diff --git a/BUILD.bazel b/BUILD.bazel index e69de29b..f3982a2b 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -0,0 +1 @@ +exports_files(["qac_compile_commands.sh"]) diff --git a/qac_compile_commands.bzl b/qac_compile_commands.bzl new file mode 100644 index 00000000..3c2b8977 --- /dev/null +++ b/qac_compile_commands.bzl @@ -0,0 +1,19 @@ +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. + + 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], + **kwargs + ) diff --git a/qac_compile_commands.sh b/qac_compile_commands.sh new file mode 100755 index 00000000..fc54110d --- /dev/null +++ b/qac_compile_commands.sh @@ -0,0 +1,9 @@ +#! /bin/bash +# This script turns the -isystem flag into the -I flag. +# This is needed for Helix QAC to work properly. +# Usage: qac_compile_commands + +REFRESH_COMPILE_COMMANDS=$1 + +$REFRESH_COMPILE_COMMANDS +sed -i 's/-isystem/-I/' $BUILD_WORKSPACE_DIRECTORY/compile_commands.json