Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: ios/web/js_compile.gni

Issue 1393303003: [iOS][GN] Port ios_web_unittests to build with gn (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ios_third_party_blink
Patch Set: Address comments and factorize the code to run java "scripts" Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2015 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("//build/util/java_action.gni")
6
7 declare_args() {
8 # Control whether the JavaScript files shipped with Chrome on iOS are
9 # compiled with closure_compiler or not. Useful for debugging.
10 compile_javascript = true
11 }
12
13 closure_compiler_path = "//third_party/closure_compiler/compiler/compiler.jar"
14
15 # Defines a target that create a JavaScript bundle using the closure compiler.
16 #
17 # Variables
18 # sources:
19 # List of JavaScript files to compile into the bundle.
20 #
21 # closure_entry_point:
22 # Name of the entry point closure module.
23 #
24 # deps (optional)
25 # List of targets required by this target.
26 #
27 # visibility (optional)
28 # Visibility restrictions.
29 #
30 # Generates a single JavaScript bundle file that can be put in the application
31 # bundle.
32 #
33 # TODO(eugenebut): this should uses the same error flags as js_compile_checked.
34 template("js_compile_bundle") {
35 assert(defined(invoker.sources),
36 "Need sources in $target_name listing the js files.")
37
38 assert(defined(invoker.closure_entry_point),
39 "Need closure_entry_point in $target_name for generated js file.")
40
41 java_action(target_name) {
42 forward_variables_from(invoker,
43 [
44 "deps",
45 "visibility",
46 ])
47
48 script = closure_compiler_path
49 sources = invoker.sources
50 outputs = [
51 "$target_gen_dir/$target_name.js",
52 ]
53
54 args = [
55 "--compilation_level",
56 "SIMPLE_OPTIMIZATIONS",
57 "--js_output_file",
58 rebase_path("$target_gen_dir/$target_name.js", root_build_dir),
59 "--only_closure_dependencies",
60 "--closure_entry_point",
61 invoker.closure_entry_point,
62 "--js",
63 ] + rebase_path(sources, root_build_dir)
64
65 # TODO(sdefresne): add the generated bundle to the list of files to move
66 # in the application bundle, equivalent to the following gyp code:
67 #
68 # "link_settings": {
69 # "mac_bundle_resources": [
70 # "<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_NAME).js",
71 # ],
72 # },
73 }
74 }
75
76 # Defines a target that compile JavaScript files with error checking using the
77 # closure compiler.
78 #
79 # Variables
80 # sources:
81 # List of JavaScript files to compile.
82 #
83 # deps (optional)
84 # List of targets required by this target.
85 #
86 # visibility (optional)
87 # Visibility restrictions.
88 #
89 # TODO(eugenebut): use flags from third_party/closure_compiler/closure_args.gni
90 # once they are the same.
91 template("js_compile_checked") {
92 assert(defined(invoker.sources),
93 "Need sources in $target_name listing the js files.")
94
95 if (compile_javascript) {
96 java_action_foreach(target_name) {
97 forward_variables_from(invoker,
98 [
99 "deps",
100 "visibility",
101 ])
102
103 script = closure_compiler_path
104 sources = invoker.sources
105 outputs = [
106 "$target_gen_dir/{{source_file_part}}",
107 ]
108
109 # TODO(eugenebut): need to enable the following compilation checks once
110 # the corresponding errors have been fixed:
111 # --jscomp_error=checkTypes
112 # --jscomp_error=checkVars
113 # --jscomp_error=missingProperties
114 # --jscomp_error=missingReturn
115 # --jscomp_error=undefinedVars
116
117 args = [
118 "--compilation_level",
119 "SIMPLE_OPTIMIZATIONS",
120 "--jscomp_error=accessControls",
121 "--jscomp_error=ambiguousFunctionDecl",
122 "--jscomp_error=constantProperty",
123 "--jscomp_error=deprecated",
124 "--jscomp_error=externsValidation",
125 "--jscomp_error=globalThis",
126 "--jscomp_error=invalidCasts",
127 "--jscomp_error=nonStandardJsDocs",
128 "--jscomp_error=suspiciousCode",
129 "--jscomp_error=undefinedNames",
130 "--jscomp_error=unknownDefines",
131 "--jscomp_error=uselessCode",
132 "--jscomp_error=visibility",
133 "--js",
134 "{{source}}",
135 "--js_output_file",
136 rebase_path("$target_gen_dir/{{source_file_part}}", root_build_dir),
137 ]
138
139 # TODO(sdefresne): add the generated bundle to the list of files to move
140 # in the application bundle, equivalent to the following gyp code:
141 #
142 # "link_settings": {
143 # "mac_bundle_resources": [
144 # "<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_NAME).js",
145 # ],
146 # },
147 }
148 } else {
149 copy(target_name) {
150 forward_variables_from(invoker,
151 [
152 "deps",
153 "visibility",
154 ])
155
156 sources = invoker.sources
157 outputs = [
158 "$target_gen_dir/{{source_file_part}}",
159 ]
160
161 # TODO(sdefresne): add the generated bundle to the list of files to move
162 # in the application bundle, equivalent to the following gyp code:
163 #
164 # "link_settings": {
165 # "mac_bundle_resources": [
166 # "<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_NAME).js",
167 # ],
168 # },
169 }
170 }
171 }
OLDNEW
« build/util/java_action.py ('K') | « ios/web/ios_web_unittests.gyp ('k') | ui/base/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698