[go: nahoru, domu]

Convert some GN test support targets to static libs.

Converts some source sets that were source sets into static libraries. Converts additional targets in the touched files to static libraries where it seemed relevant.

Update the definition of //crypto:test_support to mark it testonly and make the conditions append sources rather than subtract them in the reverse condition.

A few redundant dependencies were removed (one shouldn't need to specify both "foo" and "foo:test_support").

BUG=627637
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_blink_rel

Review-Url: https://codereview.chromium.org/2151653003
Cr-Commit-Position: refs/heads/master@{#405544}
diff --git a/cc/BUILD.gn b/cc/BUILD.gn
index f1be4f7..d5db28e 100644
--- a/cc/BUILD.gn
+++ b/cc/BUILD.gn
@@ -589,7 +589,7 @@
   }
 }
 
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
   sources = [
     "test/animation_test_common.cc",
diff --git a/components/open_from_clipboard/BUILD.gn b/components/open_from_clipboard/BUILD.gn
index adb5aa1..fe46837 100644
--- a/components/open_from_clipboard/BUILD.gn
+++ b/components/open_from_clipboard/BUILD.gn
@@ -2,7 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-source_set("open_from_clipboard") {
+static_library("open_from_clipboard") {
   sources = [
     "clipboard_recent_content.cc",
     "clipboard_recent_content.h",
@@ -16,7 +16,7 @@
   ]
 }
 
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
   sources = [
     "fake_clipboard_recent_content.cc",
diff --git a/components/os_crypt/BUILD.gn b/components/os_crypt/BUILD.gn
index 81da111..1ef7f1f 100644
--- a/components/os_crypt/BUILD.gn
+++ b/components/os_crypt/BUILD.gn
@@ -5,7 +5,7 @@
 import("//build/config/features.gni")
 import("//build/config/ui.gni")
 
-source_set("os_crypt") {
+static_library("os_crypt") {
   sources = [
     "ie7_password_win.cc",
     "ie7_password_win.h",
@@ -75,7 +75,7 @@
   }
 }
 
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
   sources = [
     "os_crypt_mocker.cc",
@@ -123,10 +123,7 @@
     }
     if (use_dbus) {
       sources += [ "kwallet_dbus_unittest.cc" ]
-      deps += [
-        "//dbus",
-        "//dbus:test_support",
-      ]
+      deps += [ "//dbus:test_support" ]
       defines += [ "USE_KWALLET" ]
     }
   }
diff --git a/components/password_manager/core/browser/BUILD.gn b/components/password_manager/core/browser/BUILD.gn
index 2c1152c..bb60e6c 100644
--- a/components/password_manager/core/browser/BUILD.gn
+++ b/components/password_manager/core/browser/BUILD.gn
@@ -165,7 +165,7 @@
   ]
 }
 
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
   sources = [
     "fake_affiliation_api.cc",
diff --git a/components/policy/BUILD.gn b/components/policy/BUILD.gn
index 312d048..7538e8b7 100644
--- a/components/policy/BUILD.gn
+++ b/components/policy/BUILD.gn
@@ -229,7 +229,7 @@
     ]
   }
 
