diff --git a/.gn b/.gn index 5ebbd9a0939de56e469be4d6f5dd8a708ad5fdc9..d996d6a9b4e71c679ece1b6531208d18a3cea814 100644 --- a/.gn +++ b/.gn @@ -14,9 +14,6 @@ buildconfig = "//build/config/BUILDCONFIG.gn" # 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 0000000000000000000000000000000000000000..52f40bbc7c585598fad4f7fd22c14ce2a10c4043 --- /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 b537d8a5ed145c06b581552c69b0ecbce6ac7714..0d0995ccba4f7f47a68353b9270f0f6f1b09d4ac 100644 --- a/build/gn/BUILD.gn +++ b/build/gn/BUILD.gn @@ -6,56 +6,11 @@ import("//build/compiled_action.gni") 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("default") { } 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 @@ compiled_action("package_archive") { "//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")