| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import("//build/util/java_action.gni") | 5 import("//build/util/java_action.gni") |
| 6 | 6 |
| 7 declare_args() { | 7 declare_args() { |
| 8 # Control whether the JavaScript files shipped with Chrome on iOS are | 8 # Control whether the JavaScript files shipped with Chrome on iOS are |
| 9 # compiled with closure_compiler or not. Useful for debugging. | 9 # compiled with closure_compiler or not. Useful for debugging. |
| 10 compile_javascript = true | 10 compile_javascript = true |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 # | 23 # |
| 24 # deps (optional) | 24 # deps (optional) |
| 25 # List of targets required by this target. | 25 # List of targets required by this target. |
| 26 # | 26 # |
| 27 # visibility (optional) | 27 # visibility (optional) |
| 28 # Visibility restrictions. | 28 # Visibility restrictions. |
| 29 # | 29 # |
| 30 # Generates a single JavaScript bundle file that can be put in the application | 30 # Generates a single JavaScript bundle file that can be put in the application |
| 31 # bundle. | 31 # bundle. |
| 32 # | 32 # |
| 33 # TODO(eugenebut): this should uses the same error flags as js_compile_checked. | 33 # TODO(crbug.com/487804): once all errors have been fixed, sync with the flags |
| 34 # from third_party/closure_compiler/closure_args.gni. |
| 34 template("js_compile_bundle") { | 35 template("js_compile_bundle") { |
| 35 assert(defined(invoker.sources), | 36 assert(defined(invoker.sources), |
| 36 "Need sources in $target_name listing the js files.") | 37 "Need sources in $target_name listing the js files.") |
| 37 | 38 |
| 38 assert(defined(invoker.closure_entry_point), | 39 assert(defined(invoker.closure_entry_point), |
| 39 "Need closure_entry_point in $target_name for generated js file.") | 40 "Need closure_entry_point in $target_name for generated js file.") |
| 40 | 41 |
| 41 java_action(target_name) { | 42 java_action(target_name) { |
| 42 forward_variables_from(invoker, | 43 forward_variables_from(invoker, |
| 43 [ | 44 [ |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 # Variables | 80 # Variables |
| 80 # sources: | 81 # sources: |
| 81 # List of JavaScript files to compile. | 82 # List of JavaScript files to compile. |
| 82 # | 83 # |
| 83 # deps (optional) | 84 # deps (optional) |
| 84 # List of targets required by this target. | 85 # List of targets required by this target. |
| 85 # | 86 # |
| 86 # visibility (optional) | 87 # visibility (optional) |
| 87 # Visibility restrictions. | 88 # Visibility restrictions. |
| 88 # | 89 # |
| 89 # TODO(eugenebut): use flags from third_party/closure_compiler/closure_args.gni | 90 # TODO(crbug.com/487804): once all errors have been fixed, sync with the flags |
| 90 # once they are the same. | 91 # from third_party/closure_compiler/closure_args.gni. |
| 91 template("js_compile_checked") { | 92 template("js_compile_checked") { |
| 92 assert(defined(invoker.sources), | 93 assert(defined(invoker.sources), |
| 93 "Need sources in $target_name listing the js files.") | 94 "Need sources in $target_name listing the js files.") |
| 94 | 95 |
| 95 if (compile_javascript) { | 96 if (compile_javascript) { |
| 96 java_action_foreach(target_name) { | 97 java_action_foreach(target_name) { |
| 97 forward_variables_from(invoker, | 98 forward_variables_from(invoker, |
| 98 [ | 99 [ |
| 99 "deps", | 100 "deps", |
| 100 "visibility", | 101 "visibility", |
| 101 ]) | 102 ]) |
| 102 | 103 |
| 103 script = closure_compiler_path | 104 script = closure_compiler_path |
| 104 sources = invoker.sources | 105 sources = invoker.sources |
| 105 outputs = [ | 106 outputs = [ |
| 106 "$target_gen_dir/{{source_file_part}}", | 107 "$target_gen_dir/{{source_file_part}}", |
| 107 ] | 108 ] |
| 108 | 109 |
| 109 # TODO(eugenebut): need to enable the following compilation checks once | 110 # TODO(crbug.com/487804): need to enable the following compilation checks |
| 110 # the corresponding errors have been fixed: | 111 # once the corresponding errors have been fixed: |
| 111 # --jscomp_error=checkTypes | 112 # --jscomp_error=checkTypes |
| 112 # --jscomp_error=checkVars | 113 # --jscomp_error=checkVars |
| 113 # --jscomp_error=missingProperties | 114 # --jscomp_error=missingProperties |
| 114 # --jscomp_error=missingReturn | 115 # --jscomp_error=missingReturn |
| 115 # --jscomp_error=undefinedVars | 116 # --jscomp_error=undefinedVars |
| 116 | 117 |
| 117 args = [ | 118 args = [ |
| 118 "--compilation_level", | 119 "--compilation_level", |
| 119 "SIMPLE_OPTIMIZATIONS", | 120 "SIMPLE_OPTIMIZATIONS", |
| 120 "--jscomp_error=accessControls", | 121 "--jscomp_error=accessControls", |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 # to move in the application bundle, equivalent to the following gyp code: | 163 # to move in the application bundle, equivalent to the following gyp code: |
| 163 # | 164 # |
| 164 # "link_settings": { | 165 # "link_settings": { |
| 165 # "mac_bundle_resources": [ | 166 # "mac_bundle_resources": [ |
| 166 # "<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_NAME).js", | 167 # "<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_NAME).js", |
| 167 # ], | 168 # ], |
| 168 # }, | 169 # }, |
| 169 } | 170 } |
| 170 } | 171 } |
| 171 } | 172 } |
| 173 |
| 174 # Defines a target that compile JavaScript files without error checking using |
| 175 # the closure compiler. |
| 176 # |
| 177 # Variables |
| 178 # sources: |
| 179 # List of JavaScript files to compile. |
| 180 # |
| 181 # deps (optional) |
| 182 # List of targets required by this target. |
| 183 # |
| 184 # visibility (optional) |
| 185 # Visibility restrictions. |
| 186 # |
| 187 # TODO(crbug.com/487804): once all errors have been fixed, remove this template |
| 188 # and port all code to use js_compile_checked instead. |
| 189 template("js_compile_unchecked") { |
| 190 assert(defined(invoker.sources), |
| 191 "Need sources in $target_name listing the js files.") |
| 192 |
| 193 if (compile_javascript) { |
| 194 java_action_foreach(target_name) { |
| 195 forward_variables_from(invoker, |
| 196 [ |
| 197 "deps", |
| 198 "visibility", |
| 199 ]) |
| 200 |
| 201 script = closure_compiler_path |
| 202 sources = invoker.sources |
| 203 outputs = [ |
| 204 "$target_gen_dir/{{source_file_part}}", |
| 205 ] |
| 206 |
| 207 args = [ |
| 208 "--compilation_level", |
| 209 "SIMPLE_OPTIMIZATIONS", |
| 210 "--js", |
| 211 "{{source}}", |
| 212 "--js_output_file", |
| 213 rebase_path("$target_gen_dir/{{source_file_part}}", root_build_dir), |
| 214 ] |
| 215 |
| 216 # TODO(crbug.com/546283): add the generated bundle to the list of files |
| 217 # to move in the application bundle, equivalent to the following gyp code: |
| 218 # |
| 219 # "link_settings": { |
| 220 # "mac_bundle_resources": [ |
| 221 # "<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_NAME).js", |
| 222 # ], |
| 223 # }, |
| 224 } |
| 225 } else { |
| 226 copy(target_name) { |
| 227 forward_variables_from(invoker, |
| 228 [ |
| 229 "deps", |
| 230 "visibility", |
| 231 ]) |
| 232 |
| 233 sources = invoker.sources |
| 234 outputs = [ |
| 235 "$target_gen_dir/{{source_file_part}}", |
| 236 ] |
| 237 |
| 238 # TODO(crbug.com/546283): add the generated bundle to the list of files |
| 239 # to move in the application bundle, equivalent to the following gyp code: |
| 240 # |
| 241 # "link_settings": { |
| 242 # "mac_bundle_resources": [ |
| 243 # "<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_NAME).js", |
| 244 # ], |
| 245 # }, |
| 246 } |
| 247 } |
| 248 } |
| OLD | NEW |