OLD | NEW |
1 # Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import("../build/compiled_action.gni") | 5 import("../build/compiled_action.gni") |
6 | 6 |
7 _dart_root = get_path_info("..", "abspath") | 7 _dart_root = get_path_info("..", "abspath") |
8 | 8 |
9 declare_args() { | 9 declare_args() { |
10 # Default to building app-jit snapshots. The simulator and cross builds | 10 # Default to building app-jit snapshots. The simulator and cross builds |
11 # override this to script snapshots to cut down on build time. | 11 # override this to script snapshots to cut down on build time. |
12 dart_snapshot_kind = "app-jit" | 12 dart_snapshot_kind = "app-jit" |
13 if (target_cpu != host_cpu) { | |
14 dart_snapshot_kind = "script" | |
15 } | |
16 } | 13 } |
17 | 14 |
18 template("application_snapshot") { | 15 template("application_snapshot") { |
19 assert(defined(invoker.main_dart), "Must specify 'main_dart'") | 16 assert(defined(invoker.main_dart), "Must specify 'main_dart'") |
20 assert(defined(invoker.training_args), "Must specify 'training_args'") | 17 assert(defined(invoker.training_args), "Must specify 'training_args'") |
21 main_dart = invoker.main_dart | 18 main_dart = invoker.main_dart |
22 training_args = invoker.training_args | 19 training_args = invoker.training_args |
23 name = target_name | 20 name = target_name |
24 if (defined(invoker.name)) { | 21 if (defined(invoker.name)) { |
25 name = invoker.name | 22 name = invoker.name |
26 } | 23 } |
27 extra_deps = [] | 24 extra_deps = [] |
28 if (defined(invoker.deps)) { | 25 if (defined(invoker.deps)) { |
29 extra_deps += invoker.deps | 26 extra_deps += invoker.deps |
30 } | 27 } |
31 extra_inputs = [ main_dart ] | 28 extra_inputs = [main_dart] |
32 if (defined(invoker.inputs)) { | 29 if (defined(invoker.inputs)) { |
33 extra_inputs += invoker.inputs | 30 extra_inputs += invoker.inputs |
34 } | 31 } |
35 compiled_action(target_name) { | 32 compiled_action(target_name) { |
36 tool = "$_dart_root/runtime/bin:dart" | 33 tool = "$_dart_root/runtime/bin:dart" |
37 deps = extra_deps + [ "$_dart_root/pkg:pkg_files_stamp" ] | 34 deps = extra_deps + [ "$_dart_root/pkg:pkg_files_stamp" ] |
38 | 35 |
39 inputs = extra_inputs + [ | 36 inputs = extra_inputs + [ |
40 "$_dart_root/sdk/lib/_internal/sdk_library_metadata/lib/libraries
.dart", | 37 "$_dart_root/sdk/lib/_internal/sdk_library_metadata/lib/libraries
.dart", |
41 "$root_gen_dir/pkg_files.stamp", | 38 "$root_gen_dir/pkg_files.stamp", |
42 ] | 39 ] |
43 | 40 |
44 output = "$root_gen_dir/$name.dart.snapshot" | 41 output = "$root_gen_dir/$name.dart.snapshot" |
45 outputs = [ | 42 outputs = [ |
46 output, | 43 output, |
47 ] | 44 ] |
48 | 45 |
49 dot_packages = rebase_path("$_dart_root/.packages") | 46 dot_packages = rebase_path("$_dart_root/.packages") |
50 abs_output = rebase_path(output) | 47 abs_output = rebase_path(output) |
51 main_file = rebase_path(main_dart) | 48 main_file = rebase_path(main_dart) |
52 | 49 |
53 args = [ | 50 args = [ "--packages=$dot_packages", |
54 "--packages=$dot_packages", | 51 "--snapshot=$abs_output" ] |
55 "--snapshot=$abs_output", | |
56 ] | |
57 | 52 |
58 if (dart_snapshot_kind == "script") { | 53 if (dart_snapshot_kind == "script") { |
59 args += [ | 54 args += ["--snapshot-kind=script", |
60 "--snapshot-kind=script", | 55 main_file ] |
61 main_file, | |
62 ] | |
63 assert(training_args != "", "Ignoring unused argument") | 56 assert(training_args != "", "Ignoring unused argument") |
64 } else if (dart_snapshot_kind == "app-jit") { | 57 } else if (dart_snapshot_kind == "app-jit") { |
65 args += [ | 58 args += ["--snapshot-kind=app-jit", |
66 "--snapshot-kind=app-jit", | 59 main_file ] + training_args |
67 main_file, | |
68 ] + training_args | |
69 } else { | 60 } else { |
70 assert(false, "Bad dart_snapshot_kind: $dart_snapshot_kind") | 61 assert(false, "Bad dart_snapshot_kind: $dart_snapshot_kind") |
71 } | 62 } |
72 } | 63 } |
73 } | 64 } |
OLD | NEW |