Chromium Code Reviews| Index: utils/invoke_dart.gni |
| diff --git a/utils/invoke_dart.gni b/utils/invoke_dart.gni |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..440b9ac5aacef157cbebd3bd770ce774334b5ccf |
| --- /dev/null |
| +++ b/utils/invoke_dart.gni |
| @@ -0,0 +1,89 @@ |
| +# 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. |
| + |
| +template("invoke_dart") { |
| + assert(defined(invoker.outputs), "invoke_dart must specify outputs") |
| + assert(defined(invoker.dart_root), "Where is the dart root?") |
| + dart_root = invoker.dart_root |
|
Cutch
2016/09/29 16:41:26
can't we automatically detect the dart root from t
zra
2016/09/29 17:46:41
Done.
|
| + extra_deps = [] |
| + if (defined(invoker.deps)) { |
| + extra_deps += invoker.deps |
| + } |
| + |
| + extra_inputs = [] |
| + if (defined(invoker.inputs)) { |
| + extra_inputs += invoker.inputs |
| + } |
| + |
| + extra_args = [] |
| + if (defined(invoker.args)) { |
| + extra_args += invoker.args |
| + } |
| + |
| + action(target_name) { |
| + deps = extra_deps + [ |
| + "$dart_root/runtime/bin:dart($host_toolchain)", |
| + ] |
| + |
| + dart_out_dir = get_label_info( |
| + "$dart_root/runtime/bin:dart($host_toolchain)", "root_out_dir") |
| + # TODO(zra): Add platform specific executable suffix (e.g. .exe on win) |
| + dart = rebase_path("$dart_out_dir/dart") |
| + |
| + inputs = [ |
| + dart, |
| + ] + extra_inputs |
| + |
| + outputs = invoker.outputs |
| + |
| + script = "$dart_root/tools/dart_for_gn.py" |
| + args = [ |
| + dart, |
| + ] + extra_args |
| + } |
| +} |
| + |
| +template("application_snapshot") { |
| + assert(defined(invoker.dart_root), "Must specify 'dart_root'") |
| + assert(defined(invoker.main_dart), "Must specify 'main_dart'") |
| + main_dart = invoker.main_dart |
| + name = target_name |
| + if (defined(invoker.name)) { |
| + name = invoker.name |
| + } |
| + extra_deps = [] |
| + if (defined(invoker.deps)) { |
| + extra_deps += invoker.deps |
| + } |
| + extra_inputs = [] |
| + if (defined(invoker.inputs)) { |
| + extra_inputs += invoker.inputs |
| + } |
| + invoke_dart(target_name) { |
| + dart_root = invoker.dart_root |
| + deps = extra_deps + [ |
| + "$dart_root/pkg:pkg_files_stamp" |
| + ] |
| + |
| + inputs = extra_inputs + [ |
| + "$dart_root/sdk/lib/_internal/sdk_library_metadata/lib/libraries.dart", |
| + "$root_gen_dir/pkg_files.stamp", |
| + ] |
| + |
| + output = "$root_gen_dir/$name.dart.snapshot" |
| + outputs = [ |
| + output, |
| + ] |
| + |
| + dot_packages = rebase_path("$dart_root/.packages") |
| + abs_output = rebase_path(output) |
| + main_file = rebase_path(main_dart) |
| + |
| + args = [ |
| + "--packages=$dot_packages", |
| + "--snapshot=$abs_output", |
| + main_file |
| + ] |
| + } |
| +} |