1
0
mirror of https://github.com/dart-lang/sdk synced 2024-06-28 22:05:22 +00:00
dart-sdk/BUILD.gn
Vyacheslav Egorov a4dd314c9e [tools] Allow precompiling gen_kernel and compile_platform
When iterating on core library changes or changes in the AOT compiler
many seconds are wasted waiting on gen_kernel/compile_platform to
parse Dart code. This happens because we are running these tools
from sources on prebuilt Dart SDK.

This CL allows SDK developer to opt-in into AOT compiling these
tools by adding `precompile_tools=true` to their DART_GN_ARGS.

AOT compilation is performed using prebuilt SDK - so these
executables do not need to be recompiled if core libraries or
VM changes reducing iteration cycles.

pkg/vm/tool/precompiler2 is tweaked to detect when DART_GN_ARGS
contains `precompile_tools=true` and use precompiled
gen_kernel.exe instead of running it from source.

Using precompiled compile_platform takes vm_platform_strong.dill
build from 20 seconds to 3 seconds.

Using precompiled gen_kernel takes small benchmark build from
~10 seconds to 2 seconds.

This relands 5cda2a871c with fixes
for Flutter build.

TEST=manually tested

Change-Id: I552861c80c152890655e41baaf6ea3fb3b03a57e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367961
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2024-05-24 09:40:39 +00:00

419 lines
14 KiB
Plaintext

# Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
import("build/config/gclient_args.gni")
import("sdk_args.gni")
targeting_fuchsia = target_os == "fuchsia"
# This target will be built if no target is specified when invoking ninja.
group("default") {
if (targeting_fuchsia) {
# Fuchsia has run_vm_tests marked testonly.
testonly = true
}
deps = [ ":runtime" ]
}
group("most") {
import("runtime/runtime_args.gni")
if (targeting_fuchsia) {
# Fuchsia has run_vm_tests marked testonly.
testonly = true
}
deps = [
":analysis_server",
":create_sdk",
":dart2js",
":dartanalyzer",
":ddc",
":runtime",
]
}
group("runtime") {
import("runtime/runtime_args.gni")
if (targeting_fuchsia) {
# Fuchsia has run_vm_tests marked testonly.
testonly = true
}
deps = [
"runtime/bin:dart",
"runtime/bin:ffi_test_dynamic_library",
"runtime/bin:ffi_test_functions",
"runtime/bin:process_test",
"runtime/bin:run_vm_tests",
"runtime/vm:kernel_platform_files($host_toolchain)",
"samples/ffi/http:fake_http",
"utils/dartdev:dartdev",
"utils/kernel-service:kernel-service",
]
if (!is_win) {
# The test isn't run on windows
deps += [ "runtime/bin:entrypoints_verification_test" ]
}
# This flag is set in runtime/runtime_args.gni
# The analyze_snapshot tool is only supported on 64 bit AOT builds running
# under linux and android platforms
if (build_analyze_snapshot) {
deps += [
# The `analyze_snapshot` tests require the `analyze_snapshot` as well as
# `gen_snapshot` binaries.
"runtime/bin:analyze_snapshot",
"runtime/bin:analyze_snapshot($host_toolchain)",
"runtime/bin:gen_snapshot",
"runtime/bin:gen_snapshot($host_toolchain)",
]
}
if (is_linux || is_android) {
deps += [ "runtime/bin:abstract_socket_test" ]
} else if (is_fuchsia) {
deps += [ ":fuchsia_test_package" ]
}
}
# A separate target and not included in group("runtime"). This way the target\
# "runtime" does not get many executables extra as build output.
group("run_ffi_unit_tests") {
deps = [ "runtime/bin/ffi_unit_test:run_ffi_unit_tests" ]
}
group("runtime_precompiled") {
deps = [
"runtime/bin:dart_precompiled_runtime",
"runtime/bin:gen_snapshot",
"runtime/bin:gen_snapshot($host_toolchain)",
"runtime/bin:process_test",
"runtime/vm:kernel_platform_files($host_toolchain)",
]
if (is_linux || is_android) {
deps += [ "runtime/bin:abstract_socket_test" ]
}
}
group("create_sdk") {
public_deps = [ "sdk:create_sdk" ]
}
group("create_platform_sdk") {
public_deps = [ "sdk:create_platform_sdk" ]
}
group("dart2js") {
deps = [ "utils/compiler:dart2js" ]
}
group("dart2wasm_platform") {
deps = [
":runtime_precompiled",
"utils/dart2wasm:compile_dart2wasm_js_compatibility_platform",
"utils/dart2wasm:compile_dart2wasm_platform",
"utils/dart2wasm:dart2wasm_snapshot",
]
if (defined(is_product)) {
if (is_product) {
deps += [ "utils/dart2wasm:dart2wasm_product_snapshot" ]
} else {
deps += [ "utils/dart2wasm:dart2wasm_asserts_snapshot" ]
}
}
}
group("dart2wasm") {
deps = [
":dart2wasm_platform",
"utils/dart2wasm:test_wasm_modules",
]
}
group("dart2wasm_benchmark") {
deps = [
":dart2wasm_platform",
"third_party/binaryen:wasm-opt",
]
}
group("dartanalyzer") {
deps = [ "utils/dartanalyzer" ]
}
group("ddc") {
deps = [ "utils/ddc:dartdevc" ]
}
group("analysis_server") {
deps = [ "utils/analysis_server" ]
}
group("tools") {
deps = [
"utils:compile_platform.exe",
"utils:gen_kernel.exe",
]
}
# This is the target that is built on the dart2js build bots.
# It must depend on anything that is required by the dart2js
# test suites.
group("dart2js_bot") {
deps = [ ":create_sdk" ]
}
# This rule and the compressed_observatory_archive rule are for the Fuchsia
# bots that pre-build the Observatory. They copy the observatory tar files to
# the root build output directory for convenient access by the Fuchsia buildbot
# scripts.
group("observatory_archive") {
deps = [ "runtime/observatory:copy_observatory_archive" ]
}
group("compressed_observatory_archive") {
deps = [ "runtime/observatory:copy_compressed_observatory_archive" ]
}
if (is_fuchsia) {
import("third_party/fuchsia/gn-sdk/src/component.gni")
import("third_party/fuchsia/gn-sdk/src/package.gni")
import("utils/application_snapshot.gni")
# tests/ffi/**_test.dart except those with compile-time errors
test_sources = [
"tests/ffi/abi_specific_int_incomplete_aot_test.dart",
"tests/ffi/abi_specific_int_incomplete_jit_test.dart",
"tests/ffi/abi_specific_int_test.dart",
"tests/ffi/abi_test.dart",
"tests/ffi/address_of_array_generated_test.dart",
"tests/ffi/address_of_struct_generated_test.dart",
"tests/ffi/address_of_test.dart",
"tests/ffi/address_of_typeddata_generated_test.dart",
"tests/ffi/aliasing_test.dart",
"tests/ffi/allocator_test.dart",
"tests/ffi/async_void_function_callbacks_test.dart",
"tests/ffi/bool_test.dart",
"tests/ffi/c_types_test.dart",
"tests/ffi/callback_unwind_error_test.dart",
"tests/ffi/calloc_test.dart",
"tests/ffi/data_not_asan_test.dart",
"tests/ffi/data_test.dart",
"tests/ffi/deeply_immutable_c_api_finalizer_test.dart",
"tests/ffi/dl_api_exit_enter_isolate_test.dart",
"tests/ffi/dylib_close_test.dart",
"tests/ffi/dylib_isolates_test.dart",
"tests/ffi/dylib_open_test.dart",
"tests/ffi/expando_test.dart",
"tests/ffi/extension_methods_test.dart",
"tests/ffi/external_typed_data_finalizer_test.dart",
"tests/ffi/external_typed_data_test.dart",
"tests/ffi/ffi_callback_unique_test.dart",
"tests/ffi/ffi_induce_a_crash_test.dart",
"tests/ffi/ffi_native_test.dart",
"tests/ffi/finalizer_external_size_accounting_test.dart",
"tests/ffi/function_callbacks_many_test.dart",
"tests/ffi/function_callbacks_structs_by_value_generated_test.dart",
"tests/ffi/function_callbacks_structs_by_value_native_callable_generated_test.dart",
"tests/ffi/function_callbacks_structs_by_value_test.dart",
"tests/ffi/function_callbacks_subtype_test.dart",
"tests/ffi/function_callbacks_test.dart",
"tests/ffi/function_callbacks_varargs_generated_test.dart",
"tests/ffi/function_callbacks_varargs_native_callable_generated_test.dart",
"tests/ffi/function_callbacks_very_many_test.dart",
"tests/ffi/function_struct_by_value_out_of_bounds_test.dart",
"tests/ffi/function_structs_by_value_generated_args_leaf_test.dart",
"tests/ffi/function_structs_by_value_generated_args_native_leaf_test.dart",
"tests/ffi/function_structs_by_value_generated_args_native_test.dart",
"tests/ffi/function_structs_by_value_generated_args_test.dart",
"tests/ffi/function_structs_by_value_generated_ret_arg_leaf_test.dart",
"tests/ffi/function_structs_by_value_generated_ret_arg_native_leaf_test.dart",
"tests/ffi/function_structs_by_value_generated_ret_arg_native_test.dart",
"tests/ffi/function_structs_by_value_generated_ret_arg_test.dart",
"tests/ffi/function_structs_by_value_generated_ret_leaf_test.dart",
"tests/ffi/function_structs_by_value_generated_ret_native_leaf_test.dart",
"tests/ffi/function_structs_by_value_generated_ret_native_test.dart",
"tests/ffi/function_structs_by_value_generated_ret_test.dart",
"tests/ffi/function_structs_test.dart",
"tests/ffi/function_test.dart",
"tests/ffi/function_varargs_generated_leaf_test.dart",
"tests/ffi/function_varargs_generated_native_leaf_test.dart",
"tests/ffi/function_varargs_generated_native_test.dart",
"tests/ffi/function_varargs_generated_test.dart",
"tests/ffi/function_varargs_name_test.dart",
"tests/ffi/function_varargs_test.dart",
"tests/ffi/function_very_many_test.dart",
"tests/ffi/hardfp_test.dart",
"tests/ffi/has_symbol_test.dart",
"tests/ffi/inline_array_multi_dimensional_test.dart",
"tests/ffi/inline_array_test.dart",
"tests/ffi/invoke_callback_after_suspension_test.dart",
"tests/ffi/isolate_local_function_callbacks_test.dart",
"tests/ffi/msan_test.dart",
"tests/ffi/native_assets/asset_absolute_test.dart",
"tests/ffi/native_assets/asset_executable_test.dart",
"tests/ffi/native_assets/asset_library_annotation_test.dart",
"tests/ffi/native_assets/asset_process_test.dart",
"tests/ffi/native_assets/asset_relative_test.dart",
"tests/ffi/native_assets/asset_system_test.dart",
"tests/ffi/native_assets/infer_native_assets_yaml_dart_kernel_snapshot_test.dart",
"tests/ffi/native_assets/infer_native_assets_yaml_isolate_spawnuri_2_test.dart",
"tests/ffi/native_assets/infer_native_assets_yaml_isolate_spawnuri_3_test.dart",
"tests/ffi/native_assets/infer_native_assets_yaml_isolate_spawnuri_test.dart",
"tests/ffi/native_assets/infer_native_assets_yaml_process_run_test.dart",
"tests/ffi/native_assets/process_test.dart",
"tests/ffi/native_callables_async_structs_by_value_generated_test.dart",
"tests/ffi/native_callables_sync_structs_by_value_generated_test.dart",
"tests/ffi/native_effect_test.dart",
"tests/ffi/negative_function_test.dart",
"tests/ffi/pointer_arithmetic_operators_test.dart",
"tests/ffi/regress_37254_test.dart",
"tests/ffi/regress_39044_test.dart",
"tests/ffi/regress_39063_test.dart",
"tests/ffi/regress_39885_test.dart",
"tests/ffi/regress_40537_test.dart",
"tests/ffi/regress_43016_test.dart",
"tests/ffi/regress_43693_test.dart",
"tests/ffi/regress_45189_test.dart",
"tests/ffi/regress_45198_test.dart",
"tests/ffi/regress_45507_test.dart",
"tests/ffi/regress_45988_test.dart",
"tests/ffi/regress_46004_test.dart",
"tests/ffi/regress_46127_test.dart",
"tests/ffi/regress_47594_test.dart",
"tests/ffi/regress_47673_test.dart",
"tests/ffi/regress_49402_test.dart",
"tests/ffi/regress_49684_test.dart",
"tests/ffi/regress_51315_test.dart",
"tests/ffi/regress_51321_test.dart",
"tests/ffi/regress_51504_test.dart",
"tests/ffi/regress_51538_2_test.dart",
"tests/ffi/regress_51538_3_test.dart",
"tests/ffi/regress_51538_test.dart",
"tests/ffi/regress_52298_test.dart",
"tests/ffi/regress_52399_test.dart",
"tests/ffi/regress_b_261224444_test.dart",
"tests/ffi/regress_flutter79441_test.dart",
"tests/ffi/regress_flutter97301_test.dart",
"tests/ffi/regress_jump_to_frame_test.dart",
"tests/ffi/sizeof_test.dart",
"tests/ffi/snapshot_test.dart",
"tests/ffi/stacktrace_regress_37910_test.dart",
"tests/ffi/structs_nested_test.dart",
"tests/ffi/structs_nnbd_workaround_test.dart",
"tests/ffi/structs_packed_test.dart",
"tests/ffi/structs_test.dart",
"tests/ffi/structs_typed_data_test.dart",
"tests/ffi/unaligned_test.dart",
"tests/ffi/variance_function_test.dart",
"tests/ffi/vmspecific_deprecated_funcs_test.dart",
"tests/ffi/vmspecific_dynamic_library_test.dart",
"tests/ffi/vmspecific_enable_ffi_test.dart",
"tests/ffi/vmspecific_ffi_native_handles_test.dart",
"tests/ffi/vmspecific_ffi_native_test.dart",
"tests/ffi/vmspecific_function_callbacks_exit_test.dart",
"tests/ffi/vmspecific_function_callbacks_test.dart",
"tests/ffi/vmspecific_function_gc_test.dart",
"tests/ffi/vmspecific_function_test.dart",
"tests/ffi/vmspecific_handle_dynamically_linked_test.dart",
"tests/ffi/vmspecific_handle_test.dart",
"tests/ffi/vmspecific_highmem_32bit_test.dart",
"tests/ffi/vmspecific_leaf_call_test.dart",
"tests/ffi/vmspecific_native_finalizer_2_test.dart",
"tests/ffi/vmspecific_native_finalizer_deeply_immutable_test.dart",
"tests/ffi/vmspecific_native_finalizer_isolate_groups_test.dart",
"tests/ffi/vmspecific_native_finalizer_isolates_test.dart",
"tests/ffi/vmspecific_native_finalizer_test.dart",
"tests/ffi/vmspecific_object_gc_test.dart",
"tests/ffi/vmspecific_pointer_load_il_test.dart",
"tests/ffi/vmspecific_regress_37100_test.dart",
"tests/ffi/vmspecific_regress_37511_callbacks_test.dart",
"tests/ffi/vmspecific_regress_37511_test.dart",
"tests/ffi/vmspecific_regress_37780_test.dart",
"tests/ffi/vmspecific_regress_51794_test.dart",
"tests/ffi/vmspecific_send_port_id_test.dart",
]
test_deps = []
test_resources = []
foreach(test_source, test_sources) {
label = string_replace(test_source, "/", "_")
application_snapshot(label) {
dart_snapshot_kind = "kernel"
main_dart = test_source
training_args = [] # Not used
output = "$target_gen_dir/$test_source.dill"
}
test_deps += [ ":$label" ]
test_resources += [
{
path = rebase_path("$target_gen_dir/$test_source.dill")
dest = "data/$test_source"
},
]
}
test_binaries = [
"dart",
"dart_precompiled_runtime",
"run_vm_tests",
]
foreach(binary, test_binaries) {
fuchsia_component("${binary}_test_component") {
testonly = true
manifest = "runtime/bin/${binary}_test_component.cml"
data_deps = [
"runtime/bin:${binary}",
"runtime/bin:ffi_test_dynamic_library",
"runtime/bin:ffi_test_functions",
]
library_files = [
"libffi_test_dynamic_library.so",
"libffi_test_functions.so",
]
resource_files = [
".dart_tool/package_config.json",
"tools/addlatexhash.dart",
]
resources = []
foreach(file, library_files) {
resources += [
{
path = root_out_dir + "/" + file
dest = "lib/" + file
},
]
}
foreach(file, resource_files) {
resources += [
{
path = file
dest = "data/" + file
},
]
}
deps = test_deps
resources += test_resources
}
}
fuchsia_package("fuchsia_test_package") {
testonly = true
if (is_debug) {
package_name = "dart_test_debug"
} else if (is_release) {
package_name = "dart_test_release"
} else if (is_product) {
package_name = "dart_test_product"
}
deps = []
foreach(binary, test_binaries) {
deps += [ ":${binary}_test_component" ]
}
}
}