Skip to content

Commit c0eaff6

Browse files
author
Paolo Tranquilli
committed
Bazel: workaround rules_rust generation weirdness
1 parent 5f171b6 commit c0eaff6

File tree

5 files changed

+99
-78
lines changed

5 files changed

+99
-78
lines changed

misc/bazel/3rdparty/patch_defs.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import sys
2+
import re
3+
import pathlib
4+
5+
label_re = re.compile(r'"@vendor//:(.+)-([\d.]+)"')
6+
7+
file = pathlib.Path(sys.argv[1])
8+
temp = file.with_suffix(f'{file.suffix}.tmp')
9+
10+
11+
with open(file) as input, open(temp, "w") as output:
12+
for line in input:
13+
line = label_re.sub(lambda m: f'"@vendor__{m[1]}-{m[2]}//:{m[1].replace("-", "_")}"', line)
14+
output.write(line)
15+
16+
temp.rename(file)

misc/bazel/3rdparty/py_deps/defs.bzl

+10-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

misc/bazel/3rdparty/tree_sitter_extractors_deps/defs.bzl

+68-68
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

misc/bazel/3rdparty/update_py_deps.sh

+2
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ WORKSPACE_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/../../.." &> /dev/nu
66

77
cd "$WORKSPACE_DIR"
88
time bazel run //misc/bazel/3rdparty:vendor_py_deps
9+
# no idea why this is necessary, see https://github.com/bazelbuild/rules_rust/issues/3255
10+
python3 "$WORKSPACE_DIR/misc/bazel/3rdparty/patch_defs.py" misc/bazel/3rdparty/py_deps/defs.bzl
911
bazel mod tidy

misc/bazel/3rdparty/update_tree_sitter_extractors_deps.sh

+3
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ time bazel run //misc/bazel/3rdparty:vendor_tree_sitter_extractors
1010
# we need access to this file in the rust extractor
1111
echo 'exports_files(["rust.ungram"])' >> misc/bazel/3rdparty/tree_sitter_extractors_deps/BUILD.ra_ap_syntax-?.*.bazel
1212

13+
# no idea why this is necessary, see https://github.com/bazelbuild/rules_rust/issues/3255
14+
python3 "$WORKSPACE_DIR/misc/bazel/3rdparty/patch_defs.py" misc/bazel/3rdparty/tree_sitter_extractors_deps/defs.bzl
15+
1316
bazel mod tidy

0 commit comments

Comments
 (0)