blob: 3441c84132260d98faa10b57d4bc2284653dbd6d [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/compiled_action.gni")
_dart_root = get_path_info("..", "abspath")
declare_args() {
# Default to building app-jit snapshots. The simulator and cross builds
# override this to script snapshots to cut down on build time.
dart_snapshot_kind = "app-jit"
if (target_cpu != host_cpu) {
dart_snapshot_kind = "script"
}
}
template("application_snapshot") {
assert(defined(invoker.main_dart), "Must specify 'main_dart'")
assert(defined(invoker.training_args), "Must specify 'training_args'")
vm_args = []
if (defined(invoker.vm_args)) {
vm_args = invoker.vm_args
}
main_dart = invoker.main_dart
training_args = invoker.training_args
name = target_name
if (defined(invoker.name)) {
name = invoker.name
}
extra_deps = []
if (defined(invoker.deps)) {
extra_deps += invoker.deps
}
extra_inputs = [ main_dart ]
if (defined(invoker.inputs)) {
extra_inputs += invoker.inputs
}
if (defined(invoker.dot_packages)) {
dot_packages = invoker.dot_packages
} else {
dot_packages = rebase_path("$_dart_root/.packages")
}
output = "$root_gen_dir/$name.dart.snapshot"
if (defined(invoker.output)) {
output = invoker.output
}
compiled_action(target_name) {
tool = "$_dart_root/runtime/bin:dart"
deps = extra_deps
depfile = "$output.d"
main_file = rebase_path(main_dart)
inputs = extra_inputs + [ main_file ]
outputs = [
output,
]
abs_depfile = rebase_path(depfile)
abs_output = rebase_path(output, root_build_dir)
args = [
"--deterministic",
"--packages=$dot_packages",
"--snapshot=$abs_output",
"--snapshot-depfile=$abs_depfile",
] + vm_args
if (dart_snapshot_kind == "script") {
args += [
"--snapshot-kind=script",
main_file,
]
assert(training_args != "", "Ignoring unused argument")
} else if (dart_snapshot_kind == "app-jit") {
args += [
"--snapshot-kind=app-jit",
main_file,
] + training_args
} else {
assert(false, "Bad dart_snapshot_kind: $dart_snapshot_kind")
}
}
}