| # 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/host.gni") |
| import("//build/packages/prebuilt_test_manifest.gni") |
| import("//src/chromium/build_args.gni") |
| import("//src/chromium/generate_pkg_and_config.gni") |
| import("//src/lib/icu/tzdata/icu_tzdata_config_data.gni") |
| import("//src/sys/core/build/core_shard.gni") |
| |
| declare_args() { |
| # TODO(crbug.com/1065707): Revert to declaring this in the BUILD.gn file once |
| # the use in here is removed. |
| use_chromium_canary = false |
| } |
| |
| prebuilt_archive_root_path = "//prebuilt/third_party" |
| build_output_gen_base_path = "/gen" |
| |
| # Generates targets for Chrome browser prebuilts. |
| # |
| # Parameters |
| # |
| # repository (optional; string; default: "chromium.org") |
| # The repository host name part of the package URL. |
| # See https://fuchsia.dev/fuchsia-src/concepts/packages/package_url#repository |
| # for more details. |
| # |
| # available_flavors (optional) |
| # Must be set if and only if `default_flavor` is set. |
| # See `flavors` in the `prebuilt_package_with_flavors()` documentation. |
| # |
| # default_flavor (optional; string) |
| # The name of the default flavor in available_flavors to use if not overridden. |
| # Must be set if and only if `flavors` is set. |
| # See `default` in the `prebuilt_package_with_flavors()` documentation. |
| template("generate_chrome_browser_targets") { |
| # Default visibility for targets generated by this template. |
| visibility = [] |
| not_needed([ "target_name" ]) |
| |
| # This target is provided for use by the Workstation product, which cannot be |
| # conditioned on `target_cpu` because that is not set in the product config. |
| # TODO(crbug.com/1320078): If arm64 builds become available, remove this |
| # target and the `target_cpu` condition below it. |
| group("chrome_browser_if_available") { |
| visibility += [ |
| "//:legacy_cache_packages", # Used by workstation_base.gni. |
| ] |
| |
| if (target_cpu == "x64") { |
| deps = [ ":chrome_browser" ] |
| } |
| } |
| |
| if (target_cpu == "x64") { |
| # TODO(fxbug.dev/70573): Remove this once flavors are selected at a higher |
| # level than the chromium BUILD.gn and thus before this file is imported. |
| package_flavor_selections += invoker.package_flavor_selections |
| |
| # The flavor override must use the slightly different name "chrome_pkg". |
| group("chrome_browser") { |
| visibility += [ "*" ] |
| deps = [ |
| ":chrome_pkg", |
| ":tzdata_for_chrome", |
| ] |
| } |
| |
| icu_tzdata_config_data("tzdata_for_chrome") { |
| visibility += [ ":chrome_browser" ] |
| for_pkg = "chrome" |
| } |
| |
| # Always use the custom build when the GN arg is specified. |
| if (chromium_build_dir != "") { |
| print("Using Chrome browser prebuilts from ", chromium_build_dir) |
| package_flavor_selections += [ |
| { |
| name = "chrome_pkg" |
| flavor = "custom" |
| }, |
| ] |
| } |
| |
| # Generates ":chrome_pkg". |
| generate_package_flavors("chrome") { |
| visibility += [ ":chrome_browser" ] |
| |
| custom_package_path = |
| "${build_output_gen_base_path}/chrome/app/chrome/chrome.far" |
| selections = package_flavor_selections |
| |
| assert( |
| defined(invoker.available_flavors) == |
| defined(invoker.default_flavor) && |
| defined(invoker.available_flavors) == defined(invoker.repository), |
| "Either all or none of `available_flavors`, `default_flavor`, and `repository` must be defined.") |
| if (defined(invoker.available_flavors)) { |
| not_needed([ "target_name" ]) |
| repository = invoker.repository |
| default_flavor = invoker.default_flavor |
| available_flavors = invoker.available_flavors |
| } else { |
| prebuilt_archive_base_path = "${prebuilt_archive_root_path}/chrome" |
| repository = "chromium.org" |
| |
| # Only the Canary flavor is available in fuchsia.git. |
| default_flavor = "canary" |
| available_flavors = [ |
| { |
| name = "canary" |
| archive = "${prebuilt_archive_base_path}_latest/arch/${target_cpu}/${target_name}.far" |
| }, |
| ] |
| } |
| } |
| } else { |
| not_needed([ "invoker" ]) |
| not_needed([ "repository" ]) |
| not_needed([ "available_flavors" ]) |
| not_needed([ "default_flavor" ]) |
| } |
| } |
| |
| # Generates targets for WebEngine prebuilts. |
| # |
| # Parameters |
| # |
| # archive_path_suffix (required) |
| # Appended to the innermost folder of the base paths passed into the |
| # `generate_package_flavors()` template. |
| # |
| # repository (required; string; default: "fuchsia.com") |
| # The repository host name part of the package URL. |
| # See https://fuchsia.dev/fuchsia-src/concepts/packages/package_url#repository |
| # for more details. |
| # TODO(crbug.com/1385930): Change this to "chromium.org". |
| template("generate_fuchsia_web_targets") { |
| # Default visibility for targets generated by this template. |
| visibility = [] |
| assert(defined(invoker.archive_path_suffix)) |
| assert(defined(invoker.repository)) |
| not_needed([ "target_name" ]) |
| |
| # TODO(fxbug.dev/70573): Remove this once flavors are selected at a higher |
| # level than the chromium BUILD.gn and thus before this file is imported. |
| package_flavor_selections += invoker.package_flavor_selections |
| |
| repository = invoker.repository |
| |
| # Always use the custom build when the GN arg is specified. |
| if (chromium_build_dir != "") { |
| print("Using fuchsia.web prebuilts from ", chromium_build_dir) |
| package_flavor_selections += [ |
| { |
| name = "web_engine_pkg" |
| flavor = "custom" |
| }, |
| ] |
| } |
| |
| # WebEngine - a Chromium implementation of `fuchsia.web`. |
| # Only Products that want to include WebEngine should depend on this target. |
| # Legacy in-tree tests depend on ":web_context_provider_for_test" below. |
| group("web_engine") { |
| visibility += [ |
| # Allow developers to include it using `--with-cache` or `--with`. |
| # This has a side effect of allowing in-tree //products to include it due |
| # to the way they are currently assembled. |
| "//:developer_cache_packages", |
| "//:developer_universe_packages", |
| |
| # TODO(fxbug.dev/119075): Remove when deps is removed from |
| # //products/terminal.gni. |
| "//:legacy_cache_packages", |
| |
| # Allow buildbot bundles to include it so that tests can be run. |
| "//bundles/buildbot/*", |
| |
| # Allow any out-of-tree Product to include it. (This also allows |
| # out-of-tree tests to depend on it, though that is discouraged.) |
| "//vendor/*", |
| ] |
| deps = [ |
| ":tzdata_for_web_engine", |
| ":web_engine_pkg", |
| ] |
| } |
| |
| # Used by integration tests to indicate they need WebEngine, specifically the |
| # `context_provider.cm` Component, in the Products on which they run. It has |
| # no effect. |
| # TODO(fxbug.dev/119212): Remove once a better solution is available. |
| group("web_context_provider_for_test") { |
| # No new tests relying on WebEngine should be added in tree. |
| visibility += [ |
| # TODO(crbug.com/1443083): Remove the following line once |
| # ":chromium_web_engine_tests" no longer depend on the system WebEngine. |
| ":*", |
| "//src/chromium/web_runner_tests/*", |
| "//src/testing/system-validation:*", |
| "//src/ui/a11y/lib/semantics/tests:*", |
| "//src/ui/tests/integration_graphics_tests/web-pixel-tests:*", |
| "//src/ui/tests/integration_input_tests/mouse/*", |
| "//src/ui/tests/integration_input_tests/text-input//*", |
| "//src/ui/tests/integration_input_tests/touch/*", |
| "//src/ui/tests/integration_input_tests/virtual-keyboard/*", |
| "//src/ui/tests/integration_input_tests/web-touch-input/*", |
| ] |
| testonly = true |
| } |
| |
| # Generates ":web_engine_pkg". |
| generate_fuchsia_web_package_flavors("web_engine") { |
| # Prevent dependencies on the package other than ":web_engine", which has |
| # a specific visibility list. |
| visibility += [ ":web_engine" ] |
| |
| prebuilt_archive_base_path = "${prebuilt_archive_root_path}/${target_name}${invoker.archive_path_suffix}" |
| custom_package_path = "${build_output_gen_base_path}/fuchsia_web/webengine/${target_name}/${target_name}.far" |
| selections = package_flavor_selections |
| } |
| |
| # TODO(crbug.com/1385930): Templatize the shard file to allow specification of |
| # the `repo-hostname` and replace all other instances of similar build rules. |
| core_shard("web_context_provider_core_shard") { |
| visibility += [ ":web_engine_PKG" ] |
| shard_file = "config/web_context_provider.core_shard.cml" |
| } |
| |
| icu_tzdata_config_data("tzdata_for_web_engine") { |
| visibility += [ ":web_engine" ] |
| for_pkg = "web_engine" |
| } |
| } |
| |
| # Generates targets for prebuilts used for testing WebEngine. |
| # |
| # Parameters |
| # |
| # archive_path_suffix (required) |
| # Appended to the innermost folder of the base paths passed into the |
| # ` ()` template. |
| # |
| # repository (required; string; default: "fuchsia.com") |
| # The repository host name part of the package URL. |
| # See https://fuchsia.dev/fuchsia-src/concepts/packages/package_url#repository |
| # for more details. |
| # TODO(crbug.com/1385930): Change this to "chromium.org". |
| template("generate_fuchsia_web_test_targets") { |
| # Default visibility for targets generated by this template. |
| visibility = [] |
| assert(defined(invoker.archive_path_suffix)) |
| assert(defined(invoker.repository)) |
| not_needed([ "target_name" ]) |
| |
| # TODO(fxbug.dev/70573): Remove this once flavors are selected at a higher |
| # level than the chromium BUILD.gn and thus before this file is imported. |
| package_flavor_selections += invoker.package_flavor_selections |
| |
| repository = invoker.repository |
| |
| # Always use the custom build when the GN arg is specified. |
| if (chromium_build_dir != "") { |
| print("Using fuchsia.web test prebuilts from ", chromium_build_dir) |
| package_flavor_selections += [ |
| { |
| name = "web_engine_shell_pkg" |
| flavor = "custom" |
| }, |
| ] |
| } |
| |
| group("web_engine_shell") { |
| visibility += [ "*" ] |
| deps = [ ":web_engine_shell_pkg" ] |
| testonly = true |
| } |
| |
| # Generates ":web_engine_shell_pkg". |
| generate_fuchsia_web_package_flavors("web_engine_shell") { |
| visibility += [ ":web_engine_shell" ] |
| |
| prebuilt_archive_base_path = "${prebuilt_archive_root_path}/${target_name}${invoker.archive_path_suffix}" |
| custom_package_path = "${build_output_gen_base_path}/fuchsia_web/shell/${target_name}/${target_name}.far" |
| selections = package_flavor_selections |
| |
| testonly = true |
| } |
| } |
| |
| if (is_host) { |
| if (host_os == "linux" && host_cpu == "x64") { |
| # Generates targets for ChromeDriver prebuilt. |
| # |
| # Parameters |
| # |
| # archive_path_suffix (required) |
| # Appended to the innermost folder of the base paths passed into the |
| # `generate_package_flavors()` template. |
| template("generate_host_targets") { |
| # Default visibility for targets generated by this template. |
| visibility = [ ":*" ] |
| assert(defined(invoker.archive_path_suffix)) |
| not_needed([ "target_name" ]) |
| |
| copy("chromedriver") { |
| visibility += [ "*" ] |
| outputs = [ "${host_tools_dir}/chromedriver" ] |
| sources = [ "${prebuilt_archive_root_path}/chromedriver${invoker.archive_path_suffix}/${host_os}-${host_cpu}/chromedriver" ] |
| } |
| } |
| } |
| } else if (current_cpu == "riscv64") { |
| # The real generate_test_targets() definition below fails at `gn gen` time |
| # because prebuilt_test_manifest() uses read_file() to parse a manifest |
| # file that does not exist for riscv64 yet. |
| # |
| # TODO(fxbug.dev/121729): Provide riscv64 Chromium prebuilts |
| # Alternatively, move this check up in the dependency chain |
| template("generate_test_targets") { |
| visibility = [ ":*" ] |
| not_needed([ "target_name" ]) |
| not_needed(invoker, "*") |
| group("tests") { |
| } |
| } |
| } else { |
| # Generates targets for Chromium test prebuilts and manifests. |
| # |
| # Parameters |
| # |
| # archive_path_suffix (required) |
| # Appended to the innermost folder of the base paths passed into the |
| # `generate_package_flavors()` template. |
| template("generate_test_targets") { |
| # Default visibility for targets generated by this template. |
| visibility = [ ":*" ] |
| assert(defined(invoker.archive_path_suffix)) |
| not_needed([ "target_name" ]) |
| |
| # Configure groups of prebuilt tests from Chromium. |
| |
| default_test_environments = [ |
| atlas_env, |
| nuc_env, |
| ] |
| |
| archive_dir = "${prebuilt_archive_root_path}/web_engine_tests${invoker.archive_path_suffix}/arch/${target_cpu}" |
| |
| # The specific tests binaries are specified by the "tests" target in |
| # https://source.chromium.org/chromium/chromium/src/+/main:build/fuchsia/cipd/BUILD.gn. |
| prebuilt_test_manifest("chromium_common_tests") { |
| manifest_name = "common_tests_manifest.json" |
| environments = default_test_environments |
| log_settings = { |
| max_severity = "ERROR" |
| } |
| deps = [ |
| ":chromium_test_base_deps", |
| |
| # The targets below have exactly the same contents, so will not be taking |
| # extra storage in configurations that use them both. |
| ":tzdata_for_base_unittests", |
| ":tzdata_for_media_unittests", |
| ] |
| } |
| |
| prebuilt_test_manifest("chromium_web_engine_tests") { |
| manifest_name = "web_engine_tests_manifest.json" |
| environments = default_test_environments |
| log_settings = { |
| max_severity = "ERROR" |
| } |
| deps = [ |
| ":chromium_test_base_deps", |
| |
| # Currently, `web_engine_integration_tests` uses an absolute URL for |
| # `web_instance.cm`, so these tests require that `web_engine` in the |
| # Product. TODO(crbug.com/1443083): Update based on outcome of the bug. |
| ":web_context_provider_for_test", |
| ] |
| } |
| |
| # TODO(fxrev.dev/769058): Remove once fxbug.dev/117321 is fixed. |
| prebuilt_test_manifest("chromium_cast_runner_tests") { |
| manifest_name = "cast_runner_tests_manifest.json" |
| environments = [ nuc_env ] |
| log_settings = { |
| max_severity = "ERROR" |
| } |
| deps = [ ":chromium_test_base_deps" ] |
| } |
| |
| icu_tzdata_config_data("tzdata_for_base_unittests") { |
| for_pkg = "base_unittests" |
| testonly = true |
| } |
| |
| icu_tzdata_config_data("tzdata_for_media_unittests") { |
| for_pkg = "media_unittests" |
| testonly = true |
| } |
| |
| # This target is provided for use by //src:test* targets. Dependencies on |
| # Chromium tests should reference specific target(s). |
| group("tests") { |
| testonly = true |
| |
| # TODO(fxbug.dev/108563): Remove //bundles/buildbot/dfv2:core when |
| # //bundles/buildbot/dfv2:core does not directly depend on |
| # //src/chromium:tests |
| visibility += [ |
| "//bundles/buildbot/dfv2/core", |
| "//src:*", |
| ] |
| |
| deps = [ |
| ":chromium_cast_runner_tests", |
| ":chromium_common_tests", |
| ":chromium_web_engine_tests", |
| ":web_engine_shell", |
| "web_runner_tests:tests", |
| "//src/fonts:downstream_test_deps", |
| ] |
| } |
| } |
| } |