blob: 9b9f07ce491f3f90f3f90f1666b2529941d3190a [file] [log] [blame]
# 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/dart/dart_action.gni")
import("../../sdk_args.gni")
import("../../utils/compile_platform.gni")
import("../application_snapshot.gni")
import("../create_timestamp.gni")
patched_sdk_dir = "$target_gen_dir/patched_sdk"
sdk_summary = "$target_gen_dir/ddc_sdk.sum"
sdk_outline_dill = "$root_out_dir/ddc_outline.dill"
sdk_full_dill = "$root_out_dir/ddc_platform.dill"
sdk_outline_sound_dill = "$root_out_dir/ddc_outline_sound.dill"
sdk_full_sound_dill = "$root_out_dir/ddc_platform_sound.dill"
application_snapshot("dartdevc") {
main_dart = "../../pkg/dev_compiler/bin/dartdevc.dart"
training_args = [
"--dart-sdk",
rebase_path("../../sdk"),
"--dart-sdk-summary",
rebase_path(sdk_outline_dill),
"-k",
"-o",
"dartdevc.js",
rebase_path("../../pkg/dev_compiler/bin/dartdevc.dart"),
]
deps = [
":dartdevc_kernel_sdk",
":dartdevc_platform",
]
inputs = [ sdk_outline_dill ]
}
sdk_root = "../../sdk"
sdk_lib_files = exec_script("../../tools/list_dart_files.py",
[
"absolute",
rebase_path("$sdk_root/lib"),
],
"list lines")
compiler_files = exec_script("../../tools/list_dart_files.py",
[
"absolute",
rebase_path("../../pkg/compiler"),
],
"list lines")
dev_compiler_files = exec_script("../../tools/list_dart_files.py",
[
"absolute",
rebase_path("../../pkg/dev_compiler"),
],
"list lines")
template("dart2js_compile") {
assert(defined(invoker.main), "Must specify the main file")
main = invoker.main
assert(defined(invoker.out), "Must specify the out file")
out = invoker.out
abs_main = rebase_path(main)
abs_output = rebase_path(out)
prebuilt_dart_action(target_name) {
deps = [ "../compiler:compile_dart2js_platform" ]
inputs = sdk_lib_files + compiler_files + dev_compiler_files + [
"$root_out_dir/dart2js_platform.dill",
"$root_out_dir/dart2js_outline.dill",
]
outputs = [ out ]
script = "../../pkg/compiler/lib/src/dart2js.dart"
packages = "../../.packages"
vm_args = [ "-Dsdk_hash=$sdk_hash" ]
args = [
"$abs_main",
"-m",
"-o$abs_output",
"--no-source-maps",
"--platform-binaries=" + rebase_path("$root_out_dir"),
]
}
}
dart2js_compile("stack_trace_mapper") {
main = rebase_path("../../pkg/dev_compiler/web/stack_trace_mapper.dart")
out = "$root_out_dir/dev_compiler/build/web/dart_stack_trace_mapper.js"
}
# Builds everything needed to run dartdevc tests using test.dart.
group("dartdevc_test") {
deps = [
":dartdevc",
":dartdevc_kernel_sdk",
":dartdevc_sound_sdk",
":dartdevc_test_kernel_pkg",
"../..:create_sdk",
]
}
# Builds everything needed to run dartdevc tests locally using test.dart without
# --use-sdk. This is the same as dartdevc_test, but skips things rely on
# building the Dart VM and create_sdk.
group("dartdevc_test_local") {
deps = [
":dartdevc_kernel_sdk",
":dartdevc_test_kernel_pkg",
]
}
create_timestamp_file("dartdevc_files_stamp") {
path = rebase_path("../../pkg/dev_compiler/lib")
output = "$target_gen_dir/dartdevc_files.stamp"
}
create_timestamp_file("dartdevc_sdk_patch_stamp") {
path = rebase_path("$sdk_root/lib/_internal/js_dev_runtime")
output = "$target_gen_dir/dartdevc_sdk_patch_stamp.stamp"
}
# Compiles to JavaScript any package used from tests.
# TODO(sigmund): generate a js bundle or a module that load these indirectly so
# we can stop referring to this list of packages explicitly in the test_runner.
group("dartdevc_test_kernel_pkg") {
deps = [
":async_helper_js",
":async_helper_sound_js",
":expect_js",
":expect_sound_js",
":js_js",
":js_sound_js",
":meta_js",
":meta_sound_js",
]
}
template("dartdevc_kernel_compile") {
assert(defined(invoker.package),
"Need 'package' in $target_name (the name of the package)")
assert(defined(invoker.sound_null_safety),
"Need 'sound_null_safety' in $target_name.")
if (invoker.sound_null_safety) {
platform_dep = ":dartdevc_platform_sound"
sdk_outline = sdk_outline_sound_dill
js_gen_dir = "$target_gen_dir/pkg_sound"
} else {
platform_dep = ":dartdevc_platform"
sdk_outline = sdk_outline_dill
js_gen_dir = "$target_gen_dir/pkg_kernel"
}
# Other optional invoker parameters:
# * extra_libraries: entrypoints to include in the module as
# "package:package_name/library_name.dart" (the rule implicitly adds
# the default import "package:package_name/package_name.dart").
# * package_dependencies: the name of other packages this package depends
# on. When providing `name`, a separate `dartdevc_kernel_compile` target
# named `${name}_js` must exist.
# * args: additional args to pass to dartdevc
prebuilt_dart_action(target_name) {
script = "../../pkg/dev_compiler/bin/dartdevc.dart"
module = invoker.package
out_dir = rebase_path("$js_gen_dir")
sdk_path = rebase_path(sdk_outline)
deps = [
":dartdevc_files_stamp",
platform_dep,
# TODO(sigmund): depend only on the compiler and the actual files in the
# package
"../../pkg:pkg_files_stamp",
]
inputs = [
sdk_outline,
"$target_gen_dir/dartdevc_files.stamp",
"$root_gen_dir/pkg_files.stamp",
]
outputs = [
"$js_gen_dir/$module.dill",
"$js_gen_dir/$module.js",
]
vm_args = [ "-Dsdk_hash=$sdk_hash" ]
args = [
"-k",
"--dart-sdk-summary=$sdk_path",
"-o$out_dir/$module.js",
"package:$module/$module.dart",
]
if (defined(invoker.extra_libraries)) {
foreach(lib, invoker.extra_libraries) {
args += [ "package:$module/$lib.dart" ]
}
}
if (defined(invoker.package_dependencies)) {
foreach(dep, invoker.package_dependencies) {
deps += [ ":${dep}_js" ]
args += [ "-s$out_dir/$dep.dill" ]
}
}
if (defined(invoker.args)) {
args += invoker.args
}
if (invoker.sound_null_safety) {
args += [ "--sound-null-safety" ]
}
}
}
dartdevc_kernel_compile("async_helper_js") {
package = "async_helper"
sound_null_safety = false
}
dartdevc_kernel_compile("async_helper_sound_js") {
package = "async_helper"
sound_null_safety = true
}
dartdevc_kernel_compile("expect_js") {
package = "expect"
extra_libraries = [ "minitest" ]
sound_null_safety = false
}
dartdevc_kernel_compile("expect_sound_js") {
package = "expect"
extra_libraries = [ "minitest" ]
sound_null_safety = true
}
dartdevc_kernel_compile("js_js") {
package = "js"
extra_libraries = [ "js_util" ]
sound_null_safety = false
}
dartdevc_kernel_compile("js_sound_js") {
package = "js"
extra_libraries = [ "js_util" ]
sound_null_safety = true
}
dartdevc_kernel_compile("meta_js") {
package = "meta"
sound_null_safety = false
}
dartdevc_kernel_compile("meta_sound_js") {
package = "meta"
sound_null_safety = true
}
template("compile_dartdevc_platform") {
assert(defined(invoker.sound_null_safety),
"Need 'sound_null_safety' in $target_name.")
compile_platform(target_name) {
single_root_scheme = "org-dartlang-sdk"
single_root_base = rebase_path("$sdk_root/")
libraries_specification_uri = "org-dartlang-sdk:///lib/libraries.json"
args = [
"--target=dartdevc",
"dart:core",
]
if (invoker.sound_null_safety) {
args += [ "--nnbd-strong" ]
outputs = [
sdk_full_sound_dill,
sdk_outline_sound_dill,
]
} else {
outputs = [
sdk_full_dill,
sdk_outline_dill,
]
}
}
}
compile_dartdevc_platform("dartdevc_platform") {
sound_null_safety = false
}
compile_dartdevc_platform("dartdevc_platform_sound") {
sound_null_safety = true
}
# Compiles the DDC SDK's JS code from the platform .dill.
template("dartdevc_sdk_js") {
assert(defined(invoker.sound_null_safety),
"Need 'sound_null_safety' in $target_name.")
if (invoker.sound_null_safety) {
platform_dep = ":dartdevc_platform_sound"
platform_input = sdk_full_sound_dill
js_gen_dir = "$target_gen_dir/sound"
} else {
platform_dep = ":dartdevc_platform"
platform_input = sdk_full_dill
js_gen_dir = "$target_gen_dir/kernel"
}
prebuilt_dart_action(target_name) {
deps = [
":dartdevc_files_stamp",
"../../pkg:pkg_files_stamp",
platform_dep,
]
inputs = [
"$target_gen_dir/dartdevc_files.stamp",
"$root_gen_dir/pkg_files.stamp",
platform_input,
]
outputs = [
"$js_gen_dir/amd/dart_sdk.js",
"$js_gen_dir/amd/dart_sdk.js.map",
"$js_gen_dir/common/dart_sdk.js",
"$js_gen_dir/common/dart_sdk.js.map",
"$js_gen_dir/es6/dart_sdk.js",
"$js_gen_dir/es6/dart_sdk.js.map",
"$js_gen_dir/legacy/dart_sdk.js",
"$js_gen_dir/legacy/dart_sdk.js.map",
]
vm_args = [ "-Dsdk_hash=$sdk_hash" ]
script = "../../pkg/dev_compiler/bin/dartdevc.dart"
args = [
"--multi-root-scheme",
"org-dartlang-sdk",
"--multi-root-output-path",
rebase_path("$target_gen_dir/../../"),
"--modules",
"amd",
"-o",
rebase_path("$js_gen_dir/amd/dart_sdk.js"),
"--modules",
"common",
"-o",
rebase_path("$js_gen_dir/common/dart_sdk.js"),
"--modules",
"es6",
"-o",
rebase_path("$js_gen_dir/es6/dart_sdk.js"),
"--modules",
"legacy",
"-o",
rebase_path("$js_gen_dir/legacy/dart_sdk.js"),
rebase_path("$platform_input"),
]
if (invoker.sound_null_safety) {
args += [ "--sound-null-safety" ]
}
}
}
dartdevc_sdk_js("dartdevc_kernel_sdk") {
sound_null_safety = false
}
dartdevc_sdk_js("dartdevc_sound_sdk") {
sound_null_safety = true
}