[go: nahoru, domu]

CC: Unify GN templates for all targets.

Simplify precompiled headers config.

BUG=575043

CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel

Review-Url: https://codereview.chromium.org/2532203003
Cr-Commit-Position: refs/heads/master@{#435498}
diff --git a/cc/BUILD.gn b/cc/BUILD.gn
index 7641d0b..2e357a0 100644
--- a/cc/BUILD.gn
+++ b/cc/BUILD.gn
@@ -4,7 +4,6 @@
 
 import("//build/config/ui.gni")
 import("//cc/cc.gni")
-import("//testing/test.gni")
 
 cc_component("cc") {
   sources = [
@@ -540,8 +539,6 @@
     ]
   }
 
-  configs = [ "//build/config:precompiled_headers" ]
-
   public_deps = [
     "//cc/base",
     "//skia",
@@ -576,7 +573,7 @@
   }
 }
 
-static_library("test_support") {
+cc_static_library("test_support") {
   testonly = true
   sources = [
     "test/animation_test_common.cc",
@@ -747,8 +744,6 @@
     "test/test_web_graphics_context_3d.h",
   ]
 
-  configs += [ "//build/config:precompiled_headers" ]
-
   public_deps = [
     ":cc",
     "//cc/animation",
@@ -783,7 +778,7 @@
   }
 }
 
-test("cc_unittests") {
+cc_test("cc_unittests") {
   sources = [
     "base/contiguous_container_unittest.cc",
     "base/delayed_unique_notifier_unittest.cc",
@@ -953,7 +948,6 @@
     "test/run_all_unittests.cc",
   ]
 
-  configs += [ "//build/config:precompiled_headers" ]
   if (!is_android) {
     data = [
       "test/data/",
@@ -991,7 +985,7 @@
   ]
 }
 
-test("cc_perftests") {
+cc_test("cc_perftests") {
   sources = [
     "animation/animation_host_perftest.cc",
     "ipc/cc_serialization_perftest.cc",
diff --git a/cc/blink/BUILD.gn b/cc/blink/BUILD.gn
index 06f79a66..36d3489 100644
--- a/cc/blink/BUILD.gn
+++ b/cc/blink/BUILD.gn
@@ -2,9 +2,9 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-import("//testing/test.gni")
+import("//cc/cc.gni")
 
-component("blink") {
+cc_component("blink") {
   output_name = "cc_blink"
 
   sources = [
@@ -46,7 +46,7 @@
   ]
 }
 
-test("cc_blink_unittests") {
+cc_test("cc_blink_unittests") {
   sources = [
     "web_layer_impl_fixed_bounds_unittest.cc",
 
diff --git a/cc/cc.gni b/cc/cc.gni
index 945ab759..91b2649 100644
--- a/cc/cc.gni
+++ b/cc/cc.gni
@@ -2,8 +2,10 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import("//testing/test.gni")
+
 cc_remove_configs = []
-cc_add_configs = []
+cc_add_configs = [ "//build/config:precompiled_headers" ]
 
 if (!is_debug && (is_win || is_android)) {
   cc_remove_configs += [ "//build/config/compiler:default_optimization" ]
@@ -31,3 +33,25 @@
     configs += cc_add_configs
   }
 }
+
+template("cc_static_library") {
+  static_library(target_name) {
+    forward_variables_from(invoker, "*", [ "configs" ])
+    if (defined(invoker.configs)) {
+      configs += invoker.configs
+    }
+    configs -= cc_remove_configs
+    configs += cc_add_configs
+  }
+}
+
+template("cc_test") {
+  test(target_name) {
+    forward_variables_from(invoker, "*", [ "configs" ])
+    if (defined(invoker.configs)) {
+      configs += invoker.configs
+    }
+    configs -= cc_remove_configs
+    configs += cc_add_configs
+  }
+}
diff --git a/cc/ipc/BUILD.gn b/cc/ipc/BUILD.gn
index 479a119d..01c83e3c 100644
--- a/cc/ipc/BUILD.gn
+++ b/cc/ipc/BUILD.gn
@@ -3,9 +3,10 @@
 # found in the LICENSE file.
 
 import("//build/config/ui.gni")
+import("//cc/cc.gni")
 import("//mojo/public/tools/bindings/mojom.gni")
 
-component("ipc") {
+cc_component("ipc") {
   output_name = "cc_ipc"
 
   defines = [ "CC_IPC_IMPLEMENTATION" ]
@@ -91,7 +92,7 @@
   ]
 }
 
-source_set("struct_traits") {
+cc_source_set("struct_traits") {
   sources = [
     "begin_frame_args_struct_traits.h",
     "compositor_frame_metadata_struct_traits.cc",
diff --git a/cc/proto/BUILD.gn b/cc/proto/BUILD.gn
index d94c4cbc..d03e00a 100644
--- a/cc/proto/BUILD.gn
+++ b/cc/proto/BUILD.gn
@@ -2,6 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import("//cc/cc.gni")
 import("//third_party/protobuf/proto_library.gni")
 
 # Use a group here to allow external targets to depend on "cc/proto" instead of
@@ -13,7 +14,7 @@
   ]
 }
 
-component("cc_proto") {
+cc_component("cc_proto") {
   # Only expose the target to the "proto" group.
   visibility = [ ":proto" ]