Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 import("closure_args.gni") | |
| 6 | |
| 7 template("compile_js") { | |
| 8 # This template optionally takes these arguments: | |
| 9 # - sources: a list of all of the source files to be compiled. Required. | |
| 10 # - out_file: a file where the compiled output is written to. The default | |
| 11 # is ${target_gen_dir}/closure/${target_name}.js". | |
| 12 # - script_args: additional arguments to pass to compile.py. | |
| 13 # - closure_args: additional arguments to pass to the Closure compiler. | |
| 14 # - disabled_closure_args: additional arguments dealing with the | |
| 15 # strictness of compilation; Non-strict | |
| 16 # defaults are provided that can be overriden. | |
| 17 # - externs: externs required to compile the sources | |
| 18 # - interfaces: interfaces required to compile the sources | |
| 19 forward_variables_from(invoker, | |
| 20 [ | |
| 21 "source_files", | |
| 22 "deps", | |
| 23 "out_file", | |
| 24 "script_args", | |
| 25 "closure_args", | |
| 26 "runner_args", | |
| 27 "disabled_closure_args", | |
| 28 "externs", | |
| 29 "interfaces", | |
| 30 ]) | |
| 31 | |
| 32 CLOSURE_DIR = "//third_party/closure_compiler" | |
| 33 | |
| 34 action(target_name) { | |
| 35 assert(defined(source_files)) | |
| 36 | |
| 37 # assign the sources to data to create run-time list of sources from the | |
| 38 # 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
| |
| 39 if (!defined(runner_args)) { | |
| 40 runner_args = [ "enable-chrome-pass" ] | |
| 41 } | |
| 42 if (!defined(script_args)) { | |
| 43 script_args = [] | |
| 44 } | |
| 45 if (!defined(closure_args)) { | |
| 46 closure_args = common_closure_args + checking_closure_args | |
| 47 } | |
| 48 if (!defined(disabled_closure_args)) { | |
| 49 disabled_closure_args = default_disabled_closure_args | |
| 50 } | |
| 51 if (!defined(out_file)) { | |
| 52 out_file = "${target_gen_dir}/closure/${target_name}.js" | |
| 53 } | |
| 54 inputs = [ | |
| 55 "${CLOSURE_DIR}/compile.py", | |
| 56 "${CLOSURE_DIR}/processor.py", | |
| 57 "${CLOSURE_DIR}/build/inputs.py", | |
| 58 "${CLOSURE_DIR}/build/outputs.py", | |
| 59 "${CLOSURE_DIR}/compiler/compiler.jar", | |
| 60 "${CLOSURE_DIR}/runner/runner.jar", | |
| 61 ] | |
| 62 | |
| 63 sources = source_files | |
| 64 | |
| 65 if (defined(externs)) { | |
| 66 EXTERNS_DIR = "${CLOSURE_DIR}/externs" | |
| 67 foreach(extern, externs) { | |
| 68 sources += [ "$EXTERNS_DIR/$extern" ] | |
| 69 } | |
| 70 } | |
| 71 if (defined(interfaces)) { | |
| 72 INTERFACES_DIR = "${CLOSURE_DIR}/interfaces" | |
| 73 foreach(interface, interfaces) { | |
| 74 sources += [ "$INTERFACES_DIR/$interface" ] | |
| 75 } | |
| 76 } | |
| 77 outputs = [ | |
| 78 out_file, | |
| 79 ] | |
| 80 data = sources | |
| 81 source_list_file = | |
| 82 "${target_gen_dir}/closure/${target_name}_source_list_file" | |
| 83 write_runtime_deps = source_list_file | |
| 84 | |
| 85 script = "${CLOSURE_DIR}/compile2.py" | |
| 86 args = script_args + rebase_path(sources) | |
| 87 args += [ | |
| 88 "--out_file", | |
| 89 rebase_path(out_file), | |
| 90 ] | |
| 91 args += [ | |
| 92 "--source_list_file", | |
| 93 rebase_path(source_list_file), | |
| 94 ] | |
| 95 args += [ "--runner_args" ] + runner_args | |
| 96 args += [ "--closure_args" ] + closure_args + disabled_closure_args | |
| 97 } | |
| 98 } | |
| OLD | NEW |