Chromium Code Reviews| Index: third_party/closure_compiler/compile_js2.gni |
| diff --git a/third_party/closure_compiler/compile_js2.gni b/third_party/closure_compiler/compile_js2.gni |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cab00b7ca0ff583a336c2a75463beac73eaf7086 |
| --- /dev/null |
| +++ b/third_party/closure_compiler/compile_js2.gni |
| @@ -0,0 +1,98 @@ |
| +# Copyright 2016 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import("closure_args.gni") |
| + |
| +template("compile_js") { |
| + # This template optionally takes these arguments: |
| + # - sources: a list of all of the source files to be compiled. Required. |
| + # - out_file: a file where the compiled output is written to. The default |
| + # is ${target_gen_dir}/closure/${target_name}.js". |
| + # - script_args: additional arguments to pass to compile.py. |
| + # - closure_args: additional arguments to pass to the Closure compiler. |
| + # - disabled_closure_args: additional arguments dealing with the |
| + # strictness of compilation; Non-strict |
| + # defaults are provided that can be overriden. |
| + # - externs: externs required to compile the sources |
| + # - interfaces: interfaces required to compile the sources |
| + forward_variables_from(invoker, |
| + [ |
| + "source_files", |
| + "deps", |
| + "out_file", |
| + "script_args", |
| + "closure_args", |
| + "runner_args", |
| + "disabled_closure_args", |
| + "externs", |
| + "interfaces", |
| + ]) |
| + |
| + CLOSURE_DIR = "//third_party/closure_compiler" |
| + |
| + action(target_name) { |
| + assert(defined(source_files)) |
| + |
| + # assign the sources to data to create run-time list of sources from the |
| + # dependency tree |
|
Dan Beam
2016/08/19 01:55:19
can actions have dependencies? if so, we just kin
aberent
2016/09/06 13:22:29
Yes, actions can have dependencies. The problem is
|
| + if (!defined(runner_args)) { |
| + runner_args = [ "enable-chrome-pass" ] |
| + } |
| + if (!defined(script_args)) { |
| + script_args = [] |
| + } |
| + if (!defined(closure_args)) { |
| + closure_args = common_closure_args + checking_closure_args |
| + } |
| + if (!defined(disabled_closure_args)) { |
| + disabled_closure_args = default_disabled_closure_args |
| + } |
| + if (!defined(out_file)) { |
| + out_file = "${target_gen_dir}/closure/${target_name}.js" |
| + } |
| + inputs = [ |
| + "${CLOSURE_DIR}/compile.py", |
| + "${CLOSURE_DIR}/processor.py", |
| + "${CLOSURE_DIR}/build/inputs.py", |
| + "${CLOSURE_DIR}/build/outputs.py", |
| + "${CLOSURE_DIR}/compiler/compiler.jar", |
| + "${CLOSURE_DIR}/runner/runner.jar", |
| + ] |
| + |
| + sources = source_files |
| + |
| + if (defined(externs)) { |
| + EXTERNS_DIR = "${CLOSURE_DIR}/externs" |
| + foreach(extern, externs) { |
| + sources += [ "$EXTERNS_DIR/$extern" ] |
| + } |
| + } |
| + if (defined(interfaces)) { |
| + INTERFACES_DIR = "${CLOSURE_DIR}/interfaces" |
| + foreach(interface, interfaces) { |
| + sources += [ "$INTERFACES_DIR/$interface" ] |
| + } |
| + } |
| + outputs = [ |
| + out_file, |
| + ] |
| + data = sources |
| + source_list_file = |
| + "${target_gen_dir}/closure/${target_name}_source_list_file" |
| + write_runtime_deps = source_list_file |
| + |
| + script = "${CLOSURE_DIR}/compile2.py" |
| + args = script_args + rebase_path(sources) |
| + args += [ |
| + "--out_file", |
| + rebase_path(out_file), |
| + ] |
| + args += [ |
| + "--source_list_file", |
| + rebase_path(source_list_file), |
| + ] |
| + args += [ "--runner_args" ] + runner_args |
| + args += [ "--closure_args" ] + closure_args + disabled_closure_args |
| + } |
| +} |