Allow configuring the destination of the SDK in the build output directory

This is needed for the Flutter Engine to use a prebuilt Dart SDK as in
https://github.com/flutter/engine/pull/26931. When using a prebuilt
Dart SDK, the rules producing the built SDK are directed to a
different location so that GN doesn't warn about multiple rules that
produce the same file.

TEST=locally with a flutter/engine checkout
Change-Id: I4095f379c772c63f93a1c88c7f4e44804f3a6fc7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204760
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
This commit is contained in:
Zach Anderson 2021-06-29 18:45:29 +00:00 committed by commit-bot@chromium.org
parent 1ce169d940
commit 46189bcb19
4 changed files with 57 additions and 41 deletions

View file

@ -2,6 +2,8 @@
# 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("../../sdk_args.gni")
# This rule copies header files to include/
copy("copy_headers") {
visibility = [ "../../sdk:copy_headers" ]
@ -16,5 +18,6 @@ copy("copy_headers") {
"internal/dart_api_dl_impl.h",
]
outputs = [ "$root_out_dir/dart-sdk/include/{{source_target_relative}}" ]
outputs =
[ "$root_out_dir/$dart_sdk_output/include/{{source_target_relative}}" ]
}

View file

@ -235,7 +235,7 @@ copy_tree_specs += [
target = "copy_dartdoc_templates"
visibility = [ ":copy_dartdoc_files" ]
source = "../third_party/pkg/dartdoc/lib/templates"
dest = "$root_out_dir/dart-sdk/bin/resources/dartdoc/templates"
dest = "$root_out_dir/$dart_sdk_output/bin/resources/dartdoc/templates"
ignore_patterns = "{}"
},
]
@ -247,7 +247,7 @@ copy_tree_specs += [
target = "copy_dartdoc_resources"
visibility = [ ":copy_dartdoc_files" ]
source = "../third_party/pkg/dartdoc/lib/resources"
dest = "$root_out_dir/dart-sdk/bin/resources/dartdoc/resources"
dest = "$root_out_dir/$dart_sdk_output/bin/resources/dartdoc/resources"
ignore_patterns = "{}"
},
]
@ -259,7 +259,7 @@ copy_tree_specs += [
target = "copy_prebuilt_devtools"
visibility = [ ":create_common_sdk" ]
source = "../third_party/devtools/web"
dest = "$root_out_dir/dart-sdk/bin/resources/devtools"
dest = "$root_out_dir/$dart_sdk_output/bin/resources/devtools"
ignore_patterns = "{}"
},
]
@ -274,7 +274,7 @@ foreach(library, _full_sdk_libraries) {
":copy_full_sdk_libraries",
]
source = "lib/$library"
dest = "$root_out_dir/dart-sdk/lib/$library"
dest = "$root_out_dir/$dart_sdk_output/lib/$library"
ignore_patterns = "*.svn,doc,*.py,*.gypi,*.sh,.gitignore"
},
]
@ -306,7 +306,7 @@ if (target_os != current_os && target_os == "fuchsia") {
deps = [ dart_label ]
dart_out = get_label_info(dart_label, "root_out_dir")
sources = [ "$dart_out/$dart_stripped_binary" ]
outputs = [ "$root_out_dir/dart-sdk/bin/$dart_stripped_binary" ]
outputs = [ "$root_out_dir/$dart_sdk_output/bin/$dart_stripped_binary" ]
script = "/bin/ln"
args = [
"-snf",
@ -323,7 +323,7 @@ if (target_os != current_os && target_os == "fuchsia") {
if (is_win && dart_lib_export_symbols) {
sources += [ "$dart_out/dart.lib" ]
}
outputs = [ "$root_out_dir/dart-sdk/bin/{{source_file_part}}" ]
outputs = [ "$root_out_dir/$dart_sdk_output/bin/{{source_file_part}}" ]
}
}
@ -335,7 +335,9 @@ copy("copy_dartaotruntime") {
sources = [
"$src_dir/${dart_precompiled_runtime_stripped_binary}${executable_suffix}",
]
outputs = [ "$root_out_dir/dart-sdk/bin/dartaotruntime${executable_suffix}" ]
outputs = [
"$root_out_dir/$dart_sdk_output/bin/dartaotruntime${executable_suffix}",
]
}
copy("copy_gen_snapshot") {
@ -344,8 +346,9 @@ copy("copy_gen_snapshot") {
src_dir =
get_label_info("../runtime/bin:gen_snapshot_product", "root_out_dir")
sources = [ "$src_dir/${gen_snapshot_stripped_binary}${executable_suffix}" ]
outputs =
[ "$root_out_dir/dart-sdk/bin/utils/gen_snapshot${executable_suffix}" ]
outputs = [
"$root_out_dir/$dart_sdk_output/bin/utils/gen_snapshot${executable_suffix}",
]
}
copy("copy_vm_platform_strong_product") {
@ -353,7 +356,8 @@ copy("copy_vm_platform_strong_product") {
deps = [ "../runtime/vm:vm_platform_product" ]
src_dir = get_label_info("../runtime/vm:vm_platform_product", "root_out_dir")
sources = [ "$src_dir/vm_platform_strong_product.dill" ]
outputs = [ "$root_out_dir/dart-sdk/lib/_internal/{{source_file_part}}" ]
outputs =
[ "$root_out_dir/$dart_sdk_output/lib/_internal/{{source_file_part}}" ]
}
copy("copy_dart2native") {
@ -368,14 +372,15 @@ copy("copy_dart2native") {
ext = ".bat"
}
sources = [ "bin/dart2native$ext" ]
outputs = [ "$root_out_dir/dart-sdk/bin/{{source_file_part}}" ]
outputs = [ "$root_out_dir/$dart_sdk_output/bin/{{source_file_part}}" ]
}
copy("copy_gen_kernel_snapshot") {
visibility = [ ":copy_dart2native" ]
deps = [ "../utils/gen_kernel" ]
sources = [ "$root_gen_dir/gen_kernel.dart.snapshot" ]
outputs = [ "$root_out_dir/dart-sdk/bin/snapshots/{{source_file_part}}" ]
outputs =
[ "$root_out_dir/$dart_sdk_output/bin/snapshots/{{source_file_part}}" ]
}
# A template for copying the things in _platform_sdk_scripts and
@ -393,7 +398,7 @@ template("copy_sdk_script") {
":copy_full_sdk_scripts",
]
sources = [ "bin/${name}_sdk$ext" ]
outputs = [ "$root_out_dir/dart-sdk/bin/$name$ext" ]
outputs = [ "$root_out_dir/$dart_sdk_output/bin/$name$ext" ]
}
}
@ -414,7 +419,7 @@ foreach(script, _scripts) {
ext = ".bat"
}
sources = [ "bin/$script$ext" ]
outputs = [ "$root_out_dir/dart-sdk/bin/{{source_file_part}}" ]
outputs = [ "$root_out_dir/$dart_sdk_output/bin/{{source_file_part}}" ]
}
}
@ -458,7 +463,8 @@ foreach(snapshot, _full_sdk_snapshots) {
]
deps = [ snapshot[1] ]
sources = [ "$root/${snapshot[0]}.dart.snapshot" ]
outputs = [ "$root_out_dir/dart-sdk/bin/snapshots/{{source_file_part}}" ]
outputs =
[ "$root_out_dir/$dart_sdk_output/bin/snapshots/{{source_file_part}}" ]
}
}
@ -483,7 +489,7 @@ group("copy_full_sdk_snapshots") {
}
# This rule writes the .packages file for dartdoc resources.
write_file("$root_out_dir/dart-sdk/bin/resources/dartdoc/.packages",
write_file("$root_out_dir/$dart_sdk_output/bin/resources/dartdoc/.packages",
"dartdoc:.")
# This is the main rule for copying the files that dartdoc needs.
@ -503,7 +509,8 @@ copy("copy_analysis_summaries") {
"../utils/dartanalyzer:generate_summary_strong",
]
sources = [ "$root_gen_dir/strong.sum" ]
outputs = [ "$root_out_dir/dart-sdk/lib/_internal/{{source_file_part}}" ]
outputs =
[ "$root_out_dir/$dart_sdk_output/lib/_internal/{{source_file_part}}" ]
}
# This rule copies dill files to lib/_internal.
@ -514,7 +521,8 @@ copy("copy_vm_dill_files") {
"../runtime/vm:kernel_platform_files",
]
sources = [ "$root_out_dir/vm_platform_strong.dill" ]
outputs = [ "$root_out_dir/dart-sdk/lib/_internal/{{source_file_part}}" ]
outputs =
[ "$root_out_dir/$dart_sdk_output/lib/_internal/{{source_file_part}}" ]
}
copy("copy_dartdev_dill_files") {
@ -524,7 +532,8 @@ copy("copy_dartdev_dill_files") {
"../utils/dartdev:dartdev",
]
sources = [ "$root_out_dir/dartdev.dill" ]
outputs = [ "$root_out_dir/dart-sdk/bin/snapshots/{{source_file_part}}" ]
outputs =
[ "$root_out_dir/$dart_sdk_output/bin/snapshots/{{source_file_part}}" ]
}
copy("copy_dart2js_dill_files") {
@ -542,7 +551,8 @@ copy("copy_dart2js_dill_files") {
"$root_out_dir/dart2js_server_nnbd_strong_platform.dill",
"$root_out_dir/dart2js_server_platform.dill",
]
outputs = [ "$root_out_dir/dart-sdk/lib/_internal/{{source_file_part}}" ]
outputs =
[ "$root_out_dir/$dart_sdk_output/lib/_internal/{{source_file_part}}" ]
}
# Copies DDC's SDK weak outline .dill to lib/_internal
@ -555,7 +565,7 @@ copy("copy_dev_compiler_weak_outline") {
"../utils/dartdevc:dartdevc_platform",
]
sources = [ "$root_out_dir/ddc_outline.dill" ]
outputs = [ "$root_out_dir/dart-sdk/lib/_internal/ddc_sdk.dill" ]
outputs = [ "$root_out_dir/$dart_sdk_output/lib/_internal/ddc_sdk.dill" ]
}
# Copies DDC's SDK full and outline .dill files to lib/_internal.
@ -571,7 +581,8 @@ copy("copy_dev_compiler_dills") {
"$root_out_dir/ddc_platform.dill",
"$root_out_dir/ddc_platform_sound.dill",
]
outputs = [ "$root_out_dir/dart-sdk/lib/_internal/{{source_file_part}}" ]
outputs =
[ "$root_out_dir/$dart_sdk_output/lib/_internal/{{source_file_part}}" ]
}
# This rule copies DDK's JS SDK and require.js to lib/dev_compiler/kernel/amd.
@ -585,9 +596,7 @@ copy("copy_dev_compiler_js_amd_kernel") {
"$gen_dir/kernel/amd/dart_sdk.js.map",
"../third_party/requirejs/require.js",
]
outputs = [
"$root_out_dir/dart-sdk/lib/dev_compiler/kernel/amd/{{source_file_part}}",
]
outputs = [ "$root_out_dir/$dart_sdk_output/lib/dev_compiler/kernel/amd/{{source_file_part}}" ]
}
# This rule copies DDK's JS SDK to lib/dev_compiler/kernel/common.
@ -601,7 +610,7 @@ copy("copy_dev_compiler_js_common_kernel") {
"$gen_dir/kernel/common/dart_sdk.js.map",
"../pkg/dev_compiler/lib/js/common/run.js",
]
outputs = [ "$root_out_dir/dart-sdk/lib/dev_compiler/kernel/common/{{source_file_part}}" ]
outputs = [ "$root_out_dir/$dart_sdk_output/lib/dev_compiler/kernel/common/{{source_file_part}}" ]
}
# This rule copies DDK's JS SDK to lib/dev_compiler/kernel/es6.
@ -614,9 +623,7 @@ copy("copy_dev_compiler_js_es6_kernel") {
"$gen_dir/kernel/es6/dart_sdk.js",
"$gen_dir/kernel/es6/dart_sdk.js.map",
]
outputs = [
"$root_out_dir/dart-sdk/lib/dev_compiler/kernel/es6/{{source_file_part}}",
]
outputs = [ "$root_out_dir/$dart_sdk_output/lib/dev_compiler/kernel/es6/{{source_file_part}}" ]
}
# Copies all of the JS artifacts needed by DDC.
@ -642,8 +649,9 @@ copy("copy_dev_compiler_tools") {
dart_out =
get_label_info("../utils/dartdevc:stack_trace_mapper", "root_out_dir")
sources = [ "$dart_out/dev_compiler/build/web/dart_stack_trace_mapper.js" ]
outputs =
[ "$root_out_dir/dart-sdk/lib/dev_compiler/web/{{source_file_part}}" ]
outputs = [
"$root_out_dir/$dart_sdk_output/lib/dev_compiler/web/{{source_file_part}}",
]
}
# This is the main rule for copying ddc's dependencies to lib/
@ -669,7 +677,7 @@ copy("copy_libraries_specification") {
visibility = [ ":create_common_sdk" ]
sources = [ "lib/libraries.json" ]
deps = [ ":copy_libraries" ]
outputs = [ "$root_out_dir/dart-sdk/lib/{{source_file_part}}" ]
outputs = [ "$root_out_dir/$dart_sdk_output/lib/{{source_file_part}}" ]
}
# This is the main rule to copy libraries in _platform_sdk_libraries to lib/
@ -714,7 +722,7 @@ action("write_version_file") {
"../tools/VERSION",
"$default_git_folder/logs/HEAD",
]
output = "$root_out_dir/dart-sdk/version"
output = "$root_out_dir/$dart_sdk_output/version"
outputs = [ output ]
script = "../tools/write_version_file.py"
args = [
@ -727,7 +735,7 @@ action("write_version_file") {
action("write_revision_file") {
visibility = [ ":create_common_sdk" ]
inputs = [ "$default_git_folder/logs/HEAD" ]
output = "$root_out_dir/dart-sdk/revision"
output = "$root_out_dir/$dart_sdk_output/revision"
outputs = [ output ]
script = "../tools/write_revision_file.py"
args = [
@ -747,28 +755,29 @@ copy("copy_libraries_dart") {
visibility = [ ":create_common_sdk" ]
deps = [ ":copy_libraries" ]
sources = [ "lib/_internal/sdk_library_metadata/lib/libraries.dart" ]
outputs = [ "$root_out_dir/dart-sdk/lib/_internal/{{source_file_part}}" ]
outputs =
[ "$root_out_dir/$dart_sdk_output/lib/_internal/{{source_file_part}}" ]
}
# This rule copies the README file.
copy("copy_readme") {
visibility = [ ":create_common_sdk" ]
sources = [ "../README.dart-sdk" ]
outputs = [ "$root_out_dir/dart-sdk/README" ]
outputs = [ "$root_out_dir/$dart_sdk_output/README" ]
}
# This rule copies the LICENSE file.
copy("copy_license") {
visibility = [ ":create_common_sdk" ]
sources = [ "../LICENSE" ]
outputs = [ "$root_out_dir/dart-sdk/LICENSE" ]
outputs = [ "$root_out_dir/$dart_sdk_output/LICENSE" ]
}
# This rule generates a custom dartdoc_options.yaml file.
action("write_dartdoc_options") {
visibility = [ ":create_common_sdk" ]
inputs = [ "$default_git_folder/logs/HEAD" ]
output = "$root_out_dir/dart-sdk/dartdoc_options.yaml"
output = "$root_out_dir/$dart_sdk_output/dartdoc_options.yaml"
outputs = [ output ]
script = "../tools/write_dartdoc_options_file.py"
args = [
@ -781,7 +790,7 @@ action("write_dartdoc_options") {
copy("copy_api_readme") {
visibility = [ ":create_common_sdk" ]
sources = [ "api_readme.md" ]
outputs = [ "$root_out_dir/dart-sdk/lib/api_readme.md" ]
outputs = [ "$root_out_dir/$dart_sdk_output/lib/api_readme.md" ]
}
# Parts common to both platform and full SDKs.

View file

@ -29,6 +29,9 @@ declare_args() {
# Whether to enable the SDK hash check that will prevent loading a kernel
# into a VM which was built with a different SDK.
verify_sdk_hash = true
# The location in the build output directory of the built Dart SDK.
dart_sdk_output = "dart-sdk"
}
# The SDK hash to build into VM and kernels.

View file

@ -3,6 +3,7 @@
# BSD-style license that can be found in the LICENSE file.
import("../../build/dart/dart_action.gni")
import("../../sdk_args.gni")
import("../application_snapshot.gni")
import("../create_timestamp.gni")
@ -46,6 +47,6 @@ prebuilt_dart_action("generate_summary_strong") {
args = [
"build",
rebase_path(output),
rebase_path("$root_out_dir/dart-sdk"),
rebase_path("$root_out_dir/$dart_sdk_output"),
]
}