From 8615037c4ca14cd04d1bddfe28afd57537a6a277 Mon Sep 17 00:00:00 2001 From: Chong Gu Date: Wed, 5 May 2021 03:21:02 +0000 Subject: [PATCH] [Fuchsia] Switch CIPD targets to use SDK provided template. Switch to use fuchsia_cipd_package template provided by the Fuchsia SDK. (cherry picked from commit 4493482287e4569c96423c315816a7bfdb33209f) Bug: 1199847 Change-Id: I678911339f748e01a9d6fc5776a13997f262bdc5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2871551 Reviewed-by: David Dorwin Commit-Queue: David Dorwin Cr-Original-Commit-Position: refs/heads/master@{#879187} Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2872999 Commit-Queue: Srinivas Sista Commit-Queue: Rubber Stamper Owners-Override: Srinivas Sista Auto-Submit: Srinivas Sista Bot-Commit: Rubber Stamper Cr-Commit-Position: refs/branch-heads/4498@{#2} Cr-Branched-From: e7262eacc73c652b86da6ac7004b823966b247dd-refs/heads/master@{#879147} --- fuchsia/cipd/BUILD.gn | 173 +++++++++++++++++++++--------------------- 1 file changed, 85 insertions(+), 88 deletions(-) diff --git a/fuchsia/cipd/BUILD.gn b/fuchsia/cipd/BUILD.gn index ecea1d7cd61cd..cf5a91ff526c7 100644 --- a/fuchsia/cipd/BUILD.gn +++ b/fuchsia/cipd/BUILD.gn @@ -9,6 +9,7 @@ assert(is_fuchsia) import("//build/cipd/cipd.gni") import("//build/util/process_version.gni") import("//third_party/fuchsia-sdk/sdk/build/build_id_dir.gni") +import("//third_party/fuchsia-sdk/sdk/build/cipd.gni") # gn binary location. if (host_os == "mac") { @@ -30,56 +31,48 @@ process_version("build_id") { process_only = true } -# Prepares a CIPD archive and generates a manifest file. +if (target_cpu == "x64") { + targetarch = "amd64" +} else { + targetarch = "arm64" +} + +# Prepares a CIPD archive, produces a corresponding LICENSE file and generates +# a manifest file. # # Parameters: # package_basename: Determines the package basename in CIPD. -# package_definition_basename: The non-extension portion of the filename used -# for the generated CIPD YAML file. Defaults to -# package_basename. # package_relative_path: Specify the package location relative to the fuchsia/ # CIPD subdirectory. Defaults to a package name # based on package_basename. -# description: Sets the "description" field in CIPD metadata. -# install_mode: String, should be either "symlink" or "copy". -# deps: A list of targets to build prior to copying files. -# sources: A list of files to copy into the staging root. -# source_directories: A list of directories to include in the package. -template("cipd_archive_internal") { +# description: Sets the "description" field in CIPD package definition. +# +# Optional parameters used directly by fuchsia_cipd_package template: +# "package_root", +# "package_definition_name", +# "package_definition_dir", +# "install_mode", +# "files", +# "directories", +# "sources", + +template("cipd_archive") { forward_variables_from(invoker, [ - "deps", "package_basename", - "package_definition_basename", "package_relative_path", - "source_directories", + "package_root", + "package_definition_name", + "package_definition_dir", + "description", + "install_mode", + "files", + "directories", "sources", + "deps", "testonly", + "visibility", ]) - if (!defined(package_definition_basename)) { - package_definition_basename = package_basename - } - - if (!defined(package_relative_path)) { - if (target_cpu == "x64") { - targetarch = "amd64" - } else { - targetarch = "arm64" - } - package_relative_path = "${package_basename}-$targetarch" - } - - if (invoker.is_internal) { - package = "chrome_internal/fuchsia/" + package_relative_path - - # '_google' is appended to the YAML file for internal binaries. - # TODO (crbug.com/1169400): Remove this once we have separate builders - # for internal and public WebEngine. - package_definition_yaml = package_definition_basename + "_google.yaml" - } else { - package = "chromium/fuchsia/" + package_relative_path - package_definition_yaml = package_definition_basename + ".yaml" - } # Produces a consolidated license file. action("${target_name}_license") { @@ -109,52 +102,41 @@ template("cipd_archive_internal") { } sources += get_target_outputs(":${target_name}_license") - cipd_package_definition(target_name) { - forward_variables_from(invoker, - [ - "description", - "install_mode", - "package", - "package_definition_yaml", - ]) - } -} + fuchsia_cipd_package(target_name) { + if (!defined(package_relative_path)) { + package_relative_path = "${package_basename}-$targetarch" + } -# This template allows built binaries to be saved to both the internal and -# public CIPD directory. -# TODO (crbug.com/1169400): Remove this template once we have separate builders -# for internal and public WebEngine. -template("cipd_archive") { - cipd_archive_internal("${target_name}") { - is_internal = false - forward_variables_from(invoker, - [ - "package_basename", - "package_definition_basename", - "package_relative_path", - "description", - "source_directories", - "install_mode", - "deps", - "sources", - "testonly", - ]) + package = "chromium/fuchsia/${package_relative_path}" + + if (!defined(package_definition_name)) { + package_definition_name = "${target_name}.yaml" + } + + # Always use absolute path. + use_absolute_root_path = true } - cipd_archive_internal("${target_name}_google") { - is_internal = true - forward_variables_from(invoker, - [ - "package_basename", - "package_definition_basename", - "package_relative_path", - "description", - "source_directories", - "install_mode", - "deps", - "sources", - "testonly", - ]) + # TODO (crbug.com/1169400): Remove this target when Fuchsia side is ready to + # transition. + fuchsia_cipd_package("${target_name}_google") { + if (!defined(package_relative_path)) { + if (target_cpu == "x64") { + targetarch = "amd64" + } else { + targetarch = "arm64" + } + package_relative_path = "${package_basename}-$targetarch" + } + + package = "chrome_internal/fuchsia/${package_relative_path}" + + if (!defined(package_definition_name)) { + package_definition_name = "${target_name}.yaml" + } + + # Always use absolute path. + use_absolute_root_path = true } } @@ -229,7 +211,6 @@ action("strip_chromedriver_binary") { } cipd_archive("chromedriver") { - package_basename = "chromedriver" package_relative_path = "chromedriver/\${os}-\${arch}" description = "Prebuilt Chromedriver binary for Fuchsia host." install_mode = "copy" @@ -288,6 +269,8 @@ cipd_archive("tests") { # .build_id structure for CIPD archival. _build_ids_target = "debug_symbol_directory" _debug_symbols_archive_name = "debug_symbols" +_debug_symbols_outdir = + "${target_gen_dir}/${_debug_symbols_archive_name}/${_build_ids_target}" build_id_dir(_build_ids_target) { build_id_dirs = [ @@ -295,8 +278,8 @@ build_id_dir(_build_ids_target) { "${root_gen_dir}/fuchsia/runners/cast_runner", "${root_gen_dir}/fuchsia/runners/web_runner", ] - output_path = - "${target_gen_dir}/${_debug_symbols_archive_name}/${target_name}" + + output_path = _debug_symbols_outdir deps = [ "//fuchsia/engine:web_engine", "//fuchsia/runners:cast_runner_pkg", @@ -304,18 +287,32 @@ build_id_dir(_build_ids_target) { ] } -cipd_archive(_debug_symbols_archive_name) { - package_basename = "debug-symbols" - package_definition_basename = _debug_symbols_archive_name +fuchsia_cipd_package(_debug_symbols_archive_name) { + package = "chromium/fuchsia/debug-symbols-${targetarch}" + package_root = _debug_symbols_outdir + package_definition_name = "${target_name}.yaml" + package_definition_dir = "${target_gen_dir}/${target_name}" + description = "Debugging symbols for prebuilt binaries from Chromium." + use_absolute_root_path = true + + directories = [ "." ] + deps = [ ":${_build_ids_target}" ] +} + +fuchsia_cipd_package("${_debug_symbols_archive_name}_google") { + package = "chrome_internal/fuchsia/debug-symbols-${targetarch}" + package_root = _debug_symbols_outdir + package_definition_name = "${target_name}.yaml" + package_definition_dir = "${target_gen_dir}/${_debug_symbols_archive_name}" description = "Debugging symbols for prebuilt binaries from Chromium." + use_absolute_root_path = true + directories = [ "." ] deps = [ ":${_build_ids_target}" ] - source_directories = [ "${_build_ids_target}" ] } cipd_archive("clear_key_cdm") { package_basename = "libclearkeycdm" - package_definition_basename = "clear_key_cdm" description = "Prebuilt libclearkeycdm.so binary for Fuchsia." testonly = true