fix: write_source_files incompatibility with bzlmod when writing from external repo
This commit is contained in:
parent
fc0ff4de2b
commit
c64bb72324
|
@ -0,0 +1 @@
|
||||||
|
common --enable_bzlmod
|
|
@ -0,0 +1 @@
|
||||||
|
../../.bazelversion
|
|
@ -0,0 +1,10 @@
|
||||||
|
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
|
||||||
|
|
||||||
|
# This tests that the "in" file to write_source_files can be a
|
||||||
|
# label to an external repository target when bzlmod is enabled.
|
||||||
|
write_source_files(
|
||||||
|
name = "write_external",
|
||||||
|
files = {
|
||||||
|
"foobar.txt": "@test//:foobar.txt",
|
||||||
|
},
|
||||||
|
)
|
|
@ -0,0 +1,17 @@
|
||||||
|
module(
|
||||||
|
name = "e2e_bzlmod_write_source_files_external",
|
||||||
|
compatibility_level = 1,
|
||||||
|
version = "0.0.0",
|
||||||
|
)
|
||||||
|
|
||||||
|
bazel_dep(name = "aspect_bazel_lib", version = "0.0.0")
|
||||||
|
|
||||||
|
local_path_override(
|
||||||
|
module_name = "aspect_bazel_lib",
|
||||||
|
path = "../..",
|
||||||
|
)
|
||||||
|
|
||||||
|
test_ext = use_extension("//:test_extension.bzl", "test_ext")
|
||||||
|
|
||||||
|
use_repo(test_ext, "test")
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Marker file that this folder is the root of a Bazel workspace.
|
||||||
|
# See MODULE.bazel for dependencies and setup.
|
|
@ -0,0 +1 @@
|
||||||
|
foobar
|
|
@ -0,0 +1,20 @@
|
||||||
|
"Test module extension to create a test repository"
|
||||||
|
|
||||||
|
def _test_repo_impl(rctx):
|
||||||
|
rctx.file("BUILD.bazel", """\
|
||||||
|
exports_files(["foobar.txt"], visibility = ["//visibility:public"])
|
||||||
|
""", executable = False)
|
||||||
|
|
||||||
|
rctx.file("foobar.txt", "foobar\n")
|
||||||
|
|
||||||
|
test_repo = repository_rule(
|
||||||
|
local = True,
|
||||||
|
implementation = _test_repo_impl,
|
||||||
|
)
|
||||||
|
|
||||||
|
def _test_ext_impl(_):
|
||||||
|
test_repo(name = "test")
|
||||||
|
|
||||||
|
test_ext = module_extension(
|
||||||
|
implementation = _test_ext_impl,
|
||||||
|
)
|
|
@ -57,8 +57,7 @@ def write_source_file(
|
||||||
if not out_file:
|
if not out_file:
|
||||||
fail("out_file must be specified if in_file is set")
|
fail("out_file must be specified if in_file is set")
|
||||||
|
|
||||||
if in_file and out_file:
|
if out_file:
|
||||||
in_file = utils.to_label(in_file)
|
|
||||||
out_file = utils.to_label(out_file)
|
out_file = utils.to_label(out_file)
|
||||||
|
|
||||||
if utils.is_external_label(out_file):
|
if utils.is_external_label(out_file):
|
||||||
|
|
Loading…
Reference in New Issue