1
0
mirror of https://github.com/dart-lang/sdk synced 2024-07-03 00:08:46 +00:00

[dart2wasm] Build product snapshot when building for the SDK.

The `dartaotruntime` is built in `product` mode even when we do a release build. This CL wires up a product flag so we always build the Dart2Wasm product snapshot when creating the SDK.

Change-Id: Ic8c6a6da180a47a19ba818d7c449f712c9e60123
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264887
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
This commit is contained in:
Joshua Litt 2022-10-26 17:04:17 +00:00 committed by Commit Queue
parent 478f2bb34c
commit 1ed2a07022
5 changed files with 35 additions and 6 deletions

View File

@ -109,8 +109,12 @@ group("dart2wasm_platform") {
"utils/dart2wasm:compile_dart2wasm_platform",
"utils/dart2wasm:dart2wasm_snapshot",
]
if (defined(is_product) && !is_product) {
deps += [ "utils/dart2wasm:dart2wasm_asserts_snapshot" ]
if (defined(is_product)) {
if (is_product) {
deps += [ "utils/dart2wasm:dart2wasm_product_snapshot" ]
} else {
deps += [ "utils/dart2wasm:dart2wasm_asserts_snapshot" ]
}
}
}

View File

@ -347,6 +347,10 @@ template("dart_action") {
# packages (optional):
# The un-rebased path to the package_config.json file.
#
# force_product_mode (optional):
# Setting this to true will cause snapshot to be built in product mode even
# if dart_runtime_mode is not product.
#
# Forwarded to action() with the usual meaning:
# depfile
# deps
@ -355,12 +359,19 @@ template("dart_action") {
# testonly
# visibility
template("gen_snapshot_action") {
product_mode =
(defined(dart_runtime_mode) && dart_runtime_mode == "release") ||
(defined(invoker.force_product_mode) && invoker.force_product_mode)
assert(
!defined(invoker.script),
"script must not be defined for $target_name. If there is a script use args instead.")
if (!_is_fuchsia || !use_prebuilt_dart_sdk) {
_built_tool_action(target_name) {
tool = "$_dart_root/runtime/bin:gen_snapshot"
if (product_mode) {
tool = "$_dart_root/runtime/bin:gen_snapshot_product"
} else {
tool = "$_dart_root/runtime/bin:gen_snapshot"
}
forward_variables_from(invoker,
[
"args",

View File

@ -43,7 +43,7 @@ declare_args() {
# ......snapshots/
# ........analysis_server.dart.snapshot
# ........dart2js.dart.snapshot
# ........dart2wasm.dart.snapshot (if not on ia32)
# ........dart2wasm_product.snapshot (if not on ia32)
# ........dartdev.dart.snapshot
# ........dartdev.dill
# ........dartdevc.dart.snapshot
@ -510,9 +510,9 @@ copy("copy_dart2wasm_snapshot") {
visibility = [ ":create_full_sdk" ]
deps = [
":copy_libraries",
"../utils/dart2wasm:dart2wasm_snapshot",
"../utils/dart2wasm:dart2wasm_product_snapshot",
]
sources = [ "$root_out_dir/dart2wasm.snapshot" ]
sources = [ "$root_out_dir/dart2wasm_product.snapshot" ]
outputs =
[ "$root_out_dir/$dart_sdk_output/bin/snapshots/{{source_file_part}}" ]
}

View File

@ -9,6 +9,9 @@ _dart_root = get_path_info("..", "abspath")
template("aot_snapshot") {
assert(defined(invoker.main_dart), "Must specify 'main_dart'")
product_mode =
(defined(dart_runtime_mode) && dart_runtime_mode == "release") ||
(defined(invoker.force_product_mode) && invoker.force_product_mode)
gen_kernel_args = []
if (defined(invoker.gen_kernel_args)) {
gen_kernel_args = invoker.gen_kernel_args
@ -92,6 +95,9 @@ template("aot_snapshot") {
]
args += gen_kernel_args
args += [ rebase_path(main_dart) ]
if (product_mode) {
args += [ "-Ddart.vm.product=true" ]
}
}
# Create a snapshot from kernel built above.
@ -114,5 +120,7 @@ template("aot_snapshot") {
] + gen_snapshot_args
args = [ rebase_path(dill) ]
force_product_mode = product_mode
}
}

View File

@ -35,6 +35,12 @@ aot_snapshot("dart2wasm_asserts_snapshot") {
gen_snapshot_args = [ "--enable-asserts" ]
}
aot_snapshot("dart2wasm_product_snapshot") {
main_dart = "../../pkg/dart2wasm/bin/dart2wasm.dart"
name = "dart2wasm_product"
force_product_mode = true
}
compile_platform("compile_dart2wasm_platform") {
single_root_scheme = "org-dartlang-sdk"
single_root_base = rebase_path("$sdk_root/")