From 834470a763e508e5342ff2a13081f08d54f20eea Mon Sep 17 00:00:00 2001 From: Isaac Torres Date: Mon, 17 Oct 2022 16:56:06 -0600 Subject: [PATCH 1/3] Wrap sh_binary in macro --- BUILD.bazel | 7 +------ qac_compile_commands.bzl | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 qac_compile_commands.bzl diff --git a/BUILD.bazel b/BUILD.bazel index 85bd5b43..f3982a2b 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,6 +1 @@ -sh_binary( - name = "qac_compile_commands", - srcs = ["qac_compile_commands.sh"], - args = ["$(location //:refresh_compile_commands)"], - data = ["//:refresh_compile_commands"], -) +exports_files(["qac_compile_commands.sh"]) diff --git a/qac_compile_commands.bzl b/qac_compile_commands.bzl new file mode 100644 index 00000000..7531d630 --- /dev/null +++ b/qac_compile_commands.bzl @@ -0,0 +1,18 @@ +def qac_compile_commands(name, tool): + """Replaces -isystem with -I in a compile_commands.json file. + + This is necessary to get Helix QAC to work correctly. + + Args: + name: A unique label for this rule. + tool: A label refrencing a @hedron_compile_commands:refresh_compile_commands target. + + """ + arg = "$(location {})".format(tool) + native.sh_binary( + name = name, + # FIXME: Assumes //bazel is a valid label in the consuming workspace. + srcs = ["//bazel:qac_compile_commands.sh"], + args = [arg], + data = [tool], + ) From bb9ca094046473c248fd6c524d49029f046e4404 Mon Sep 17 00:00:00 2001 From: Isaac Torres Date: Mon, 17 Oct 2022 17:32:10 -0600 Subject: [PATCH 2/3] Add kwargs parameter --- qac_compile_commands.bzl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qac_compile_commands.bzl b/qac_compile_commands.bzl index 7531d630..d389aaf5 100644 --- a/qac_compile_commands.bzl +++ b/qac_compile_commands.bzl @@ -1,4 +1,4 @@ -def qac_compile_commands(name, tool): +def qac_compile_commands(name, tool, **kwargs): """Replaces -isystem with -I in a compile_commands.json file. This is necessary to get Helix QAC to work correctly. @@ -15,4 +15,5 @@ def qac_compile_commands(name, tool): srcs = ["//bazel:qac_compile_commands.sh"], args = [arg], data = [tool], + **kwargs, ) From 338e497b8250c9d254be5eb980dbbf70eb7e41a8 Mon Sep 17 00:00:00 2001 From: Isaac Torres Date: Mon, 17 Oct 2022 17:47:54 -0600 Subject: [PATCH 3/3] Run buildifier --- qac_compile_commands.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qac_compile_commands.bzl b/qac_compile_commands.bzl index d389aaf5..3c2b8977 100644 --- a/qac_compile_commands.bzl +++ b/qac_compile_commands.bzl @@ -15,5 +15,5 @@ def qac_compile_commands(name, tool, **kwargs): srcs = ["//bazel:qac_compile_commands.sh"], args = [arg], data = [tool], - **kwargs, + **kwargs )