[gn] Add top-level BUILD.gn and forwarding targets to //build/gn:*
This adds a top-level BUILD.gn file and defines it as the root (by
removing the root_build override in //.gn) and adds forwarding rules to
the top-level target definitions in //build/gn/BUILD.gn. Also moves the
file generation steps to the top level BUILD.gn file.
The other rules in //build/gn/BUILD.gn should move too, but they are
currently referred to by infrastructure configuration files. They can
move after this lands and rolls to GI and the infra configs are updated.
Change-Id: I2043cc507944158cfe691db884d9fc79c2e80cc4
diff --git a/.gn b/.gn
index 5ebbd9a..d996d6a 100644
--- a/.gn
+++ b/.gn
@@ -14,9 +14,6 @@
# in the source tree, e.g. for third party source trees.
secondary_source = "//build/secondary/"
-# The source root location.
-root = "//build/gn"
-
# The executable used to execute scripts in action and exec_script.
script_executable = "/usr/bin/env"
diff --git a/BUILD.gn b/BUILD.gn
new file mode 100644
index 0000000..52f40bb
--- /dev/null
+++ b/BUILD.gn
@@ -0,0 +1,110 @@
+# Copyright 2019 The Fuchsia Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/fuchsia/zircon.gni")
+import("//build/testing/platforms.gni")
+
+# Collect the source files that are dependencies of the create_gn_rules.py
+# script, below. Unfortunately, exec_script cannot use a depfile produced
+# by the script and only supports a separately computed list of dependencies.
+zircon_files =
+ exec_script("//build/zircon/list_source_files.py", [], "list lines")
+
+supporting_templates = [
+ "//build/zircon/boards.mako",
+ "//build/zircon/header.mako",
+ "//build/zircon/host_tool.mako",
+ "//build/zircon/main.mako",
+ "//build/zircon/shared_library.mako",
+ "//build/zircon/source_library.mako",
+ "//build/zircon/static_library.mako",
+ "//build/zircon/sysroot.mako",
+]
+
+# The following script generates GN build files for Zircon objects. It is
+# placed before everything else so that //zircon targets are available in
+# due time. See //build/zircon/README.md for more details.
+exec_script("//build/zircon/create_gn_rules.py",
+ [
+ "--out",
+ rebase_path("//zircon/public"),
+ "--zircon-build",
+ rebase_path(zircon_root_build_dir),
+ "--zircon-manifest",
+ rebase_path("$zircon_root_build_dir/export/manifest-$target_cpu"),
+ ],
+ "",
+ zircon_files + supporting_templates)
+
+# Write a file that can be sourced by `fx`. This file is produced
+# by `gn gen` and is not known to Ninja at all, so it has nothing to
+# do with the build itself. Its sole purpose is to leave bread
+# crumbs about the settings `gn gen` used for `fx` to use later.
+_relative_build_dir = rebase_path(root_build_dir, "//", "//")
+_fx_config_lines = [
+ "# Generated by `gn gen`.",
+ "FUCHSIA_BUILD_DIR='${_relative_build_dir}'",
+ "FUCHSIA_ARCH='${target_cpu}'",
+]
+write_file("$root_build_dir/fx.config", _fx_config_lines)
+
+# Forwarding targets to things defined in //build/gn that are referred to by
+# infrastructure.
+# TODO(jamesr): Move definition from //build/gn to here after updating infra.
+
+# Permit dependencies on testonly targets from packages.
+testonly = true
+
+group("default") {
+ public_deps = [
+ "//build/gn:default",
+ ]
+}
+
+group("host_tests") {
+ visibility = []
+ public_deps = [
+ "//build/gn:host_tests",
+ ]
+}
+
+group("tests") {
+ public_deps = [
+ "//build/gn:tests",
+ ]
+}
+
+group("pseudo_tests") {
+ public_deps = [
+ "//build/gn:pseudo_tests",
+ ]
+}
+
+group("copy_host_tests") {
+ public_deps = [
+ "//build/gn:copy_host_tests",
+ ]
+}
+
+group("breakpad_symbols") {
+ public_deps = [
+ "//build/gn:breakpad_symbols",
+ ]
+}
+
+group("package_archive") {
+ public_deps = [
+ "//build/gn:package_archive",
+ ]
+}
+
+# Generates a JSON manifest of the platforms available for testing, along with
+# their properties.
+target_platforms = []
+foreach(platform, test_platforms) {
+ if (!defined(platform.cpu) || platform.cpu == current_cpu) {
+ target_platforms += [ platform ]
+ }
+}
+write_file("$root_build_dir/platforms.json", target_platforms, "json")
diff --git a/build/gn/BUILD.gn b/build/gn/BUILD.gn
index b537d8a..0d0995c 100644
--- a/build/gn/BUILD.gn
+++ b/build/gn/BUILD.gn
@@ -6,56 +6,11 @@
import("//build/config/fuchsia/zircon.gni")
import("//build/gn/packages.gni")
import("//build/package.gni")
-import("//build/testing/platforms.gni")
import("//build/toolchain/goma.gni")
# Permit dependencies on testonly targets from packages.
testonly = true
-# Collect the source files that are dependencies of the create_gn_rules.py
-# script, below. Unfortunately, exec_script cannot use a depfile produced
-# by the script and only supports a separately computed list of dependencies.
-zircon_files =
- exec_script("//build/zircon/list_source_files.py", [], "list lines")
-
-supporting_templates = [
- "//build/zircon/boards.mako",
- "//build/zircon/header.mako",
- "//build/zircon/host_tool.mako",
- "//build/zircon/main.mako",
- "//build/zircon/shared_library.mako",
- "//build/zircon/source_library.mako",
- "//build/zircon/static_library.mako",
- "//build/zircon/sysroot.mako",
-]
-
-# The following script generates GN build files for Zircon objects. It is
-# placed before everything else so that //zircon targets are available in
-# due time. See //build/zircon/README.md for more details.
-exec_script("//build/zircon/create_gn_rules.py",
- [
- "--out",
- rebase_path("//zircon/public"),
- "--zircon-build",
- rebase_path(zircon_root_build_dir),
- "--zircon-manifest",
- rebase_path("$zircon_root_build_dir/export/manifest-$target_cpu"),
- ],
- "",
- zircon_files + supporting_templates)
-
-# Write a file that can be sourced by `fx`. This file is produced
-# by `gn gen` and is not known to Ninja at all, so it has nothing to
-# do with the build itself. Its sole purpose is to leave bread
-# crumbs about the settings `gn gen` used for `fx` to use later.
-_relative_build_dir = rebase_path(root_build_dir, "//", "//")
-_fx_config_lines = [
- "# Generated by `gn gen`.",
- "FUCHSIA_BUILD_DIR='${_relative_build_dir}'",
- "FUCHSIA_ARCH='${target_cpu}'",
-]
-write_file("$root_build_dir/fx.config", _fx_config_lines)
-
group("default") {
deps = [
":copy_host_tests",
@@ -70,11 +25,20 @@
}
group("host_tests") {
- visibility = [ ":*" ]
+ visibility = [
+ ":*",
+ "//:host_tests",
+ ]
public_deps = []
foreach(label, package_host_tests) {
public_deps += [ "$label($host_toolchain)" ]
}
+ deps = [
+ # Currently host tests dependencies wind up as dependencies of the packages.
+ # TODO: We should more cleanly separate host targets (including tests) from
+ # packages.
+ "//build/images:packages",
+ ]
}
# TODO(joshuaseaton|mcgrathr): Make this a formal build_api_module.
@@ -221,13 +185,3 @@
"//build/images:updates",
]
}
-
-# Generates a JSON manifest of the platforms available for testing, along with
-# their properties.
-target_platforms = []
-foreach(platform, test_platforms) {
- if (!defined(platform.cpu) || platform.cpu == current_cpu) {
- target_platforms += [ platform ]
- }
-}
-write_file("$root_build_dir/platforms.json", target_platforms, "json")