Skip to content

Commit

Permalink
Add closure_compile build flag.
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
nik3daz authored and Commit Bot committed Mar 28, 2018
1 parent c5dc779 commit ef75ebf
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 12 deletions.
7 changes: 6 additions & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import("//remoting/remoting_enable.gni")
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")
Expand Down Expand Up @@ -89,6 +90,10 @@ group("gn_all") {
]
}

if (closure_compile) {
deps += [ ":webui_closure_compile" ]
}

if (!is_ios && !is_android && !is_chromecast && !is_fuchsia) {
deps += [
"//chrome",
Expand Down Expand Up @@ -1153,7 +1158,7 @@ template("assert_valid_out_dir") {
"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",
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/resources/engagement/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions chrome/common/features.gni
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import("//net/features.gni")
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")

Expand Down
13 changes: 10 additions & 3 deletions third_party/closure_compiler/compile_js.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -219,8 +220,14 @@ template("js_binary") {

# 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) {
}
}
}
5 changes: 0 additions & 5 deletions ui/base/ui_features.gni
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ declare_args() {
# 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
2 changes: 1 addition & 1 deletion ui/resources/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
15 changes: 15 additions & 0 deletions ui/webui/webui_features.gni
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit ef75ebf

Please sign in to comment.