experiment: env vars only

This commit is contained in:
Greg Magolan 2023-10-29 10:58:54 +01:00
parent d2638fe295
commit 108b0053ba
2 changed files with 7 additions and 4 deletions

View File

@ -59,13 +59,14 @@ Possible fixes:
for k, v in ctx.attr.env.items():
envs[k] = " ".join([expand_variables(ctx, e, outs = outputs, attribute_name = "env") for e in expand_locations(ctx, v, ctx.attr.srcs).split(" ")])
inputs = ctx.files.srcs
stamp = maybe_stamp(ctx)
if stamp:
inputs = ctx.files.srcs + [stamp.volatile_status_file, stamp.stable_status_file]
envs["BAZEL_STABLE_STATUS_FILE"] = stamp.stable_status_file.path
envs["BAZEL_VOLATILE_STATUS_FILE"] = stamp.volatile_status_file.path
else:
inputs = ctx.files.srcs
envs["BAZEL_STABLE_STATUS_FILE"] = stamp.stable_status_file.path
if not stamp.env_vars_only:
inputs = inputs + [stamp.stable_status_file, stamp.volatile_status_file]
ctx.actions.run(
outputs = outputs,

View File

@ -103,6 +103,7 @@ def maybe_stamp(ctx):
return struct(
volatile_status_file = ctx.version_file,
stable_status_file = ctx.info_file,
stamp_volatile_only = ctx.attr.stamp_volatile_only,
)
return None
@ -126,6 +127,7 @@ Whether to encode build information into the output. Possible values:
default = -1,
values = [1, 0, -1],
),
"env_vars_only": attr.bool(),
"_stamp_flag": attr.label(
doc = "Internal use only. A setting used to determine whether or not the `--stamp` flag is enabled.",
default = Label("//lib:stamp"),