Rationalize the top-level BUILD.gn rules a bit

Historically for reasons that are no longer relevant //mojo/BUILD.gn's
"mojo" target has been treated as the global metatarget to add new
things to, including targets in other top-level directories like
//services. This rationalizes the dependency structure in the top few
build files to more closely match the directory structure. //BUILD.gn
references metatargets in top level directories and
//{services,mojo,shell}/BUILD.gn handle references within those
//directories. This will hopefully make it clearer where to add new
//targets.

R=viettrungluu@chromium.org

Review URL: https://codereview.chromium.org/1312763004 .
diff --git a/BUILD.gn b/BUILD.gn
index bb7dfc4..a3e4bf8 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -2,12 +2,15 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import("//build/config/ui.gni")
+
 # This target will be built if no target is specified when invoking ninja.
 group("default") {
   testonly = true
 
   deps = [
     "//apps",
+    "//benchmarks",
     "//crypto:crypto_unittests",
     "//examples",
     "//mojo",
@@ -18,7 +21,7 @@
     "//ui/events:events_unittests",
   ]
 
-  if (!is_android && !is_win) {
+  if (!is_android) {
     deps += [ "//tools/xdisplaycheck" ]
   }
 
@@ -26,6 +29,13 @@
     deps += [ "//sandbox/linux:sandbox" ]
     deps += [ "//sandbox/linux:sandbox_linux_unittests" ]
   }
+
+  if (use_ozone) {
+    deps += [
+      "//ui/ozone",
+      "//ui/ozone/demo",
+    ]
+  }
 }
 
 # Deprecated name for the default build target.
diff --git a/mojo/BUILD.gn b/mojo/BUILD.gn
index bbfa7ea..ddc7176 100644
--- a/mojo/BUILD.gn
+++ b/mojo/BUILD.gn
@@ -2,11 +2,9 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-import("//build/config/ui.gni")
 import("//build/module_args/mojo.gni")
 import("//mojo/public/mojo.gni")
 
-# TODO(beng): this meta target should probably move to the root dir's BUILD.gn.
 group("mojo") {
   # Meta-target, don't link into production code.
   testonly = true
@@ -18,13 +16,10 @@
   }
   deps = [
     ":tests",
-    "//benchmarks",
-    "//examples",
     "//mojo/common",
     "//mojo/dart",
     "//mojo/public",
     "//mojo/services",
-    "//services",
   ]
 
   if (is_android) {
@@ -50,13 +45,6 @@
       "//mojo/nacl:mojo_nacl_tests",
     ]
   }
-
-  if (use_ozone) {
-    deps += [
-      "//ui/ozone",
-      "//ui/ozone/demo",
-    ]
-  }
 }
 
 group("tests") {
@@ -71,41 +59,14 @@
     "//mojo/services/view_manager/public/cpp/tests:mojo_view_manager_lib_unittests",
     "//mojo/tests:mojo_task_tracker_perftests",
     "//mojo/tools:message_generator",
-    "//services/asset_bundle:apptests",
-    "//services/clipboard:apptests",
-    "//services/dart/dart_apptests",
-    "//services/files:apptests",
     "//mojo/gpu:apptests",
     "//mojo/services/files/public/c:apptests",
-    "//services/authenticating_url_loader_interceptor:apptests",
-    "//services/http_server:apptests",
-    "//services/prediction:apptests",
-    "//services/reaper:tests",
-    "//services/url_response_disk_cache:tests",
-    "//services/view_manager:mojo_view_manager_client_apptests",
-    "//services/view_manager:view_manager_service_apptests",
-    "//services/view_manager:view_manager_service_unittests",
-    "//services/window_manager:window_manager_apptests",
-    "//services/window_manager:window_manager_unittests",
-    "//shell:apptests",
   ]
 
-  if (is_linux) {
-    deps += [ "//services/python:python_apptests" ]
-  }
-
-  if (is_android) {
-    deps += [ "//services/notifications:apptests" ]
-  }
-
   # TODO(jamesr): We only support building V8 snapshot data on a linux host since it
   # needs a 32 bit toolchain and we don't have one configured for mac hosts.
   if (host_os == "linux") {
-    deps += [
-      "//mojo/edk/js:tests",
-      "//services/js:js_apptests",
-      "//services/js:js_services_unittests",
-    ]
+    deps += [ "//mojo/edk/js:tests" ]
   }
 
   if (mojo_use_prebuilt_network_service) {
diff --git a/services/BUILD.gn b/services/BUILD.gn
index a6e68ce..129561b 100644
--- a/services/BUILD.gn
+++ b/services/BUILD.gn
@@ -3,7 +3,10 @@
 # found in the LICENSE file.
 
 group("services") {
+  testonly = true
+
   deps = [
+    ":tests",
     "//services/asset_bundle",
     "//services/authenticating_url_loader_interceptor",
     "//services/authentication",
@@ -48,9 +51,48 @@
     deps += [ "//services/python" ]
   }
 
+  # TODO(jamesr): We only support building V8 snapshot data on a linux host
+  # since it needs a 32 bit toolchain and we don't have one configured for mac
+  # hosts.
+  if (host_os == "linux") {
+    deps += [ "//services/js" ]
+  }
+}
+
+group("tests") {
+  testonly = true
+
+  deps = [
+    "//services/asset_bundle:apptests",
+    "//services/authenticating_url_loader_interceptor:apptests",
+    "//services/clipboard:apptests",
+    "//services/dart/dart_apptests",
+    "//services/files:apptests",
+    "//services/http_server:apptests",
+    "//services/prediction:apptests",
+    "//services/reaper:tests",
+    "//services/url_response_disk_cache:tests",
+    "//services/view_manager:mojo_view_manager_client_apptests",
+    "//services/view_manager:view_manager_service_apptests",
+    "//services/view_manager:view_manager_service_unittests",
+    "//services/window_manager:window_manager_apptests",
+    "//services/window_manager:window_manager_unittests",
+  ]
+
+  if (is_linux) {
+    deps += [ "//services/python:python_apptests" ]
+  }
+
+  if (is_android) {
+    deps += [ "//services/notifications:apptests" ]
+  }
+
   # TODO(jamesr): We only support building V8 snapshot data on a linux host since it
   # needs a 32 bit toolchain and we don't have one configured for mac hosts.
   if (host_os == "linux") {
-    deps += [ "//services/js" ]
+    deps += [
+      "//services/js:js_apptests",
+      "//services/js:js_services_unittests",
+    ]
   }
 }
diff --git a/shell/BUILD.gn b/shell/BUILD.gn
index 383dda5..e0e7919 100644
--- a/shell/BUILD.gn
+++ b/shell/BUILD.gn
@@ -33,6 +33,7 @@
 group("tests") {
   testonly = true
   deps = [
+    ":apptests",
     ":mojo_shell_tests",
     ":shell_nfc_apptests",
     "//shell/application_manager:mojo_application_manager_unittests",