Commit e007e95c authored by Erik Staab's avatar Erik Staab Committed by Commit Bot

Add generic template for creating a CIPD package definition file.

Bug: 1042819
Change-Id: If9dc84c5a7c5da5e1597b8ae030cab43ea269cdc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2006139Reviewed-by: default avatarKevin Marshall <kmarshall@chromium.org>
Reviewed-by: default avatarJohn Budorick <jbudorick@chromium.org>
Commit-Queue: Erik Staab <estaab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736064}
parent 289815c7
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Build targets for constructing CIPD packages.
#
# Prepares a CIPD archive and generates a manifest file.
#
# TODO(crbug.com/1042819): Add support for including directories.
#
# Parameters:
# package_definition_yaml: CIPD package definition filename. "cipd.yaml"
# if unspecified.
# package: The path where the package will be located inside the CIPD
# repository.
# description: Sets the "description" field in CIPD package definition.
# install_mode: String, should be either "symlink" or "copy". Defaults to
# "symlink".
# deps: A list of targets to build prior to copying files.
# sources: A list of files to copy into the staging root.
#
# Example:
# cipd_package_definition("chromedriver") {
# package = "path/to/cipd/package"
# description = "Prebuilt test binary."
# install_mode = "copy"
# deps = [ "//path/to:test_binary_target" ]
# sources = [ "//path/to:test_binary_file" ]
# }
#
template("cipd_package_definition") {
forward_variables_from(invoker,
[
"deps",
"data",
"data_deps",
"sources",
"testonly",
])
assert(defined(invoker.sources), "sources must be specified.")
_install_mode = "symlink"
if (defined(invoker.install_mode)) {
_install_mode = invoker.install_mode
}
assert(_install_mode == "copy" || _install_mode == "symlink",
"\"install_mode\" arg should be either \"copy\" or \"symlink\".")
_cipd_definition_yaml = "cipd.yaml"
if (defined(invoker.package_definition_yaml)) {
_cipd_definition_yaml = invoker.package_definition_yaml
}
_package_staging_dir = "${target_gen_dir}/${target_name}"
_yaml_contents = [
"package: ${invoker.package}",
"description: ${invoker.description}",
"root: \${outdir}/" + rebase_path(_package_staging_dir, root_build_dir),
"install_mode: ${_install_mode}",
"data:",
]
foreach(source, sources) {
_yaml_contents += [ " - file: " + get_path_info(source, "file") ]
}
write_file("${_package_staging_dir}/${_cipd_definition_yaml}", _yaml_contents)
copy(target_name) {
outputs = [ "${_package_staging_dir}/{{source_file_part}}" ]
}
}
......@@ -6,6 +6,7 @@
assert(is_fuchsia)
import("//build/cipd/cipd.gni")
import("//build/util/process_version.gni")
# gn binary location.
......@@ -47,37 +48,20 @@ process_version("build_id") {
# Prepares a CIPD archive and generates a manifest file.
#
# Parameters:
# cipd_manifest_name: The filename to use for the generated CIPD YAML file.
# cipd_path: The path where the package will be located inside the CIPD
# repository.
# cipd_description: Sets the "description" field in CIPD metadata.
# package_definition_yaml: The filename to use for the generated CIPD YAML
# file.
# package: The path where the package will be located inside the CIPD
# repository.
# 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.
template("cipd_archive") {
forward_variables_from(invoker,
[
"cipd_manifest_name",
"cipd_path",
"cipd_description",
"install_mode",
"deps",
"sources",
])
archive_staging_dir = "${target_gen_dir}/${target_name}"
if (!defined(invoker.install_mode)) {
install_mode = "symlink"
}
assert(install_mode == "copy" || install_mode == "symlink",
"\"install_mode\" arg should be either \"copy\" or \"symlink\".")
yaml_contents = [
"package: ${cipd_path}",
"description: ${cipd_description}",
"root: \${outdir}/" + rebase_path(archive_staging_dir, root_build_dir),
"install_mode: ${install_mode}",
"data:",
" - file: LICENSE",
]
if (!defined(deps)) {
deps = []
......@@ -87,23 +71,27 @@ template("cipd_archive") {
":license",
]
foreach(source, sources) {
yaml_contents += [ " - file: " + get_path_info(source, "file") ]
if (!defined(sources)) {
sources = []
}
sources += get_target_outputs(":license")
write_file("${archive_staging_dir}/${cipd_manifest_name}", yaml_contents)
copy(target_name) {
cipd_package_definition(target_name) {
testonly = true
outputs = [ "${archive_staging_dir}/{{source_file_part}}" ]
forward_variables_from(invoker,
[
"description",
"install_mode",
"package",
"package_definition_yaml",
])
}
}
cipd_archive("webrunner") {
cipd_manifest_name = "webrunner.yaml"
cipd_path = "chromium/fuchsia/webrunner-\${targetarch}"
cipd_description = "Prebuilt Chrome and Web Runner binaries for Fuchsia."
package_definition_yaml = "webrunner.yaml"
package = "chromium/fuchsia/webrunner-\${targetarch}"
description = "Prebuilt Chrome and Web Runner binaries for Fuchsia."
deps = [
"//fuchsia/engine:web_engine",
......@@ -117,9 +105,9 @@ cipd_archive("webrunner") {
}
cipd_archive("castrunner") {
cipd_manifest_name = "castrunner.yaml"
cipd_path = "chromium/fuchsia/castrunner-\${targetarch}"
cipd_description = "Prebuilt Cast application Runner binaries for Fuchsia."
package_definition_yaml = "castrunner.yaml"
package = "chromium/fuchsia/castrunner-\${targetarch}"
description = "Prebuilt Cast application Runner binaries for Fuchsia."
deps = [ "//fuchsia/runners:cast_runner_pkg" ]
......@@ -127,9 +115,9 @@ cipd_archive("castrunner") {
}
cipd_archive("http") {
cipd_manifest_name = "http.yaml"
cipd_path = "chromium/fuchsia/http-\${targetarch}"
cipd_description = "Prebuilt HTTP service binary for Fuchsia."
package_definition_yaml = "http.yaml"
package = "chromium/fuchsia/http-\${targetarch}"
description = "Prebuilt HTTP service binary for Fuchsia."
deps = [ "//fuchsia/http:http_pkg" ]
......@@ -162,9 +150,9 @@ action("strip_chromedriver_binary") {
}
cipd_archive("chromedriver") {
cipd_manifest_name = "chromedriver.yaml"
cipd_path = "chromium/fuchsia/chromedriver/\${os}-\${arch}"
cipd_description = "Prebuilt Chromedriver binary for Fuchsia host."
package_definition_yaml = "chromedriver.yaml"
package = "chromium/fuchsia/chromedriver/\${os}-\${arch}"
description = "Prebuilt Chromedriver binary for Fuchsia host."
install_mode = "copy"
deps = [ ":strip_chromedriver_binary" ]
......@@ -173,9 +161,9 @@ cipd_archive("chromedriver") {
cipd_archive("tests") {
_manifest_path = "${target_gen_dir}/test_manifest.json"
cipd_manifest_name = "tests.yaml"
cipd_path = "chromium/fuchsia/tests-\${targetarch}"
cipd_description = "Prebuilt Chromium tests for Fuchsia."
package_definition_yaml = "tests.yaml"
package = "chromium/fuchsia/tests-\${targetarch}"
description = "Prebuilt Chromium tests for Fuchsia."
deps = [
"//base:base_unittests_pkg",
......@@ -217,9 +205,9 @@ cipd_archive("tests") {
}
cipd_archive("debug_symbols") {
cipd_manifest_name = "debug_symbols.yaml"
cipd_path = "chromium/fuchsia/debug-symbols-\${targetarch}"
cipd_description = "Debugging symbols for prebuilt binaries from Chromium."
package_definition_yaml = "debug_symbols.yaml"
package = "chromium/fuchsia/debug-symbols-\${targetarch}"
description = "Debugging symbols for prebuilt binaries from Chromium."
_symbol_tarballs = [
"${root_gen_dir}/fuchsia/engine/web_engine/web_engine.symbols.tar.bz2",
......@@ -243,9 +231,9 @@ cipd_archive("debug_symbols") {
}
cipd_archive("clear_key_cdm") {
cipd_manifest_name = "clear_key_cdm.yaml"
cipd_path = "chromium/fuchsia/libclearkeycdm-\${targetarch}"
cipd_description = "Prebuilt libclearkeycdm.so binary for Fuchsia."
package_definition_yaml = "clear_key_cdm.yaml"
package = "chromium/fuchsia/libclearkeycdm-\${targetarch}"
description = "Prebuilt libclearkeycdm.so binary for Fuchsia."
deps = [ "//media/cdm/library_cdm/clear_key_cdm:clear_key_cdm" ]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment