blob: 6ae3cd96b72bdcb11c3a7a7c1086a7240a197b87 [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_action.gni")
import("../../build/prebuilt_dart_sdk.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_dill = "$target_gen_dir/kernel/ddc_sdk.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_summary),
"--library-root",
rebase_path("../../pkg/dev_compiler"),
"-o",
"dartdevc.js",
"--unsafe-force-compile",
rebase_path("../../pkg/dev_compiler/bin/dartdevc.dart"),
]
deps = [
":dartdevc_sdk",
]
inputs = exec_script("../../tools/list_dart_files.py",
[
"absolute",
rebase_path("../../pkg/dev_compiler/bin"),
],
"list lines")
inputs += [ sdk_summary ]
}
application_snapshot("dartdevk") {
main_dart = "../../pkg/dev_compiler/bin/dartdevk.dart"
# TODO(vsm): Train this on real input.
training_args = [
"--dart-sdk-summary",
rebase_path(sdk_dill),
"-o",
"dartdevk.js",
rebase_path("../../pkg/dev_compiler/test/codegen/sunflower/sunflower.dart"),
]
deps = [
":dartdevc_sdk",
":dartdevc_sdk_kernel_summary",
]
inputs = exec_script("../../tools/list_dart_files.py",
[
"absolute",
rebase_path("../../pkg/dev_compiler/bin"),
],
"list lines")
inputs += [ sdk_dill ]
}
sdk_lib_files = exec_script("../../tools/list_dart_files.py",
[
"absolute",
rebase_path("../../sdk/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)
compiled_action(target_name) {
tool = "../../runtime/bin:dart"
deps = [
"../compiler:compile_dart2js_platform",
"../compiler:compile_dart2js_platform_strong",
]
inputs = sdk_lib_files + compiler_files + dev_compiler_files + [
"$root_out_dir/dart2js_platform.dill",
"$root_out_dir/dart2js_outline.dill",
"$root_out_dir/dart2js_platform_strong.dill",
"$root_out_dir/dart2js_outline_strong.dill",
]
outputs = [
out,
]
dot_packages = rebase_path("../../.packages")
compiler = rebase_path("../../pkg/compiler/lib/src/dart2js.dart")
args = [
"--packages=$dot_packages",
compiler,
"--packages=$dot_packages",
"$abs_main",
"-m",
"-o$abs_output",
]
}
}
dart2js_compile("dartdevc_web") {
main = rebase_path("../../pkg/dev_compiler/web/main.dart")
out = "$root_out_dir/dev_compiler/build/web/ddc_web_compiler.js"
}
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"
}
# Apply dev_compiler's patch files to create the Dart version of the dartdevc
# SDK.
dart_action("dartdevc_patch_sdk") {
# TODO(rnystrom): Unfork DDC's patch_sdk.dart script with the
# tools/patch_sdk.dart and then change this to use generate_patch_sdk().
deps = [
":dartdevc_files_stamp",
# The patch script uses several packages, including analyzer, so consider
# it dirty if any of those change.
"../../pkg:pkg_files_stamp",
]
script = "../../pkg/dev_compiler/tool/patch_sdk.dart"
# The main SDK library sources.
inputs = sdk_lib_files
# dev_compiler's additional sources and patch files.
inputs += exec_script("../../tools/list_dart_files.py",
[
"absolute",
rebase_path("../../pkg/dev_compiler/tool/input_sdk"),
],
"list lines")
# Arbitrarily use the version file as a token file to check against to see if
# the sources have changed.
# TODO(rnystrom): List the outputs more precisely?
outputs = [
"$patched_sdk_dir/version",
]
args = [
rebase_path("../../"),
rebase_path("../../pkg/dev_compiler/tool/input_sdk"),
rebase_path(patched_sdk_dir),
]
}
# Compiles the Dart core libraries and DDC runtime to an analyzer summary and
# JS.
dart_action("dartdevc_sdk") {
deps = [
":dartdevc_files_stamp",
":dartdevc_patch_sdk",
"../../pkg:pkg_files_stamp",
]
script = "../../pkg/dev_compiler/tool/build_sdk.dart"
inputs = [
"../../pkg/dev_compiler/tool/build_sdk.dart",
# Since the entire patched SDK is built in one step, if any file changes,
# they all will. Instead of listing them all as outputs of
# dartdevc_patch_sdk (which would require something like a depfile), just
# use version as the token file whose timestamp we track.
# TODO(rnystrom): Do something better?
"$patched_sdk_dir/version",
# If dev_compiler itself changes, it can affect the generated SDK.
"$target_gen_dir/dartdevc_files.stamp",
# Likewise, the packages dev_compiler depends on may affect its output.
"$root_gen_dir/pkg_files.stamp",
]
outputs = [
sdk_summary,
"$target_gen_dir/js/amd/dart_sdk.js",
"$target_gen_dir/js/amd/dart_sdk.js.map",
"$target_gen_dir/js/common/dart_sdk.js",
"$target_gen_dir/js/common/dart_sdk.js.map",
"$target_gen_dir/js/es6/dart_sdk.js",
"$target_gen_dir/js/es6/dart_sdk.js.map",
"$target_gen_dir/js/legacy/dart_sdk.js",
"$target_gen_dir/js/legacy/dart_sdk.js.map",
]
args = [
"--dart-sdk",
rebase_path(patched_sdk_dir),
"--dart-sdk-summary=build",
"--summary-out",
rebase_path(sdk_summary),
"--source-map",
"--source-map-comment",
"--modules=amd",
"-o",
rebase_path("$target_gen_dir/js/amd/dart_sdk.js"),
"--modules=es6",
"-o",
rebase_path("$target_gen_dir/js/es6/dart_sdk.js"),
"--modules=common",
"-o",
rebase_path("$target_gen_dir/js/common/dart_sdk.js"),
"--modules=legacy",
"-o",
rebase_path("$target_gen_dir/js/legacy/dart_sdk.js"),
]
}
# Builds everything needed to run dartdevc and dartdevk tests using test.dart.
group("dartdevc_test") {
deps = [
":dartdevc",
":dartdevc_sdk",
":dartdevc_sdk_kernel_summary",
":dartdevc_test_pkg",
":dartdevk",
"../../sdk:create_sdk",
]
}
create_timestamp_file("dartdevc_files_stamp") {
path = rebase_path("../../pkg/dev_compiler/lib")
output = "$target_gen_dir/dartdevc_files.stamp"
}
# Compiles the packages used by the tests to JS with dartdevc so that they are
# available for loading by the tests.
compiled_action("dartdevc_test_pkg") {
tool = "../../runtime/bin:dart"
deps = [
":dartdevc_files_stamp",
":dartdevc_sdk",
":dartdevc_sdk_kernel_summary",
"../../pkg:pkg_files_stamp",
]
inputs = [
sdk_dill,
sdk_summary,
"$target_gen_dir/dartdevc_files.stamp",
"$root_gen_dir/pkg_files.stamp",
]
outputs = [
"$target_gen_dir/pkg/async_helper.dill",
"$target_gen_dir/pkg/async_helper.js",
"$target_gen_dir/pkg/async_helper.sum",
"$target_gen_dir/pkg/collection.dill",
"$target_gen_dir/pkg/collection.js",
"$target_gen_dir/pkg/collection.sum",
"$target_gen_dir/pkg/expect.dill",
"$target_gen_dir/pkg/expect.js",
"$target_gen_dir/pkg/expect.sum",
"$target_gen_dir/pkg/js.dill",
"$target_gen_dir/pkg/js.js",
"$target_gen_dir/pkg/js.sum",
"$target_gen_dir/pkg/matcher.dill",
"$target_gen_dir/pkg/matcher.js",
"$target_gen_dir/pkg/matcher.sum",
"$target_gen_dir/pkg/meta.dill",
"$target_gen_dir/pkg/meta.js",
"$target_gen_dir/pkg/meta.sum",
"$target_gen_dir/pkg/path.dill",
"$target_gen_dir/pkg/path.js",
"$target_gen_dir/pkg/path.sum",
"$target_gen_dir/pkg/stack_trace.dill",
"$target_gen_dir/pkg/stack_trace.js",
"$target_gen_dir/pkg/stack_trace.sum",
# TODO(rnystrom): Remove this when unittest is no longer used. Also remove
# any of the above packages that are only here because unittest uses them.
"$target_gen_dir/pkg/unittest.dill",
"$target_gen_dir/pkg/unittest.js",
"$target_gen_dir/pkg/unittest.sum",
]
args = [
rebase_path("../../pkg/dev_compiler/tool/build_pkgs.dart"),
"--analyzer-sdk",
rebase_path(sdk_summary),
"--kernel-sdk",
rebase_path(sdk_dill),
"--output",
rebase_path("$target_gen_dir"),
]
}
# Compiles the DDC SDK's kernel summary and JS code.
compiled_action("dartdevc_sdk_kernel_summary") {
tool = "../../runtime/bin:dart"
deps = [
":dartdevc_files_stamp",
]
inputs = [
"$target_gen_dir/dartdevc_files.stamp",
]
outputs = [
sdk_dill,
"$target_gen_dir/kernel/amd/dart_sdk.js",
"$target_gen_dir/kernel/amd/dart_sdk.js.map",
"$target_gen_dir/kernel/common/dart_sdk.js",
"$target_gen_dir/kernel/common/dart_sdk.js.map",
"$target_gen_dir/kernel/es6/dart_sdk.js",
"$target_gen_dir/kernel/es6/dart_sdk.js.map",
"$target_gen_dir/kernel/legacy/dart_sdk.js",
"$target_gen_dir/kernel/legacy/dart_sdk.js.map",
]
args = [
rebase_path("../../pkg/dev_compiler/tool/kernel_sdk.dart"),
rebase_path(sdk_dill),
]
}