Skip to content

Commit 8aff7dc

Browse files
authored
fix: Using "current_working_dir" instead of "runfiles_dir" at write_source_files (#1232)
This is a fix for: write_source_files: wrong runfiles_dir assignment with runfiles enabled for windows #1223 The working dir differs when runfiles are enabled. On windows the variables are not case sensitive, so that an assignment to "runfiles_dir" overwrites the "RUNFILES_DIR" env var (which is wrong, when runfiles are enabled).
1 parent 3da7568 commit 8aff7dc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/private/write_source_file.bzl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def _write_source_file_sh(ctx, paths):
233233

234234
contents = ["""#!/usr/bin/env bash
235235
set -o errexit -o nounset -o pipefail
236-
runfiles_dir=$PWD
236+
current_working_dir=$PWD
237237
# BUILD_WORKSPACE_DIRECTORY not set when running as a test, uses the sandbox instead
238238
if [[ ! -z "${BUILD_WORKSPACE_DIRECTORY:-}" ]]; then
239239
cd "$BUILD_WORKSPACE_DIRECTORY"
@@ -262,7 +262,7 @@ fi"""]
262262

263263
for in_path, _, _, out_path in paths:
264264
contents.append("""
265-
in=$runfiles_dir/{in_path}
265+
in=$current_working_dir/{in_path}
266266
out={out_path}
267267
268268
mkdir -p "$(dirname "$out")"
@@ -296,7 +296,7 @@ fi
296296
))
297297

298298
contents.extend([
299-
"cd \"$runfiles_dir\"",
299+
"cd \"$current_working_dir\"",
300300
"# Run the update scripts for all write_source_file deps",
301301
])
302302
for update_script in additional_update_scripts:
@@ -328,7 +328,7 @@ SETLOCAL ENABLEEXTENSIONS
328328
SETLOCAL ENABLEDELAYEDEXPANSION
329329
set RUNFILES_MANIFEST_ONLY=1
330330
""" + BATCH_RLOCATION_FUNCTION + """
331-
set runfiles_dir=%cd%
331+
set current_working_dir=%cd%
332332
if defined BUILD_WORKSPACE_DIRECTORY (
333333
cd /d %BUILD_WORKSPACE_DIRECTORY%
334334
)"""]
@@ -380,7 +380,7 @@ if !ERRORLEVEL! neq 0 (
380380
))
381381

382382
contents.extend([
383-
"cd /d %runfiles_dir%",
383+
"cd /d %current_working_dir%",
384384
"@rem Run the update scripts for all write_source_file deps",
385385
])
386386
for update_script in additional_update_scripts:

0 commit comments

Comments
 (0)