Skip to content

Commit b240344

Browse files
committed
try to make powershell version work
1 parent e514cfd commit b240344

2 files changed

Lines changed: 22 additions & 9 deletions

File tree

python/private/BUILD.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ bzl_library(
9898
],
9999
)
100100

101-
filegroup(
101+
alias(
102102
name = "build_data_writer",
103-
srcs = select({
104-
"@platforms//os:windows": ["build_data_writer.ps1"],
105-
"//conditions:default": ["build_data_writer.sh"],
103+
actual = select({
104+
"@platforms//os:windows": ":build_data_writer.ps1",
105+
"//conditions:default": ":build_data_writer.sh",
106106
}),
107107
)
108108

python/private/py_executable.bzl

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ accepting arbitrary Python versions.
208208
),
209209
"_build_data_writer": lambda: attrb.Label(
210210
default = "//python/private:build_data_writer",
211-
executable = True,
211+
allow_files = True,
212212
cfg = "exec",
213213
),
214214
"_debugger_flag": lambda: attrb.Label(
@@ -1336,14 +1336,15 @@ def _get_base_runfiles_for_binary(
13361336
)
13371337

13381338
def _write_build_data(ctx):
1339+
inputs = builders.DepsetBuilder()
13391340
if is_stamping_enabled(ctx):
13401341
# NOTE: ctx.info_file is undocumented; see
13411342
# https://github.com/bazelbuild/bazel/issues/9363
13421343
info_file = ctx.info_file
13431344
version_file = ctx.files._uncachable_version_file[0]
1344-
inputs = [info_file, version_file]
1345+
inputs.add(info_file)
1346+
inputs.add(version_file)
13451347
else:
1346-
inputs = []
13471348
info_file = None
13481349
version_file = None
13491350

@@ -1377,8 +1378,19 @@ def _write_build_data(ctx):
13771378
root = ctx.bin_dir,
13781379
)
13791380

1381+
action_args = ctx.actions.args()
1382+
writer_file = ctx.files._build_data_writer[0]
1383+
if writer_file.path.endswith(".ps1"):
1384+
action_exe = "pwsh.exe"
1385+
action_args.add("-File")
1386+
action_args.add(writer_file)
1387+
inputs.add(writer_file)
1388+
else:
1389+
action_exe = ctx.attr._build_data_writer[DefaultInfo].files_to_run
1390+
13801391
ctx.actions.run(
1381-
executable = ctx.executable._build_data_writer,
1392+
executable = action_exe,
1393+
arguments = [action_args],
13821394
env = {
13831395
# Include config mode so that binaries can detect if they're
13841396
# being used as a build tool or not, allowing for runtime optimizations.
@@ -1391,10 +1403,11 @@ def _write_build_data(ctx):
13911403
"TARGET": str(ctx.label),
13921404
"VERSION_FILE": version_file.path if version_file else "",
13931405
},
1394-
inputs = depset(direct = inputs),
1406+
inputs = inputs.build(),
13951407
outputs = [build_data],
13961408
mnemonic = "PyWriteBuildData",
13971409
progress_message = "Reticulating %{label} build data",
1410+
toolchain = None,
13981411
)
13991412
return build_data
14001413

0 commit comments

Comments
 (0)