From ed50da473657426d5eb085320b1d8f5223dace5e Mon Sep 17 00:00:00 2001 From: Marcel Hlopko Date: Mon, 4 May 2020 10:56:00 +0200 Subject: [PATCH 1/5] Disable unnamed-macro check for cc_configure --- cc/private/toolchain/cc_configure.bzl | 1 + 1 file changed, 1 insertion(+) diff --git a/cc/private/toolchain/cc_configure.bzl b/cc/private/toolchain/cc_configure.bzl index b26f2b5..c281198 100644 --- a/cc/private/toolchain/cc_configure.bzl +++ b/cc/private/toolchain/cc_configure.bzl @@ -173,6 +173,7 @@ cc_autoconf = repository_rule( configure = True, ) +# buildifier: disable=unnamed-macro def cc_configure(): """A C++ configuration rules that generate the crosstool file.""" cc_autoconf_toolchains(name = "local_config_cc_toolchains") From b70b375b6dd6eb33d58595a889ca508c06c45ca8 Mon Sep 17 00:00:00 2001 From: Marcel Hlopko Date: Mon, 4 May 2020 10:58:34 +0200 Subject: [PATCH 2/5] Add `name` parameter to `cc_configure` To satisfy the buildifier and make the build green again. --- cc/private/toolchain/cc_configure.bzl | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cc/private/toolchain/cc_configure.bzl b/cc/private/toolchain/cc_configure.bzl index c281198..fa630be 100644 --- a/cc/private/toolchain/cc_configure.bzl +++ b/cc/private/toolchain/cc_configure.bzl @@ -173,13 +173,17 @@ cc_autoconf = repository_rule( configure = True, ) -# buildifier: disable=unnamed-macro -def cc_configure(): - """A C++ configuration rules that generate the crosstool file.""" - cc_autoconf_toolchains(name = "local_config_cc_toolchains") - cc_autoconf(name = "local_config_cc") - native.bind(name = "cc_toolchain", actual = "@local_config_cc//:toolchain") +def cc_configure(name = "local_config_cc"): + """A C++ configuration rules that generate the crosstool file. + + Args: + name: name of the repository + """ + cc_autoconf_toolchains(name = name + "_toolchains") + cc_autoconf(name = name) + if name == "local_config_cc": + native.bind(name = "cc_toolchain", actual = "@local_config_cc//:toolchain") native.register_toolchains( # Use register_toolchain's target pattern expansion to register all toolchains in the package. - "@local_config_cc_toolchains//:all", + "@" + name + "_toolchains//:all", ) From e8781b53aa49406c3f47c9885c0eb28519eedcaf Mon Sep 17 00:00:00 2001 From: Marcel Hlopko Date: Mon, 4 May 2020 11:18:21 +0200 Subject: [PATCH 3/5] Fix repositories.bzl --- cc/repositories.bzl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cc/repositories.bzl b/cc/repositories.bzl index 5ddb373..41b8adb 100644 --- a/cc/repositories.bzl +++ b/cc/repositories.bzl @@ -23,8 +23,8 @@ def rules_cc_dependencies(): ], ) -def rules_cc_toolchains(*args): - cc_configure(*args) +def rules_cc_toolchains(name, *args): + cc_configure(name, *args) def _maybe(repo_rule, name, **kwargs): if not native.existing_rule(name): From 65436199d8d6fe8400aa3d8a348af9e8dd585909 Mon Sep 17 00:00:00 2001 From: Marcel Hlopko Date: Mon, 4 May 2020 11:20:17 +0200 Subject: [PATCH 4/5] Duh --- cc/repositories.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cc/repositories.bzl b/cc/repositories.bzl index 41b8adb..f52ade2 100644 --- a/cc/repositories.bzl +++ b/cc/repositories.bzl @@ -23,7 +23,7 @@ def rules_cc_dependencies(): ], ) -def rules_cc_toolchains(name, *args): +def rules_cc_toolchains(name = "local_config_cc", *args): cc_configure(name, *args) def _maybe(repo_rule, name, **kwargs): From 0e4443f2cae12a2916a9f631976a454cfb0f7583 Mon Sep 17 00:00:00 2001 From: Marcel Hlopko Date: Mon, 4 May 2020 11:45:39 +0200 Subject: [PATCH 5/5] Instead disable the buildifier warning --- cc/private/toolchain/cc_configure.bzl | 18 +++++++----------- cc/repositories.bzl | 5 +++-- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/cc/private/toolchain/cc_configure.bzl b/cc/private/toolchain/cc_configure.bzl index fa630be..c281198 100644 --- a/cc/private/toolchain/cc_configure.bzl +++ b/cc/private/toolchain/cc_configure.bzl @@ -173,17 +173,13 @@ cc_autoconf = repository_rule( configure = True, ) -def cc_configure(name = "local_config_cc"): - """A C++ configuration rules that generate the crosstool file. - - Args: - name: name of the repository - """ - cc_autoconf_toolchains(name = name + "_toolchains") - cc_autoconf(name = name) - if name == "local_config_cc": - native.bind(name = "cc_toolchain", actual = "@local_config_cc//:toolchain") +# buildifier: disable=unnamed-macro +def cc_configure(): + """A C++ configuration rules that generate the crosstool file.""" + cc_autoconf_toolchains(name = "local_config_cc_toolchains") + cc_autoconf(name = "local_config_cc") + native.bind(name = "cc_toolchain", actual = "@local_config_cc//:toolchain") native.register_toolchains( # Use register_toolchain's target pattern expansion to register all toolchains in the package. - "@" + name + "_toolchains//:all", + "@local_config_cc_toolchains//:all", ) diff --git a/cc/repositories.bzl b/cc/repositories.bzl index f52ade2..5d0c56b 100644 --- a/cc/repositories.bzl +++ b/cc/repositories.bzl @@ -23,8 +23,9 @@ def rules_cc_dependencies(): ], ) -def rules_cc_toolchains(name = "local_config_cc", *args): - cc_configure(name, *args) +# buildifier: disable=unnamed-macro +def rules_cc_toolchains(*args): + cc_configure(*args) def _maybe(repo_rule, name, **kwargs): if not native.existing_rule(name):