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

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: 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
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..ededdf5f5d306dd52502ddd9746b9b626087acf3
--- /dev/null
+++ b/ios/web/js_compile.gni
@@ -0,0 +1,186 @@
+# 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.
+
+closure_compiler_wrapper = "closure_compiler.py"
+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.")
+
+ action(target_name) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "visibility",
+ ])
+
+ script = closure_compiler_wrapper
+ inputs = [
+ closure_compiler_path,
+ ]
+
+ outputs = [
+ "$target_gen_dir/$target_name.js",
+ ]
+ sources = invoker.sources
+
+ args = [
+ rebase_path(closure_compiler_path, root_build_dir),
+ "--compilation_level",
+ "SIMPLE_OPTIMIZATIONS",
+ "--js",
+ ] + rebase_path(sources, root_build_dir) + [ "--js_output_file" ] +
+ rebase_path(outputs, root_build_dir) +
+ [
+ "--only_closure_dependencies",
+ "--closure_entry_point",
+ invoker.closure_entry_point,
+ ]
+
+ # TODO(sdefresne): 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.
+#
+# compile (optional, defaults to true)
+# If false or undefined, the JavaScript files will not be compiled but
Eugene But (OOO till 7-30) 2015/10/08 16:10:41 I don't think that this comment is accurate. if in
Dirk Pranke 2015/10/08 17:49:45 Why even have the 'copy' part of this template? Wh
sdefresne 2015/10/09 13:54:45 Removed the comment as I've changed the value to a
+# just copied to the destination.
+#
+# 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 (defined(invoker.compile)) {
+ compile = invoker.compile
+ } else {
+ compile = true
+ }
+
+ if (compile) {
+ action_foreach(target_name) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "visibility",
+ ])
+
+ script = closure_compiler_wrapper
+ inputs = [
+ 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 = [
+ rebase_path(closure_compiler_path, root_build_dir),
+ "--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(sdefresne): 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(sdefresne): 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",
+ # ],
+ # },
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698