Skip to content

Commit 3a8dabd

Browse files
committed
Add workaround for rules_foreign_cc
1 parent 9fc4140 commit 3a8dabd

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

bazel/detail/tools/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ EXE_EXT = ".exe" if "windows" in HOST_TARGET else ""
7474
out = tool + SCRIPT_EXT,
7575
data = ["@llvm-{}//:bin/{}{}".format(HOST_TARGET, tool, EXE_EXT)],
7676
substitutions = {
77-
"TOOL": "$(execpath @llvm-{}//:bin/{}{})".format(HOST_TARGET, tool, EXE_EXT),
77+
"{{TOOL}}": "$(execpath @llvm-{}//:bin/{}{})".format(HOST_TARGET, tool, EXE_EXT),
7878
},
7979
template = "wrapper" + SCRIPT_EXT,
8080
),
8181
expand_template(
8282
name = tool + "_bat",
8383
out = tool + ".bat",
8484
substitutions = {
85-
"TOOL": tool,
85+
"{{TOOL}}": tool,
8686
},
8787
template = "wrapper.bat",
8888
),

bazel/detail/tools/wrapper.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
@echo off
2-
powershell -ExecutionPolicy Bypass -File "%~dp0TOOL.ps1" %*
2+
powershell -ExecutionPolicy Bypass -File "%~dp0{{TOOL}}.ps1" %*
33
set exitcode=%errorlevel%
4-
exit /b %exitcode%
4+
exit /b %exitcode%

bazel/detail/tools/wrapper.ps1

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
$exe = 'TOOL' -replace '/', '\'
1+
if ($env:EXT_BUILD_ROOT) {
2+
# Workaround for rules_foreign_cc
3+
$exe = (Join-Path $env:EXT_BUILD_ROOT '{{TOOL}}') -replace '/', '\'
4+
} else {
5+
$exe = '{{TOOL}}' -replace '/', '\'
6+
}
7+
28
$processedArgs = @()
39
foreach ($arg in $args) {
410
$processedArg = $arg -replace '__BAZEL_EXECUTION_ROOT__', $PWD.Path
@@ -10,4 +16,4 @@ foreach ($arg in $args) {
1016
$toolExitCode = $LASTEXITCODE
1117

1218
# Exit with the same code as the tool
13-
exit $toolExitCode
19+
exit $toolExitCode

bazel/detail/tools/wrapper.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@ args=()
44
for i in "$@"; do
55
args+=("${i//__BAZEL_EXECUTION_ROOT__/$PWD}")
66
done
7-
TOOL "${args[@]}"
7+
8+
if [ -z ${EXT_BUILD_ROOT+x} ]; then
9+
"{{TOOL}}" "${args[@]}"
10+
else
11+
# workaround for rules_foreign_cc
12+
"$EXT_BUILD_ROOT/{{TOOL}}" "${args[@]}"
13+
fi

0 commit comments

Comments
 (0)