Skip to content

Commit b50717a

Browse files
authored
Replace tilde with underscore in cc_static_library (#168)
When using `bzl_mod` the folder structure below `bazel-out/k8-opt-aptiv/bin/external/` changes slightly. Modules consumed as `bazel_dep` are located no longer in `foo` but in `foo~`. The tilde (`~`) affects the archiver tooling of the `gcc-arm` toolchain, when creating a `cc_static_library`, that uses a `.mri` script. There is already an implementation, which replaces `+` with `_`. We can do the same for the tilde. Tests in - [x] `starling` (Bazel 6/`WORKSPACE`) - [x] `starling` (Bazel 7/`MODULE`) - [x] `orion` (Bazel 6/`WORKSPACE`)
1 parent db80d30 commit b50717a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cc/cc_static_library.bzl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ def _get_linker_inputs(deps):
1010
def _get_static_libaries(ctx, lib):
1111
# This statement checks if path contains "+" and replaces it with "_".
1212
# This workaround is needed for the older version of archiver (2.31.1), which doesn't accept paths with "+".
13-
if lib.path.find("+") != -1:
14-
new_lib = ctx.actions.declare_file(lib.path.replace("+", "_"))
13+
# Moreover, the archiver MRI script has hickups with paths containing "~".
14+
# This is unfortunate, because "~" is part of the folder structure when using bzl_mod.
15+
if lib.path.find("+") != -1 or lib.path.find("~") != -1:
16+
new_lib = ctx.actions.declare_file(lib.path.replace("+", "_").replace("~", "_"))
1517
ctx.actions.run_shell(
1618
command = "cp {} {}".format(lib.path, new_lib.path),
1719
inputs = [lib],

0 commit comments

Comments
 (0)