fix(write_source_files): fix writing to workspace root (#53)
This commit is contained in:
parent
d21acfbd5a
commit
a2e228dde0
|
@ -1 +1,2 @@
|
|||
bazel-*
|
||||
test-out/
|
||||
|
|
14
BUILD.bazel
14
BUILD.bazel
|
@ -20,3 +20,17 @@ bzl_library(
|
|||
"@bazel_tools//tools/build_defs/repo:utils.bzl",
|
||||
],
|
||||
)
|
||||
|
||||
# write_source_files() to a git ignored subdirectory of the root
|
||||
load("//lib:write_source_files.bzl", "write_source_files")
|
||||
genrule(
|
||||
name = "write_source_file_root",
|
||||
outs = ["write_source_file-root_directory"],
|
||||
cmd = "mkdir -p $@ && echo 'test' > $@/test.txt",
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
write_source_files(
|
||||
name = "write_source_file_root-test",
|
||||
diff_test = False,
|
||||
files = {"test-out/dist/write_source_file_root-test": ":write_source_file_root"},
|
||||
)
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
bazel run //:write_source_file_root-test
|
|
@ -266,7 +266,7 @@ def _write_source_file_impl(ctx):
|
|||
else:
|
||||
fail("in file %s must be a single file or a target that provides DefaultOutputPathInfo or DirectoryPathInfo" % ctx.attr.in_file.label)
|
||||
|
||||
out_path = "/".join([ctx.label.package, ctx.attr.out_file])
|
||||
out_path = "/".join([ctx.label.package, ctx.attr.out_file]) if ctx.label.package else ctx.attr.out_file
|
||||
paths.append((in_path, out_path))
|
||||
|
||||
if ctx.attr.is_windows:
|
||||
|
|
Loading…
Reference in New Issue