Skip to content

Commit 31882f3

Browse files
committed
Use cc_binary
1 parent ab0dc64 commit 31882f3

File tree

7 files changed

+17
-35
lines changed

7 files changed

+17
-35
lines changed

BUILD

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@ filegroup(
2525
# Implementation:
2626
# If you are looking into the implementation, start with the overview in ImplementationReadme.md.
2727

28-
exports_files(["refresh.template.py", "check_python_version.template.py", "print_args.py"]) # For implicit use by the refresh_compile_commands macro, not direct use.
28+
exports_files(["refresh.template.py", "check_python_version.template.py"]) # For implicit use by the refresh_compile_commands macro, not direct use.
2929

30-
filegroup(
30+
cc_binary(
3131
name = "print_args",
32-
srcs = select({
33-
"@bazel_tools//src/conditions:host_windows": [":print_args.bat"],
34-
"//conditions:default": [":print_args.sh"],
35-
}),
32+
srcs = ["print_args.cc"],
3633
visibility = ["//visibility:public"],
3734
)

print_args.bat

Lines changed: 0 additions & 3 deletions
This file was deleted.

print_args.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Prints the arguments passed to the script
2+
3+
#include <iostream>
4+
5+
int main(int argc, char *argv[]) {
6+
std::cout << "===HEDRON_COMPILE_COMMANDS_BEGIN_ARGS===\n";
7+
for (int i = 1; i < argc; ++i) {
8+
std::cout << argv[i] << "\n";
9+
}
10+
std::cout << "===HEDRON_COMPILE_COMMANDS_END_ARGS===\n";
11+
// We purposely return a non-zero exit code to have the emcc process exit after running this fake clang wrapper.
12+
return 1;
13+
}

print_args.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

print_args.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

refresh.template.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,6 @@ def get_workspace_root(path_from_execroot: pathlib.PurePath):
780780
'EM_CONFIG_PATH': str(get_workspace_root(emcc_driver) / 'emscripten_toolchain' / 'emscripten_config'),
781781
'EMCC_SKIP_SANITY_CHECK': '1',
782782
'EM_COMPILER_WRAPPER': str(pathlib.PurePath({print_args_executable})),
783-
'HEDRON_COMPILE_COMMANDS_PRINT_ARGS_PY': str(pathlib.PurePath({print_args_py})),
784783
'PATH': os.environ['PATH'],
785784
}
786785

refresh_compile_commands.bzl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ def _expand_template_impl(ctx):
117117
"{exclude_headers}": repr(ctx.attr.exclude_headers),
118118
"{exclude_external_sources}": repr(ctx.attr.exclude_external_sources),
119119
"{print_args_executable}": repr(ctx.executable._print_args_executable.path),
120-
"{print_args_py}": repr(ctx.file._print_args_py.path),
121120
},
122121
)
123122
return DefaultInfo(files = depset([script]))
@@ -128,8 +127,7 @@ _expand_template = rule(
128127
"exclude_external_sources": attr.bool(default = False),
129128
"exclude_headers": attr.string(values = ["all", "external", ""]), # "" needed only for compatibility with Bazel < 3.6.0
130129
"_script_template": attr.label(allow_single_file = True, default = "refresh.template.py"),
131-
"_print_args_executable": attr.label(executable = True, allow_single_file = True, cfg = "target", default = "print_args"),
132-
"_print_args_py": attr.label(allow_single_file = True, default = "print_args.py"),
130+
"_print_args_executable": attr.label(executable = True, cfg = "target", default = "//:print_args"),
133131
# For Windows INCLUDE. If this were eliminated, for example by the resolution of https://github.com/clangd/clangd/issues/123, we'd be able to just use a macro and skylib's expand_template rule: https://github.com/bazelbuild/bazel-skylib/pull/330
134132
# Once https://github.com/bazelbuild/bazel/pull/17108 is widely released, we should be able to eliminate this and get INCLUDE directly. Perhaps for 7.0? Should be released in the sucessor to 6.0
135133
"_cc_toolchain": attr.label(default = "@bazel_tools//tools/cpp:current_cc_toolchain"),

0 commit comments

Comments
 (0)