Add closure_compile build flag.
This CL adds a closure_compile build flag which is set to compile on
the android, linux and chromeos trybots. This flag causes the js_type_check
target to no-op by generating an empty group() target.
Bug: 820473
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I77e2fdbb9bb7881cf0cb335bad0978c8532ea539
Reviewed-on: https://chromium-review.googlesource.com/958308
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: calamity <calamity@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546398}
diff --git a/BUILD.gn b/BUILD.gn
index d7058700..1fdb3ab 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -21,6 +21,7 @@
import("//third_party/openh264/openh264_args.gni")
import("//tools/ipc_fuzzer/ipc_fuzzer.gni")
import("//ui/base/ui_features.gni")
+import("//ui/webui/webui_features.gni")
import("//ui/ozone/ozone.gni")
import("//v8/gni/v8.gni")
import("//v8/snapshot_toolchain.gni")
@@ -89,6 +90,10 @@
]
}
+ if (closure_compile) {
+ deps += [ ":webui_closure_compile" ]
+ }
+
if (!is_ios && !is_android && !is_chromecast && !is_fuchsia) {
deps += [
"//chrome",
@@ -1153,7 +1158,7 @@
"Do not use a platform name in your output directory (found \"$root_build_dir\"). http://crbug.com/548283")
}
-if (!is_win) {
+if (closure_compile) {
group("webui_closure_compile") {
data_deps = [
"chrome/browser/resources/engagement:closure_compile",
diff --git a/chrome/browser/resources/engagement/BUILD.gn b/chrome/browser/resources/engagement/BUILD.gn
index 93c8c3a1..84ee3210 100644
--- a/chrome/browser/resources/engagement/BUILD.gn
+++ b/chrome/browser/resources/engagement/BUILD.gn
@@ -4,13 +4,13 @@
import("//third_party/closure_compiler/compile_js.gni")
-group("closure_compile") {
+js_type_check("closure_compile") {
deps = [
":site_engagement",
]
}
-js_binary("site_engagement") {
+js_library("site_engagement") {
deps = [
"//ui/webui/resources/js:assert",
"//ui/webui/resources/js:util",
diff --git a/chrome/common/features.gni b/chrome/common/features.gni
index bfdee74e..2c6bb35 100644
--- a/chrome/common/features.gni
+++ b/chrome/common/features.gni
@@ -14,6 +14,7 @@
import("//ppapi/buildflags/buildflags.gni")
import("//printing/features/features.gni")
import("//ui/base/ui_features.gni")
+import("//ui/webui/webui_features.gni")
assert(!is_ios, "Chromium/iOS shouldn't use anything in //chrome")
diff --git a/third_party/closure_compiler/compile_js.gni b/third_party/closure_compiler/compile_js.gni
index 83a2f1d3..c1955d8b 100644
--- a/third_party/closure_compiler/compile_js.gni
+++ b/third_party/closure_compiler/compile_js.gni
@@ -3,6 +3,7 @@
# found in the LICENSE file.
import("//third_party/closure_compiler/closure_args.gni")
+import("//ui/webui/webui_features.gni")
script_path = "//third_party/closure_compiler"
compiler_path = "$script_path/compiler/compiler.jar"
@@ -219,8 +220,14 @@
# Defines a target that compiles a group of js_library targets.
template("js_type_check") {
- js_binary(target_name) {
- sources = []
- forward_variables_from(invoker, [ "deps" ])
+ if (closure_compile) {
+ js_binary(target_name) {
+ sources = []
+ forward_variables_from(invoker, [ "deps" ])
+ }
+ } else {
+ not_needed(invoker, "*")
+ group(target_name) {
+ }
}
}
diff --git a/ui/base/ui_features.gni b/ui/base/ui_features.gni
index 1a8ec2b0..25f9980 100644
--- a/ui/base/ui_features.gni
+++ b/ui/base/ui_features.gni
@@ -20,11 +20,6 @@
# Set to true to if mus (aka the UI service) is enabled. Use the features kMus
# (or kMash in chrome code) to start in mus/mash.
enable_mus = is_chromeos
-
- # Optimize parts of Chrome's UI written with web technologies (HTML/CSS/JS)
- # for runtime performance purposes. This does more work at compile time for
- # speed benefits at runtime (so we skip in debug builds).
- optimize_webui = !is_debug
}
enable_hidpi = is_mac || is_win || is_linux
diff --git a/ui/resources/BUILD.gn b/ui/resources/BUILD.gn
index 8286ba5..c10eb455 100644
--- a/ui/resources/BUILD.gn
+++ b/ui/resources/BUILD.gn
@@ -5,7 +5,7 @@
import("//build/config/jumbo.gni")
import("//tools/grit/grit_rule.gni")
import("//tools/grit/repack.gni")
-import("//ui/base/ui_features.gni")
+import("//ui/webui/webui_features.gni")
group("resources") {
public_deps = [
diff --git a/ui/webui/webui_features.gni b/ui/webui/webui_features.gni
new file mode 100644
index 0000000..c20d7c3
--- /dev/null
+++ b/ui/webui/webui_features.gni
@@ -0,0 +1,15 @@
+# Copyright 2018 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.
+
+declare_args() {
+ # Optimize parts of Chrome's UI written with web technologies (HTML/CSS/JS)
+ # for runtime performance purposes. This does more work at compile time for
+ # speed benefits at runtime (so we skip in debug builds).
+ optimize_webui = !is_debug
+
+ # Enable closure type-checking for Chrome's web technology-based UI. This
+ # enables the webui_closure_compile target which does a no-op without this
+ # flag enabled. Requires Java.
+ closure_compile = is_chromeos || is_linux || is_android
+}