From f916234dd7595a559237b7fcc39b2bd26af9591d Mon Sep 17 00:00:00 2001 From: John Millikin Date: Mon, 15 May 2023 12:42:06 +0900 Subject: [PATCH] Minor tidying-up of workspace-relative vs absolute labels. The use of absolute labels in `load()` calls was a workaround for a Bazel bug[0] that was fixed in 2018, before the Bazel v1.0 release. Using either absolute or relative labels as appropriate makes it easier to understand whether a given load is expected to happen in the `@rules_m4` repository or in the root workspace. [0] https://github.com/bazelbuild/bazel/issues/3115 GitOrigin-RevId: 7e5120adf89230c32569c6d9eb281123f1d48b54 --- m4/BUILD | 2 +- m4/internal/testutil_ext.bzl | 4 ++-- m4/internal/toolchain_alias.bzl | 2 +- m4/internal/toolchain_info.bzl | 2 +- m4/m4.bzl | 12 ++++++------ m4/rules/m4.bzl | 6 +++--- m4/rules/m4_repository.bzl | 16 ++++++++-------- m4/toolchains/BUILD | 4 ++-- tests/BUILD | 4 ++-- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/m4/BUILD b/m4/BUILD index 11efba1..5250e38 100644 --- a/m4/BUILD +++ b/m4/BUILD @@ -1,4 +1,4 @@ -load("@rules_m4//m4/internal:toolchain_alias.bzl", "m4_toolchain_alias") +load("//m4/internal:toolchain_alias.bzl", "m4_toolchain_alias") filegroup( name = "bzl_srcs", diff --git a/m4/internal/testutil_ext.bzl b/m4/internal/testutil_ext.bzl index 2aef88a..1685245 100644 --- a/m4/internal/testutil_ext.bzl +++ b/m4/internal/testutil_ext.bzl @@ -16,8 +16,8 @@ """Helpers for testing rules_m4 in a bzlmod-enabled workspace.""" -load("@rules_m4//m4/internal:versions.bzl", "VERSION_URLS") -load("@rules_m4//m4/rules:m4_repository.bzl", "m4_repository") +load("//m4/internal:versions.bzl", "VERSION_URLS") +load("//m4/rules:m4_repository.bzl", "m4_repository") load(":testutil.bzl", "rules_m4_testutil") def _rules_m4_testutil_ext(_module_ctx): diff --git a/m4/internal/toolchain_alias.bzl b/m4/internal/toolchain_alias.bzl index cf5339d..0fb930a 100644 --- a/m4/internal/toolchain_alias.bzl +++ b/m4/internal/toolchain_alias.bzl @@ -17,7 +17,7 @@ """Shim rule for using m4 in a genrule.""" load( - "@rules_m4//m4:toolchain_type.bzl", + "//m4:toolchain_type.bzl", "M4_TOOLCHAIN_TYPE", "m4_toolchain", ) diff --git a/m4/internal/toolchain_info.bzl b/m4/internal/toolchain_info.bzl index 7bbd980..c01ffa5 100644 --- a/m4/internal/toolchain_info.bzl +++ b/m4/internal/toolchain_info.bzl @@ -16,7 +16,7 @@ """Bazel toolchain for the m4 macro expander.""" -load("@rules_m4//m4:providers.bzl", "M4ToolchainInfo") +load("//m4:providers.bzl", "M4ToolchainInfo") def _template_vars(toolchain): return platform_common.TemplateVariableInfo({ diff --git a/m4/m4.bzl b/m4/m4.bzl index b3d9681..5a45758 100644 --- a/m4/m4.bzl +++ b/m4/m4.bzl @@ -17,29 +17,29 @@ """Bazel rules for the m4 macro expander.""" load( - "@rules_m4//m4:providers.bzl", + "//m4:providers.bzl", _M4ToolchainInfo = "M4ToolchainInfo", ) load( - "@rules_m4//m4:toolchain_type.bzl", + "//m4:toolchain_type.bzl", _M4_TOOLCHAIN_TYPE = "M4_TOOLCHAIN_TYPE", _m4_toolchain = "m4_toolchain", ) load( - "@rules_m4//m4/internal:versions.bzl", + "//m4/internal:versions.bzl", "DEFAULT_VERSION", "check_version", ) load( - "@rules_m4//m4/rules:m4.bzl", + "//m4/rules:m4.bzl", _m4 = "m4", ) load( - "@rules_m4//m4/rules:m4_repository.bzl", + "//m4/rules:m4_repository.bzl", _m4_repository = "m4_repository", ) load( - "@rules_m4//m4/rules:m4_toolchain_repository.bzl", + "//m4/rules:m4_toolchain_repository.bzl", _m4_toolchain_repository = "m4_toolchain_repository", ) diff --git a/m4/rules/m4.bzl b/m4/rules/m4.bzl index 530830f..bcb19cd 100644 --- a/m4/rules/m4.bzl +++ b/m4/rules/m4.bzl @@ -17,7 +17,7 @@ """Definition of the `m4` build rule.""" load( - "@rules_m4//m4:toolchain_type.bzl", + "//m4:toolchain_type.bzl", "M4_TOOLCHAIN_TYPE", "m4_toolchain", ) @@ -133,12 +133,12 @@ These will be added to the command args immediately before the source files. ), "_capture_stdout": attr.label( executable = True, - default = "@rules_m4//m4/internal:capture_stdout", + default = Label("//m4/internal:capture_stdout"), cfg = "host", ), "_deny_shell": attr.label( executable = True, - default = "@rules_m4//m4/internal:deny_shell", + default = Label("//m4/internal:deny_shell"), cfg = "host", ), }, diff --git a/m4/rules/m4_repository.bzl b/m4/rules/m4_repository.bzl index 08abfa4..ea0bc73 100644 --- a/m4/rules/m4_repository.bzl +++ b/m4/rules/m4_repository.bzl @@ -16,8 +16,8 @@ """Definition of the `m4_repository` repository rule.""" -load("@rules_m4//m4/internal:versions.bzl", "VERSION_URLS") -load("@rules_m4//m4/internal:gnulib/gnulib.bzl", "gnulib_overlay") +load("//m4/internal:versions.bzl", "VERSION_URLS") +load("//m4/internal:gnulib/gnulib.bzl", "gnulib_overlay") _M4_BUILD = """ cc_library( @@ -163,27 +163,27 @@ m4_repository( doc = "Additional C compiler options to use when building GNU M4.", ), "_gnulib_build": attr.label( - default = "@rules_m4//m4/internal:gnulib/gnulib.BUILD", + default = Label("//m4/internal:gnulib/gnulib.BUILD"), allow_single_file = True, ), "_gnulib_config_darwin_h": attr.label( - default = "//m4/internal:gnulib/config-darwin.h", + default = Label("//m4/internal:gnulib/config-darwin.h"), allow_single_file = True, ), "_gnulib_config_linux_h": attr.label( - default = "//m4/internal:gnulib/config-linux.h", + default = Label("//m4/internal:gnulib/config-linux.h"), allow_single_file = True, ), "_gnulib_config_windows_h": attr.label( - default = "//m4/internal:gnulib/config-windows.h", + default = Label("//m4/internal:gnulib/config-windows.h"), allow_single_file = True, ), "_gnulib_config_openbsd_h": attr.label( - default = "//m4/internal:gnulib/config-openbsd.h", + default = Label("//m4/internal:gnulib/config-openbsd.h"), allow_single_file = True, ), "_gnulib_config_freebsd_h": attr.label( - default = "//m4/internal:gnulib/config-freebsd.h", + default = Label("//m4/internal:gnulib/config-freebsd.h"), allow_single_file = True, ), }, diff --git a/m4/toolchains/BUILD b/m4/toolchains/BUILD index 6c564c6..b43228c 100644 --- a/m4/toolchains/BUILD +++ b/m4/toolchains/BUILD @@ -1,5 +1,5 @@ -load("@rules_m4//m4:toolchain_type.bzl", "M4_TOOLCHAIN_TYPE") -load("@rules_m4//m4/internal:versions.bzl", "VERSION_URLS") +load("//m4:toolchain_type.bzl", "M4_TOOLCHAIN_TYPE") +load("//m4/internal:versions.bzl", "VERSION_URLS") [toolchain( name = "v{}".format(version), diff --git a/tests/BUILD b/tests/BUILD index 2c86dec..ea04775 100644 --- a/tests/BUILD +++ b/tests/BUILD @@ -1,4 +1,4 @@ -load("@rules_m4//m4:m4.bzl", "m4") +load("//m4:m4.bzl", "m4") m4( name = "expansion_test", @@ -15,7 +15,7 @@ genrule( cp $(location expansion_test.in) genrule_test.in $(M4) --synclines genrule_test.in > $@ """, - toolchains = ["@rules_m4//m4:current_m4_toolchain"], + toolchains = ["//m4:current_m4_toolchain"], ) m4(