Skip to content

Commit

Permalink
Minor tidying-up of workspace-relative vs absolute labels.
Browse files Browse the repository at this point in the history
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] bazelbuild/bazel#3115

GitOrigin-RevId: 7e5120adf89230c32569c6d9eb281123f1d48b54
  • Loading branch information
jmillikin committed May 15, 2023
1 parent 3f63792 commit f916234
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion m4/BUILD
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions m4/internal/testutil_ext.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion m4/internal/toolchain_alias.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Expand Down
2 changes: 1 addition & 1 deletion m4/internal/toolchain_info.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
12 changes: 6 additions & 6 deletions m4/m4.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)

Expand Down
6 changes: 3 additions & 3 deletions m4/rules/m4.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Expand Down Expand Up @@ -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",
),
},
Expand Down
16 changes: 8 additions & 8 deletions m4/rules/m4_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
),
},
Expand Down
4 changes: 2 additions & 2 deletions m4/toolchains/BUILD
Original file line number Diff line number Diff line change
@@ -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),
Expand Down
4 changes: 2 additions & 2 deletions tests/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@rules_m4//m4:m4.bzl", "m4")
load("//m4:m4.bzl", "m4")

m4(
name = "expansion_test",
Expand All @@ -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(
Expand Down

0 comments on commit f916234

Please sign in to comment.