Skip to content

Commit e160627

Browse files
committed
Allow use of refresh_compile_commands from sub-packages
Aims to fix hedronvision#137
1 parent ecafb96 commit e160627

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

refresh_compile_commands.bzl

+6
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ def refresh_compile_commands(
7777
elif type(targets) != "dict": # Assume they've supplied a single string/label and wrap it
7878
targets = {targets: ""}
7979

80+
# Make any package-relative labels absolute
81+
targets = {
82+
target if target.startswith("/") or target.startswith("@") else "@{}//{}:{}".format(native.repository_name(), native.package_name(), target.removeprefix(":")): flags for target, flags in targets.items()
83+
}
84+
8085
# Create a wrapper script that prints a helpful error message if the python version is too old, generated from check_python_version.template.py
8186
version_checker_script_name = name + ".check_python_version.py"
8287
_check_python_version(name = version_checker_script_name, to_run = name)
@@ -93,6 +98,7 @@ def refresh_compile_commands(
9398
version_checker_script_name,
9499
script_name,
95100
],
101+
imports = [''], # Allows binary to import templated script, even if this macro is being called inside a sub package. See https://github.com/hedronvision/bazel-compile-commands-extractor/issues/137
96102
**kwargs
97103
)
98104

0 commit comments

Comments
 (0)