Skip to content

Commit

Permalink
fix: add missing runfiles and general improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy committed Jul 5, 2024
1 parent 0495990 commit 9eb54f9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 21 deletions.
1 change: 1 addition & 0 deletions rules/private/bzlws_tool_cc_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def _bzlws_tool_cc_binary(ctx):

return DefaultInfo(
files = depset([output.executable]),
default_runfiles = ctx.runfiles(ctx.files.srcs + [output.executable]),
executable = output.executable,
)

Expand Down
22 changes: 11 additions & 11 deletions test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ load("@bzlws//rules:bzlws_link.bzl", "bzlws_link")

bzlws_copy(
name = "copy_example_txt",
srcs = ["example.txt"],
srcs = ["exampledir/example.txt"],
out = "ignored_folder/{FILENAME}",
)

bzlws_copy(
name = "copy_example_txt_file_path",
srcs = ["example.txt"],
srcs = ["exampledir/example.txt"],
out = "ignored_folder/{FILEPATH}",
force = True,
)
Expand All @@ -23,31 +23,31 @@ bzlws_copy(

bzlws_link(
name = "link_example_txt",
srcs = ["example.txt"],
srcs = ["exampledir/example.txt"],
out = "ignored_folder/{FILENAME}",
)

bzlws_copy(
name = "copy_error_example_txt",
srcs = ["example.txt"],
srcs = ["exampledir/example.txt"],
out = "folder/{FILENAME}",
)

bzlws_copy(
name = "link_error_example_txt",
srcs = ["example.txt"],
srcs = ["exampledir/example.txt"],
out = "folder/{FILENAME}",
)

bzlws_copy(
name = "path_substitutions_example1",
srcs = ["example.txt"],
srcs = ["exampledir/example.txt"],
out = "ignored_folder/__{BASENAME}__{EXT}",
)

bzlws_copy(
name = "path_substitutions_example2",
srcs = ["example.txt"],
srcs = ["exampledir/example.txt"],
out = "ignored_folder/{EXTNAME}__{FILENAME}",
)

Expand All @@ -64,7 +64,7 @@ bzlws_copy(
bzlws_copy(
name = "info_all_example",
srcs = ["info.txt"],
out = "example/ignored_folder/{FILENAME}",
out = "ignored_folder/{FILENAME}",
substitutions = {
"@bzlws//info:bazel-bin": "__bazel-bin",
"@bzlws//info:bazel-genfiles": "__bazel-genfiles",
Expand Down Expand Up @@ -95,15 +95,15 @@ bzlws_copy(
bzlws_copy(
name = "stamp_subst_example",
srcs = ["stamp_info.txt"],
out = "example/ignored_folder/{FILENAME}",
out = "ignored_folder/{FILENAME}",
stamp_substitutions = {
"BUILD_HOST": "__BUILD_HOST__",
},
)

bzlws_copy(
name = "stamp_out_path",
srcs = ["example.txt"],
out = "example/ignored_folder/{BUILD_HOST}/{BUILD_USER}/{FILENAME}",
srcs = ["exampledir/example.txt"],
out = "ignored_folder/{BUILD_HOST}/{BUILD_USER}/{FILENAME}",
force = True,
)
2 changes: 1 addition & 1 deletion test/test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bazel run --config=test //:copy_example_txt
Test-Path-Or-Exit .\ignored_folder\example.txt

bazel run --config=test //:copy_example_txt_file_path
Test-Path-Or-Exit .\ignored_folder\example\example.txt
Test-Path-Or-Exit .\ignored_folder\exampledir\example.txt

bazel run --config=test //:copy_example_txt_file_path_external
Test-Path-Or-Exit .\ignored_folder\external\faux_repo\example.txt
Expand Down
5 changes: 3 additions & 2 deletions test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -e
function test_path_or_exit {
if [ ! -f "$1" ]; then
echo "Test FAILED: '$1' does not exist"
exit 1
fi
}

Expand All @@ -15,9 +16,9 @@ bazel run --config=test //:copy_example_txt
test_path_or_exit ./ignored_folder/example.txt

bazel run --config=test //:copy_example_txt_file_path
test_path_or_exit ./ignored_folder/example/example.txt
test_path_or_exit ./ignored_folder/exampledir/example.txt

bazel run --config=test //:copy_example_txt_file_path
bazel run --config=test //:copy_example_txt_file_path_external
test_path_or_exit ./ignored_folder/external/faux_repo/example.txt

git clean -fx . -e test/bazel-*
Expand Down
7 changes: 0 additions & 7 deletions tools/bzlws_copy/bzlws_copy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ static void copy_files
, const bzlws_tool_lib::options& options
);

static void copy_file
( const bzlws_tool_lib::options& options
, const bzlws_tool_lib::src_info& src_info
);

int bzlws_copy
( const char* argv0
, const std::vector<std::string>& args
Expand All @@ -37,8 +32,6 @@ int bzlws_copy
auto workspace_dir = get_build_workspace_dir();
auto bzlignore = parse_bazelignore(workspace_dir);
auto options = parse_args(workspace_dir, argv0, args);

auto wsDirSz = workspace_dir.generic_string().size();

for(const auto& info : options.srcs_info) {
bzlignore.assert_ignored_path(info.new_src_path);
Expand Down

0 comments on commit 9eb54f9

Please sign in to comment.