[bazel] Backport mksnapshot additions

Support custom suffix and target_os.

Change-Id: I6117ab86974518aeb868dab101204e091830f4bc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3921516
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83495}
This commit is contained in:
Camillo 2022-09-27 13:11:57 +02:00 committed by V8 LUCI CQ
parent 16cfe9ffae
commit 3cf3b818fc

View File

@ -407,15 +407,19 @@ v8_target_cpu_transition = transition(
)
def _mksnapshot(ctx):
prefix = ctx.attr.prefix
suffix = ctx.attr.suffix
outs = [
ctx.actions.declare_file(ctx.attr.prefix + "/snapshot.cc"),
ctx.actions.declare_file(ctx.attr.prefix + "/embedded.S"),
ctx.actions.declare_file(prefix + "/snapshot" + suffix + ".cc"),
ctx.actions.declare_file(prefix + "/embedded" + suffix + ".S"),
]
ctx.actions.run(
outputs = outs,
inputs = [],
arguments = [
"--embedded_variant=Default",
"--target_os",
ctx.attr.target_os,
"--startup_src",
outs[0].path,
"--embedded_src",
@ -436,26 +440,38 @@ _v8_mksnapshot = rule(
executable = True,
cfg = "exec",
),
"target_os": attr.string(mandatory = True),
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
"prefix": attr.string(mandatory = True),
"suffix": attr.string(mandatory = True),
},
cfg = v8_target_cpu_transition,
)
def v8_mksnapshot(name, args):
def v8_mksnapshot(name, args, suffix = ""):
_v8_mksnapshot(
name = "noicu/" + name,
args = args,
prefix = "noicu",
tool = ":noicu/mksnapshot",
tool = ":noicu/mksnapshot" + suffix,
suffix = suffix,
target_os = select({
"@v8//bazel/config:is_macos": "mac",
"//conditions:default": "",
}),
)
_v8_mksnapshot(
name = "icu/" + name,
args = args,
prefix = "icu",
tool = ":icu/mksnapshot",
tool = ":icu/mksnapshot" + suffix,
suffix = suffix,
target_os = select({
"@v8//bazel/config:is_macos": "mac",
"//conditions:default": "",
}),
)
def _quote(val):