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..007cefe94a5c8215040210371a35a901fa973dfd |
| --- /dev/null |
| +++ b/third_party/closure_compiler/compile_js2.gni |
| @@ -0,0 +1,99 @@ |
| +# 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) { |
|
Dan Beam
2016/09/07 18:18:05
can we just automatically pref targets if we're do
aberent
2016/09/08 10:29:18
We could, and I wondered about this, but given tha
|
| + assert(defined(source_files)) |
| + |
| + 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" |
|
Dan Beam
2016/09/07 18:18:05
why is this /closure/ here? was this in the old s
|
| + } |
| + inputs = [ |
| + "${CLOSURE_DIR}/compile.py", |
| + "${CLOSURE_DIR}/processor.py", |
| + "${CLOSURE_DIR}/build/inputs.py", |
|
Dan Beam
2016/09/07 18:18:05
where are inputs.py or outputs.py invoked? they u
aberent
2016/09/08 10:29:19
Unless I have missed something inputs.py isn't act
Dan Beam
2016/09/08 17:53:21
yeah, I just want to remove from inputs = [] if we
|
| + "${CLOSURE_DIR}/build/outputs.py", |
| + "${CLOSURE_DIR}/compiler/compiler.jar", |
| + "${CLOSURE_DIR}/runner/runner.jar", |
| + ] |
| + |
| + sources = source_files |
|
Dan Beam
2016/09/07 18:18:05
can we not use sources directly rather than "sourc
aberent
2016/09/08 10:29:19
I tried this originally, and it didn't seem to wor
|
| + |
| + 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, |
| + ] |
| + |
| + # assign the sources to data to create run-time list of sources from the |
| + # dependency tree |
| + 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 += [ |
| + "--gn_source_list_file", |
| + rebase_path(source_list_file), |
| + ] |
| + args += [ "--runner_args" ] + runner_args |
| + args += [ "--closure_args" ] + closure_args + disabled_closure_args |
| + } |
| +} |