Skip to content

Commit

Permalink
pull in BUILD.bazel from somewhere under src/
Browse files Browse the repository at this point in the history
  • Loading branch information
wade-arista committed Jan 26, 2024
1 parent ec90e04 commit 7779919
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
7 changes: 7 additions & 0 deletions extfiles/src/ref1/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
genrule(
name = "gen_test_input",
srcs = ["root/input.txt"],
outs = ["test_input"],
cmd = "cat $< > $@",
visibility = ["//visibility:public"],
)
11 changes: 5 additions & 6 deletions extfiles/src/rules/import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ bring in files from outside of bazel
"""

def _input_importer_impl(repository_ctx):
dirname = repository_ctx.os.environ.get("EXT_ROOT", "/run/user/1000/ext/")
dirname = repository_ctx.os.environ["EXT_ROOT"]
print("importing from", dirname)
repository_ctx.symlink(dirname + "input.txt", "input.txt")
repository_ctx.symlink(dirname + "BUILD.bazel", "BUILD.bazel")
content = repository_ctx.read("BUILD.bazel")
repository_ctx.file("BUILD", content = content)
repository_ctx.symlink(dirname, "root")
srcRoot = repository_ctx.os.environ["SRC_ROOT"]
repository_ctx.file("BUILD", content = repository_ctx.read(srcRoot + "/BUILD.bazel"))

input_importer = repository_rule(
implementation = _input_importer_impl,
attrs = {},
environ = ["EXT_ROOT"],
environ = ["EXT_ROOT", "SRC_ROOT"],
local = True,
)

Expand Down

0 comments on commit 7779919

Please sign in to comment.