Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prefer param file in current path #17

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rules/private/bzlws_tool_cc_binary.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
load("@bzlws//rules/private:bzlws_info.bzl", "BzlwsInfo")
load("@bzlws//rules/private:bzlws_util.bzl", "bzlws_get_full_label_string")
load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain", "use_cc_toolchain")
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")

def _bzlws_tool_cc_binary(ctx):
name = ctx.attr.name
Expand Down Expand Up @@ -99,7 +99,7 @@ def _bzlws_tool_cc_binary(ctx):

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

Expand Down
11 changes: 9 additions & 2 deletions tools/bzlws_tool_lib/bzlws_tool_lib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,20 @@ bzlws_tool_lib::options bzlws_tool_lib::parse_args

if(arg == "--params_file") {
auto param_file = next_arg();
if(!fs::exists(workspace_dir / param_file)) {
auto param_file_path = fs::path{param_file};
if(!fs::exists(param_file_path)) {
param_file_path = workspace_dir / param_file_path;
}
if(!fs::exists(param_file_path)) {
param_file_path = runfiles->Rlocation(param_file);
}
if(!fs::exists(param_file_path)) {
std::cerr
<< "[ERROR] Unable to read params file: " << param_file << std::endl;
tool_exit(exit_code::filesystem_error);
}

std::ifstream param_file_stream(workspace_dir / param_file);
std::ifstream param_file_stream(param_file_path);

auto get_next_line = [&]{
std::string next_line;
Expand Down