-  source_set("policy_component_test_support") {
+  static_library("policy_component_test_support") {
     testonly = true
     sources = [
       "core/browser/configuration_policy_pref_store_test.cc",
diff --git a/components/pref_registry/BUILD.gn b/components/pref_registry/BUILD.gn
index 8a3ef8b..4a32f9a 100644
--- a/components/pref_registry/BUILD.gn
+++ b/components/pref_registry/BUILD.gn
@@ -2,7 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-source_set("pref_registry") {
+static_library("pref_registry") {
   sources = [
     "pref_registry_syncable.cc",
     "pref_registry_syncable.h",
@@ -15,7 +15,7 @@
   ]
 }
 
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
   sources = [
     "testing_pref_service_syncable.cc",
diff --git a/components/prefs/BUILD.gn b/components/prefs/BUILD.gn
index 032ed18..ff4e1f2 100644
--- a/components/prefs/BUILD.gn
+++ b/components/prefs/BUILD.gn
@@ -55,7 +55,7 @@
   ]
 }
 
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
   sources = [
     "mock_pref_change_callback.cc",
diff --git a/components/printing/test/BUILD.gn b/components/printing/test/BUILD.gn
index 9b698386..aad7715 100644
--- a/components/printing/test/BUILD.gn
+++ b/components/printing/test/BUILD.gn
@@ -2,7 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
 
   sources = [
diff --git a/components/proximity_auth/BUILD.gn b/components/proximity_auth/BUILD.gn
index a19418d8..bcd4817 100644
--- a/components/proximity_auth/BUILD.gn
+++ b/components/proximity_auth/BUILD.gn
@@ -93,7 +93,7 @@
   }
 }
 
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
 
   sources = [
diff --git a/components/proximity_auth/cryptauth/BUILD.gn b/components/proximity_auth/cryptauth/BUILD.gn
index fc7d40e..6791187e 100644
--- a/components/proximity_auth/cryptauth/BUILD.gn
+++ b/components/proximity_auth/cryptauth/BUILD.gn
@@ -2,7 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-source_set("cryptauth") {
+static_library("cryptauth") {
   sources = [
     "cryptauth_access_token_fetcher.h",
     "cryptauth_access_token_fetcher_impl.cc",
@@ -53,7 +53,7 @@
   ]
 }
 
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
 
   sources = [
diff --git a/components/safe_json/BUILD.gn b/components/safe_json/BUILD.gn
index d611979..644e81d7 100644
--- a/components/safe_json/BUILD.gn
+++ b/components/safe_json/BUILD.gn
@@ -7,7 +7,7 @@
 }
 
 # GYP version: components/safe_json.gypi:safe_json
-source_set("safe_json") {
+static_library("safe_json") {
   sources = [
     "android/component_jni_registrar.cc",
     "android/component_jni_registrar.h",
@@ -62,7 +62,7 @@
 }
 
 # GYP version: components/safe_json.gypi:safe_json_test_support
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
   sources = [
     "testing_json_parser.cc",
diff --git a/components/scheduler/BUILD.gn b/components/scheduler/BUILD.gn
index 236b9a436..5180d47 100644
--- a/components/scheduler/BUILD.gn
+++ b/components/scheduler/BUILD.gn
@@ -111,7 +111,7 @@
 }
 
 # GYP version: components/scheduler.gypi:scheduler_common
-source_set("common") {
+static_library("common") {
   sources = [
     "common/scheduler_switches.cc",
     "common/scheduler_switches.h",
@@ -163,7 +163,7 @@
 }
 
 # GYP version: components/scheduler.gypi:scheduler_test_support
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
 
   sources = [
diff --git a/components/search_engines/BUILD.gn b/components/search_engines/BUILD.gn
index b4779bcc..ff6571a 100644
--- a/components/search_engines/BUILD.gn
+++ b/components/search_engines/BUILD.gn
@@ -94,7 +94,7 @@
   }
 }
 
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
   sources = [
     "default_search_pref_test_util.cc",
diff --git a/components/sessions/BUILD.gn b/components/sessions/BUILD.gn
index a8523473..da1c47e 100644
--- a/components/sessions/BUILD.gn
+++ b/components/sessions/BUILD.gn
@@ -129,7 +129,7 @@
   ]
 }
 
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
   sources = [
     "core/serialized_navigation_entry_test_helper.cc",
diff --git a/components/signin/core/browser/BUILD.gn b/components/signin/core/browser/BUILD.gn
index 0c3eb74c..a0d760d 100644
--- a/components/signin/core/browser/BUILD.gn
+++ b/components/signin/core/browser/BUILD.gn
@@ -6,7 +6,7 @@
   import("//build/config/android/rules.gni")
 }
 
-source_set("browser") {
+static_library("browser") {
   sources = [
     "about_signin_internals.cc",
     "about_signin_internals.h",
@@ -113,7 +113,7 @@
   }
 }
 
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
   sources = [
     "fake_account_fetcher_service.cc",
diff --git a/components/storage_monitor/BUILD.gn b/components/storage_monitor/BUILD.gn
index dbbedf8..1c008c6 100644
--- a/components/storage_monitor/BUILD.gn
+++ b/components/storage_monitor/BUILD.gn
@@ -5,7 +5,7 @@
 import("//build/config/features.gni")
 
 # GYP version: components/storage_monitor.gypi:storage_monitor
-source_set("storage_monitor") {
+static_library("storage_monitor") {
   sources = [
     "image_capture_device.h",
     "image_capture_device.mm",
@@ -88,7 +88,7 @@
 }
 
 # GYP version: components/storage_monitor.gypi:storage_monitor_test_support
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
   sources = [
     "mock_removable_storage_observer.cc",
diff --git a/components/subresource_filter/core/browser/BUILD.gn b/components/subresource_filter/core/browser/BUILD.gn
index 63b8458..f94482d 100644
--- a/components/subresource_filter/core/browser/BUILD.gn
+++ b/components/subresource_filter/core/browser/BUILD.gn
@@ -2,7 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-source_set("browser") {
+static_library("browser") {
   sources = [
     "ruleset_distributor.h",
     "ruleset_service.cc",
@@ -20,7 +20,7 @@
   ]
 }
 
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
   sources = [
     "subresource_filter_features_test_support.cc",
diff --git a/components/sync_driver/BUILD.gn b/components/sync_driver/BUILD.gn
index 4717d29..979666d0 100644
--- a/components/sync_driver/BUILD.gn
+++ b/components/sync_driver/BUILD.gn
@@ -5,7 +5,7 @@
 import("//build/buildflag_header.gni")
 import("//build/config/features.gni")
 
-source_set("sync_driver") {
+static_library("sync_driver") {
   sources = [
     "about_sync_util.cc",
     "about_sync_util.h",
@@ -156,7 +156,7 @@
   }
 }
 
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
   sources = [
     "change_processor_mock.cc",
diff --git a/components/sync_sessions/BUILD.gn b/components/sync_sessions/BUILD.gn
index c66737c4..c52bb6a 100644
--- a/components/sync_sessions/BUILD.gn
+++ b/components/sync_sessions/BUILD.gn
@@ -3,7 +3,7 @@
 # found in the LICENSE file.
 
 # GYP version: components/sync_sessions.gypi:sync_sessions
-source_set("sync_sessions") {
+static_library("sync_sessions") {
   sources = [
     "favicon_cache.cc",
     "favicon_cache.h",
@@ -65,7 +65,7 @@
   ]
 }
 
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
   sources = [
     "fake_sync_sessions_client.cc",
diff --git a/components/syncable_prefs/BUILD.gn b/components/syncable_prefs/BUILD.gn
index a4977ce..81edcad 100644
--- a/components/syncable_prefs/BUILD.gn
+++ b/components/syncable_prefs/BUILD.gn
@@ -4,7 +4,7 @@
 
 import("//build/config/features.gni")
 
-source_set("syncable_prefs") {
+static_library("syncable_prefs") {
   sources = [
     "pref_model_associator.cc",
     "pref_model_associator.h",
@@ -37,7 +37,7 @@
   }
 }
 
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
   sources = [
     "pref_service_mock_factory.cc",
diff --git a/components/toolbar/BUILD.gn b/components/toolbar/BUILD.gn
index 67cee0f0..797a6da2 100644
--- a/components/toolbar/BUILD.gn
+++ b/components/toolbar/BUILD.gn
@@ -4,7 +4,7 @@
 
 import("//build/config/ui.gni")
 
-source_set("toolbar") {
+static_library("toolbar") {
   sources = [
     "toolbar_model.cc",
     "toolbar_model.h",
@@ -28,7 +28,7 @@
   ]
 }
 
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
 
   sources = [
diff --git a/components/update_client/BUILD.gn b/components/update_client/BUILD.gn
index 7783b098..2833b159 100644
--- a/components/update_client/BUILD.gn
+++ b/components/update_client/BUILD.gn
@@ -2,7 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-source_set("update_client") {
+static_library("update_client") {
   sources = [
     "action.cc",
     "action.h",
@@ -66,7 +66,7 @@
   ]
 }
 
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
   sources = [
     "test_configurator.cc",
diff --git a/components/user_prefs/tracked/BUILD.gn b/components/user_prefs/tracked/BUILD.gn
index 3afd2bc..6904799 100644
--- a/components/user_prefs/tracked/BUILD.gn
+++ b/components/user_prefs/tracked/BUILD.gn
@@ -56,7 +56,7 @@
   ]
 }
 
-source_set("user_prefs_tracked_test_support") {
+static_library("user_prefs_tracked_test_support") {
   testonly = true
   sources = [
     "mock_validation_delegate.cc",
diff --git a/components/webdata_services/BUILD.gn b/components/webdata_services/BUILD.gn
index 8626a4c0..35d434b 100644
--- a/components/webdata_services/BUILD.gn
+++ b/components/webdata_services/BUILD.gn
@@ -23,7 +23,7 @@
   ]
 }
 
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
   sources = [
     "web_data_service_test_util.cc",
diff --git a/components/zoom/BUILD.gn b/components/zoom/BUILD.gn
index 4a2f3ea..42451b03 100644
--- a/components/zoom/BUILD.gn
+++ b/components/zoom/BUILD.gn
@@ -2,7 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-source_set("zoom") {
+static_library("zoom") {
   sources = [
     "page_zoom.cc",
     "page_zoom.h",
@@ -27,7 +27,7 @@
   ]
 }
 
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
   sources = [
     "test/zoom_test_utils.cc",
diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn
index bab905c..5bf5c7f5 100644
--- a/content/test/BUILD.gn
+++ b/content/test/BUILD.gn
@@ -50,7 +50,6 @@
     ":browsertest_base",
     ":content_test_mojo_bindings",
     "//base/third_party/dynamic_annotations",
-    "//cc",
     "//cc:test_support",
     "//cc/blink",
     "//cc/ipc",
@@ -207,7 +206,7 @@
 
 # browsertest_support can be used by targets that run content_shell based
 # browser tests.
-source_set("browsertest_support") {
+static_library("browsertest_support") {
   testonly = true
 
   # See comment at the top of //content/BUILD.gn for why this is disabled in
@@ -258,7 +257,7 @@
 }
 
 # browsertest_base can be used by any browser test target.
-source_set("browsertest_base") {
+static_library("browsertest_base") {
   testonly = true
 
   sources = [
diff --git a/crypto/BUILD.gn b/crypto/BUILD.gn
index 088a5c1..a912d934 100644
--- a/crypto/BUILD.gn
+++ b/crypto/BUILD.gn
@@ -175,36 +175,32 @@
   ]
 }
 
+# This has no sources in some cases so can't be a static library.
 source_set("test_support") {
-  sources = [
-    "scoped_test_nss_chromeos_user.cc",
-    "scoped_test_nss_chromeos_user.h",
-    "scoped_test_nss_db.cc",
-    "scoped_test_nss_db.h",
-    "scoped_test_system_nss_key_slot.cc",
-    "scoped_test_system_nss_key_slot.h",
-  ]
-  deps = [
-    ":crypto",
-    ":platform",
-    "//base",
-  ]
+  testonly = true
+  sources = []
 
-  if (!use_nss_certs) {
-    sources -= [
+  if (use_nss_certs) {
+    sources += [
       "scoped_test_nss_db.cc",
       "scoped_test_nss_db.h",
     ]
   }
 
-  if (!is_chromeos) {
-    sources -= [
+  if (is_chromeos) {
+    sources += [
       "scoped_test_nss_chromeos_user.cc",
       "scoped_test_nss_chromeos_user.h",
       "scoped_test_system_nss_key_slot.cc",
       "scoped_test_system_nss_key_slot.h",
     ]
   }
+
+  deps = [
+    ":crypto",
+    ":platform",
+    "//base",
+  ]
 }
 
 config("platform_config") {
diff --git a/dbus/BUILD.gn b/dbus/BUILD.gn
index ed113c8..28efb93f 100644
--- a/dbus/BUILD.gn
+++ b/dbus/BUILD.gn
@@ -59,7 +59,7 @@
 
 # This target contains mocks that can be used to write unit tests without
 # issuing actual D-Bus calls.
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
   sources = [
     "mock_bus.cc",
diff --git a/device/usb/BUILD.gn b/device/usb/BUILD.gn
index da028ff..ce1fe655 100644
--- a/device/usb/BUILD.gn
+++ b/device/usb/BUILD.gn
@@ -14,7 +14,7 @@
 source_ids = "//third_party/usb_ids/usb.ids"
 generated_ids = "$target_gen_dir/usb_ids_gen.cc"
 
-source_set("usb") {
+static_library("usb") {
   sources = [
     "android/usb_jni_registrar.cc",
     "android/usb_jni_registrar.h",
@@ -102,7 +102,7 @@
   }
 }
 
-source_set("test_support") {
+static_library("test_support") {
   testonly = true
 
   sources = [