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 } |
13 } | 16 } |
14 | 17 |
15 template("application_snapshot") { | 18 template("application_snapshot") { |
16 assert(defined(invoker.main_dart), "Must specify 'main_dart'") | 19 assert(defined(invoker.main_dart), "Must specify 'main_dart'") |
17 assert(defined(invoker.training_args), "Must specify 'training_args'") | 20 assert(defined(invoker.training_args), "Must specify 'training_args'") |
18 main_dart = invoker.main_dart | 21 main_dart = invoker.main_dart |
19 training_args = invoker.training_args | 22 training_args = invoker.training_args |
20 name = target_name | 23 name = target_name |
21 if (defined(invoker.name)) { | 24 if (defined(invoker.name)) { |
22 name = invoker.name | 25 name = invoker.name |
23 } | 26 } |
24 extra_deps = [] | 27 extra_deps = [] |
25 if (defined(invoker.deps)) { | 28 if (defined(invoker.deps)) { |
26 extra_deps += invoker.deps | 29 extra_deps += invoker.deps |
27 } | 30 } |
28 extra_inputs = [main_dart] | 31 extra_inputs = [ main_dart ] |
29 if (defined(invoker.inputs)) { | 32 if (defined(invoker.inputs)) { |
30 extra_inputs += invoker.inputs | 33 extra_inputs += invoker.inputs |
31 } | 34 } |
32 compiled_action(target_name) { | 35 compiled_action(target_name) { |
33 tool = "$_dart_root/runtime/bin:dart" | 36 tool = "$_dart_root/runtime/bin:dart" |
34 deps = extra_deps + [ "$_dart_root/pkg:pkg_files_stamp" ] | 37 deps = extra_deps + [ "$_dart_root/pkg:pkg_files_stamp" ] |
35 | 38 |
36 inputs = extra_inputs + [ | 39 inputs = extra_inputs + [ |
37 "$_dart_root/sdk/lib/_internal/sdk_library_metadata/lib/libraries
.dart", | 40 "$_dart_root/sdk/lib/_internal/sdk_library_metadata/lib/libraries
.dart", |
38 "$root_gen_dir/pkg_files.stamp", | 41 "$root_gen_dir/pkg_files.stamp", |
39 ] | 42 ] |
40 | 43 |
41 output = "$root_gen_dir/$name.dart.snapshot" | 44 output = "$root_gen_dir/$name.dart.snapshot" |
42 outputs = [ | 45 outputs = [ |
43 output, | 46 output, |
44 ] | 47 ] |
45 | 48 |
46 dot_packages = rebase_path("$_dart_root/.packages") | 49 dot_packages = rebase_path("$_dart_root/.packages") |
47 abs_output = rebase_path(output) | 50 abs_output = rebase_path(output) |
48 main_file = rebase_path(main_dart) | 51 main_file = rebase_path(main_dart) |
49 | 52 |
50 args = [ "--packages=$dot_packages", | 53 args = [ |
51 "--snapshot=$abs_output" ] | 54 "--packages=$dot_packages", |
| 55 "--snapshot=$abs_output", |
| 56 ] |
52 | 57 |
53 if (dart_snapshot_kind == "script") { | 58 if (dart_snapshot_kind == "script") { |
54 args += ["--snapshot-kind=script", | 59 args += [ |
55 main_file ] | 60 "--snapshot-kind=script", |
| 61 main_file, |
| 62 ] |
56 assert(training_args != "", "Ignoring unused argument") | 63 assert(training_args != "", "Ignoring unused argument") |
57 } else if (dart_snapshot_kind == "app-jit") { | 64 } else if (dart_snapshot_kind == "app-jit") { |
58 args += ["--snapshot-kind=app-jit", | 65 args += [ |
59 main_file ] + training_args | 66 "--snapshot-kind=app-jit", |
| 67 main_file, |
| 68 ] + training_args |
60 } else { | 69 } else { |
61 assert(false, "Bad dart_snapshot_kind: $dart_snapshot_kind") | 70 assert(false, "Bad dart_snapshot_kind: $dart_snapshot_kind") |
62 } | 71 } |
63 } | 72 } |
64 } | 73 } |
OLD | NEW |