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..ffc2897dd95c75c30c1912b3255927907a5be7ca |
| --- /dev/null |
| +++ b/third_party/closure_compiler/compile_js2.gni |
| @@ -0,0 +1,86 @@ |
| +# 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. |
| + # If sources is undefined, a default of ['<(_target_name).js'] |
| + # is created (this probably suffices for many targets). |
| + # - out_file: a file where the compiled output is written to. The default |
| + # is gen/closure/<path to |target_name|>/|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, without the .js |
| + # extension |
| + # - interfaces: interfaces required to compile the sources, without the |
| + # .js extension |
| + forward_variables_from(invoker, |
| + [ |
| + "sources", |
| + "out_file", |
| + "script_args", |
| + "closure_args", |
| + "runner_args", |
| + "disabled_closure_args", |
| + "externs", |
| + "interfaces", |
| + ]) |
| + |
| + CLOSURE_DIR = "//third_party/closure_compiler" |
| + |
| + action(target_name) { |
| + assert(defined(sources)) |
| + 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", |
| + ] |
| + if (defined(exters)) { |
|
Dan Beam
2016/08/17 18:24:21
externs
aberent
2016/08/18 16:08:52
Done.
|
| + EXTERNS_DIR = "${CLOSURE_DIR}/externs" |
| + for_each(extern, externs) { |
| + sources += [ "$EXTERNS_DIR/$extern" ] |
| + } |
| + } |
| + if (defined(interfaces)) { |
| + INTERFACES_DIR = "${CLOSURE_DIR}/interfaces" |
| + for_each(interface, interfaces) { |
| + sources += [ "$INTERFACES_DIR/$interface" ] |
| + } |
| + } |
| + outputs = [ |
| + out_file, |
| + ] |
| + script = "${CLOSURE_DIR}/compile2.py" |
| + args = script_args + rebase_path(sources) |
| + args += [ |
| + "--out_file", |
| + rebase_path(out_file), |
| + ] |
| + args += [ "--runner_args" ] + runner_args |
| + args += [ "--closure_args" ] + closure_args + disabled_closure_args |
| + } |
| +} |