| 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") |
| 6 |
| 5 _dart_root = rebase_path("..") | 7 _dart_root = rebase_path("..") |
| 6 | 8 |
| 7 if (defined(is_win) && is_win) { | |
| 8 dart_executable_suffix = ".exe" | |
| 9 } else { | |
| 10 dart_executable_suffix = "" | |
| 11 } | |
| 12 | |
| 13 template("invoke_dart") { | |
| 14 assert(defined(invoker.outputs), "invoke_dart must specify outputs") | |
| 15 extra_deps = [] | |
| 16 if (defined(invoker.deps)) { | |
| 17 extra_deps += invoker.deps | |
| 18 } | |
| 19 | |
| 20 extra_inputs = [] | |
| 21 if (defined(invoker.inputs)) { | |
| 22 extra_inputs += invoker.inputs | |
| 23 } | |
| 24 | |
| 25 extra_args = [] | |
| 26 if (defined(invoker.args)) { | |
| 27 extra_args += invoker.args | |
| 28 } | |
| 29 | |
| 30 action(target_name) { | |
| 31 relative_dart_root = rebase_path(_dart_root, ".") | |
| 32 deps = | |
| 33 extra_deps + [ "$relative_dart_root/runtime/bin:dart($host_toolchain)" ] | |
| 34 | |
| 35 dart_out_dir = | |
| 36 get_label_info("$relative_dart_root/runtime/bin:dart($host_toolchain)", | |
| 37 "root_out_dir") | |
| 38 dart = rebase_path("$dart_out_dir/dart$dart_executable_suffix") | |
| 39 | |
| 40 inputs = [ dart ] + extra_inputs | |
| 41 | |
| 42 outputs = invoker.outputs | |
| 43 | |
| 44 script = "$_dart_root/tools/dart_for_gn.py" | |
| 45 args = [ dart ] + extra_args | |
| 46 } | |
| 47 } | |
| 48 | |
| 49 template("application_snapshot") { | 9 template("application_snapshot") { |
| 50 assert(defined(invoker.main_dart), "Must specify 'main_dart'") | 10 assert(defined(invoker.main_dart), "Must specify 'main_dart'") |
| 51 assert(defined(invoker.training_args), "Must specify 'training_args'") | 11 assert(defined(invoker.training_args), "Must specify 'training_args'") |
| 52 main_dart = invoker.main_dart | 12 main_dart = invoker.main_dart |
| 53 training_args = invoker.training_args | 13 training_args = invoker.training_args |
| 54 name = target_name | 14 name = target_name |
| 55 if (defined(invoker.name)) { | 15 if (defined(invoker.name)) { |
| 56 name = invoker.name | 16 name = invoker.name |
| 57 } | 17 } |
| 58 extra_deps = [] | 18 extra_deps = [] |
| 59 if (defined(invoker.deps)) { | 19 if (defined(invoker.deps)) { |
| 60 extra_deps += invoker.deps | 20 extra_deps += invoker.deps |
| 61 } | 21 } |
| 62 extra_inputs = [] | 22 extra_inputs = [] |
| 63 if (defined(invoker.inputs)) { | 23 if (defined(invoker.inputs)) { |
| 64 extra_inputs += invoker.inputs | 24 extra_inputs += invoker.inputs |
| 65 } | 25 } |
| 66 invoke_dart(target_name) { | 26 compiled_action(target_name) { |
| 27 tool = get_path_info("$_dart_root/runtime/bin:dart", "abspath") |
| 67 deps = extra_deps + [ "$_dart_root/pkg:pkg_files_stamp" ] | 28 deps = extra_deps + [ "$_dart_root/pkg:pkg_files_stamp" ] |
| 68 | 29 |
| 69 inputs = extra_inputs + [ | 30 inputs = extra_inputs + [ |
| 70 "$_dart_root/sdk/lib/_internal/sdk_library_metadata/lib/libraries
.dart", | 31 "$_dart_root/sdk/lib/_internal/sdk_library_metadata/lib/libraries
.dart", |
| 71 "$root_gen_dir/pkg_files.stamp", | 32 "$root_gen_dir/pkg_files.stamp", |
| 72 ] | 33 ] |
| 73 | 34 |
| 74 output = "$root_gen_dir/$name.dart.snapshot" | 35 output = "$root_gen_dir/$name.dart.snapshot" |
| 75 outputs = [ | 36 outputs = [ |
| 76 output, | 37 output, |
| 77 ] | 38 ] |
| 78 | 39 |
| 79 dot_packages = rebase_path("$_dart_root/.packages") | 40 dot_packages = rebase_path("$_dart_root/.packages") |
| 80 abs_output = rebase_path(output) | 41 abs_output = rebase_path(output) |
| 81 main_file = rebase_path(main_dart) | 42 main_file = rebase_path(main_dart) |
| 82 | 43 |
| 83 args = [ | 44 args = [ |
| 84 "--packages=$dot_packages", | 45 "--packages=$dot_packages", |
| 85 "--snapshot=$abs_output", | 46 "--snapshot=$abs_output", |
| 86 "--snapshot-kind=app-jit", | 47 "--snapshot-kind=app-jit", |
| 87 main_file, | 48 main_file, |
| 88 ] + training_args | 49 ] + training_args |
| 89 } | 50 } |
| 90 } | 51 } |
| OLD | NEW |