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

Unified 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: TODO fix-it 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web/ios_web_unittests.gyp ('k') | ui/base/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/js_compile.gni
diff --git a/ios/web/js_compile.gni b/ios/web/js_compile.gni
new file mode 100644
index 0000000000000000000000000000000000000000..6c9590af12af909a3d4445127d863b366ef1febe
--- /dev/null
+++ b/ios/web/js_compile.gni
@@ -0,0 +1,171 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/util/java_action.gni")
+
+declare_args() {
+ # Control whether the JavaScript files shipped with Chrome on iOS are
+ # compiled with closure_compiler or not. Useful for debugging.
+ compile_javascript = true
+}
+
+closure_compiler_path = "//third_party/closure_compiler/compiler/compiler.jar"
+
+# Defines a target that create a JavaScript bundle using the closure compiler.
+#
+# Variables
+# sources:
+# List of JavaScript files to compile into the bundle.
+#
+# closure_entry_point:
+# Name of the entry point closure module.
+#
+# deps (optional)
+# List of targets required by this target.
+#
+# visibility (optional)
+# Visibility restrictions.
+#
+# 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.
+template("js_compile_bundle") {
+ assert(defined(invoker.sources),
+ "Need sources in $target_name listing the js files.")
+
+ assert(defined(invoker.closure_entry_point),
+ "Need closure_entry_point in $target_name for generated js file.")
+
+ java_action(target_name) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "visibility",
+ ])
+
+ script = closure_compiler_path
+ sources = invoker.sources
+ outputs = [
+ "$target_gen_dir/$target_name.js",
+ ]
+
+ args = [
+ "--compilation_level",
+ "SIMPLE_OPTIMIZATIONS",
+ "--js_output_file",
+ rebase_path("$target_gen_dir/$target_name.js", root_build_dir),
+ "--only_closure_dependencies",
+ "--closure_entry_point",
+ invoker.closure_entry_point,
+ "--js",
+ ] + rebase_path(sources, 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",
+ # ],
+ # },
+ }
+}
+
+# Defines a target that compile JavaScript files with 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(eugenebut): use flags from third_party/closure_compiler/closure_args.gni
+# once they are the same.
+template("js_compile_checked") {
+ 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}}",
+ ]
+
+ # TODO(eugenebut): need to enable the following compilation checks once
+ # the corresponding errors have been fixed:
+ # --jscomp_error=checkTypes
+ # --jscomp_error=checkVars
+ # --jscomp_error=missingProperties
+ # --jscomp_error=missingReturn
+ # --jscomp_error=undefinedVars
+
+ args = [
+ "--compilation_level",
+ "SIMPLE_OPTIMIZATIONS",
+ "--jscomp_error=accessControls",
+ "--jscomp_error=ambiguousFunctionDecl",
+ "--jscomp_error=constantProperty",
+ "--jscomp_error=deprecated",
+ "--jscomp_error=externsValidation",
+ "--jscomp_error=globalThis",
+ "--jscomp_error=invalidCasts",
+ "--jscomp_error=nonStandardJsDocs",
+ "--jscomp_error=suspiciousCode",
+ "--jscomp_error=undefinedNames",
+ "--jscomp_error=unknownDefines",
+ "--jscomp_error=uselessCode",
+ "--jscomp_error=visibility",
+ "--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",
+ # ],
+ # },
+ }
+ }
+}
« no previous file with comments | « 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