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. | |
10 # If sources is undefined, a default of ['<(_target_name).js'] | |
11 # is created (this probably suffices for many targets). | |
12 # - out_file: a file where the compiled output is written to. The default | |
13 # is gen/closure/<path to |target_name|>/|target_name|.js. | |
14 # - script_args: additional arguments to pass to compile.py. | |
15 # - closure_args: additional arguments to pass to the Closure compiler. | |
16 # - disabled_closure_args: additional arguments dealing with the | |
17 # strictness of compilation; Non-strict | |
18 # defaults are provided that can be overriden. | |
19 # - externs: externs required to compile the sources, without the .js | |
20 # extension | |
21 # - interfaces: interfaces required to compile the sources, without the | |
22 # .js extension | |
23 forward_variables_from(invoker, | |
24 [ | |
25 "sources", | |
26 "out_file", | |
27 "script_args", | |
28 "closure_args", | |
29 "runner_args", | |
30 "disabled_closure_args", | |
31 "externs", | |
32 "interfaces", | |
33 ]) | |
34 | |
35 CLOSURE_DIR = "//third_party/closure_compiler" | |
36 | |
37 action(target_name) { | |
38 assert(defined(sources)) | |
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 if (defined(exters)) { | |
Dan Beam
2016/08/17 18:24:21
externs
aberent
2016/08/18 16:08:52
Done.
| |
63 EXTERNS_DIR = "${CLOSURE_DIR}/externs" | |
64 for_each(extern, externs) { | |
65 sources += [ "$EXTERNS_DIR/$extern" ] | |
66 } | |
67 } | |
68 if (defined(interfaces)) { | |
69 INTERFACES_DIR = "${CLOSURE_DIR}/interfaces" | |
70 for_each(interface, interfaces) { | |
71 sources += [ "$INTERFACES_DIR/$interface" ] | |
72 } | |
73 } | |
74 outputs = [ | |
75 out_file, | |
76 ] | |
77 script = "${CLOSURE_DIR}/compile2.py" | |
78 args = script_args + rebase_path(sources) | |
79 args += [ | |
80 "--out_file", | |
81 rebase_path(out_file), | |
82 ] | |
83 args += [ "--runner_args" ] + runner_args | |
84 args += [ "--closure_args" ] + closure_args + disabled_closure_args | |
85 } | |
86 } | |
OLD | NEW |