Index: ios/web/js_compile.gni |
diff --git a/ios/web/js_compile.gni b/ios/web/js_compile.gni |
index 6c9590af12af909a3d4445127d863b366ef1febe..a8c70713650d415cb574bc2b4546a7ed9234798c 100644 |
--- a/ios/web/js_compile.gni |
+++ b/ios/web/js_compile.gni |
@@ -30,7 +30,8 @@ closure_compiler_path = "//third_party/closure_compiler/compiler/compiler.jar" |
# Generates a single JavaScript bundle file that can be put in the application |
# bundle. |
# |
-# TODO(eugenebut): this should uses the same error flags as js_compile_checked. |
+# TODO(crbug.com/487804): once all errors have been fixed, sync with the flags |
+# from third_party/closure_compiler/closure_args.gni. |
template("js_compile_bundle") { |
assert(defined(invoker.sources), |
"Need sources in $target_name listing the js files.") |
@@ -86,8 +87,8 @@ template("js_compile_bundle") { |
# visibility (optional) |
# Visibility restrictions. |
# |
-# TODO(eugenebut): use flags from third_party/closure_compiler/closure_args.gni |
-# once they are the same. |
+# TODO(crbug.com/487804): once all errors have been fixed, sync with the flags |
+# from third_party/closure_compiler/closure_args.gni. |
template("js_compile_checked") { |
assert(defined(invoker.sources), |
"Need sources in $target_name listing the js files.") |
@@ -106,8 +107,8 @@ template("js_compile_checked") { |
"$target_gen_dir/{{source_file_part}}", |
] |
- # TODO(eugenebut): need to enable the following compilation checks once |
- # the corresponding errors have been fixed: |
+ # TODO(crbug.com/487804): need to enable the following compilation checks |
+ # once the corresponding errors have been fixed: |
# --jscomp_error=checkTypes |
# --jscomp_error=checkVars |
# --jscomp_error=missingProperties |
@@ -169,3 +170,79 @@ template("js_compile_checked") { |
} |
} |
} |
+ |
+# Defines a target that compile JavaScript files without error checking using |
+# the closure compiler. |
+# |
+# Variables |
+# sources: |
+# List of JavaScript files to compile. |
+# |
+# deps (optional) |
+# List of targets required by this target. |
+# |
+# visibility (optional) |
+# Visibility restrictions. |
+# |
+# TODO(crbug.com/487804): once all errors have been fixed, remove this template |
+# and port all code to use js_compile_checked instead. |
+template("js_compile_unchecked") { |
+ assert(defined(invoker.sources), |
+ "Need sources in $target_name listing the js files.") |
+ |
+ if (compile_javascript) { |
+ java_action_foreach(target_name) { |
+ forward_variables_from(invoker, |
+ [ |
+ "deps", |
+ "visibility", |
+ ]) |
+ |
+ script = closure_compiler_path |
+ sources = invoker.sources |
+ outputs = [ |
+ "$target_gen_dir/{{source_file_part}}", |
+ ] |
+ |
+ args = [ |
+ "--compilation_level", |
+ "SIMPLE_OPTIMIZATIONS", |
+ "--js", |
+ "{{source}}", |
+ "--js_output_file", |
+ rebase_path("$target_gen_dir/{{source_file_part}}", root_build_dir), |
+ ] |
+ |
+ # TODO(crbug.com/546283): add the generated bundle to the list of files |
+ # to move in the application bundle, equivalent to the following gyp code: |
+ # |
+ # "link_settings": { |
+ # "mac_bundle_resources": [ |
+ # "<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_NAME).js", |
+ # ], |
+ # }, |
+ } |
+ } else { |
+ copy(target_name) { |
+ forward_variables_from(invoker, |
+ [ |
+ "deps", |
+ "visibility", |
+ ]) |
+ |
+ sources = invoker.sources |
+ outputs = [ |
+ "$target_gen_dir/{{source_file_part}}", |
+ ] |
+ |
+ # TODO(crbug.com/546283): add the generated bundle to the list of files |
+ # to move in the application bundle, equivalent to the following gyp code: |
+ # |
+ # "link_settings": { |
+ # "mac_bundle_resources": [ |
+ # "<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_NAME).js", |
+ # ], |
+ # }, |
+ } |
+ } |
+} |