Commit e9ca13de authored by Wez's avatar Wez Committed by Commit Bot

Revert "[cipd] Refactor CIPD template"

This reverts commit 3d6123e3.

Reason for revert: Broke official desktop continuous builder, at least for Fuchsia (see https://crbug.com/1070174).

Original change's description:
> [cipd] Refactor CIPD template
> 
> Currently, a CIPD staging directory is populated by copying specified
> `sources` into it, and producing a .yaml manifest which reflects the
> copied files.
> 
> This change refactors the template to invoke a pytho script to do the
> above instead of in GN, using the `yaml` library to write the file data
> in the proper format.
> 
> Also make the license filepath explicitly passed through sources.
> 
> Renames "archive" -> "package" and "manifest" -> "package definition" to
> be consistent with CIPD semantics (crbug.com/1042819#c8).
> 
> Finally, have the script emit a depfile for all files tracked by the
> .yaml manifest.
> 
> This refactor is desirable, as we want to create CIPD packages with more
> complicated rules than simply "copy and include these files" (see
> crrev.com/c/1925446, which extends the functionality of the template to
> allow for the inclusion of directories). Wriiting yamls with a library
> reduces the error-proneness of trying to recreate yaml's format in pure
> GN.
> 
> Also, emitting a depfile ensure that we track and rebuild if the CIPD
> package is modified.
> 
> Currently the potential danger of this change is limited in scope to
> fuchsia, as they are the only users of the template. I've checked
> locally that the produced CIPD packages for fuchsia are identical prior
> to this change.
> 
> Bug: fuchsia:41443
> Change-Id: If1b27d6a8fbbffdf767aaa4230bf7b527a553170
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135186
> Commit-Queue: Anthony Fandrianto <atyfto@google.com>
> Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
> Reviewed-by: Kevin Marshall <kmarshall@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#758433}

TBR=kmarshall@chromium.org,brucedawson@chromium.org,joshuaseaton@google.com,atyfto@google.com

Change-Id: I68f850f43ca121c3dfb7f87d0ec68e7f96448d94
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: fuchsia:41443
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2144183Reviewed-by: default avatarWez <wez@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758489}
parent 1992b7fe
...@@ -4,12 +4,12 @@ ...@@ -4,12 +4,12 @@
# Build targets for constructing CIPD packages. # Build targets for constructing CIPD packages.
# #
# Prepares a CIPD package and generates a package definition. # Prepares a CIPD archive and generates a manifest file.
# #
# TODO(crbug.com/1042819): Add support for including directories. # TODO(crbug.com/1042819): Add support for including directories.
# #
# Parameters: # Parameters:
# package_definition_name: CIPD package definition filename. "cipd.yaml" # package_definition_yaml: CIPD package definition filename. "cipd.yaml"
# if unspecified. # if unspecified.
# package: The path where the package will be located inside the CIPD # package: The path where the package will be located inside the CIPD
# repository. # repository.
...@@ -47,33 +47,27 @@ template("cipd_package_definition") { ...@@ -47,33 +47,27 @@ template("cipd_package_definition") {
assert(_install_mode == "copy" || _install_mode == "symlink", assert(_install_mode == "copy" || _install_mode == "symlink",
"\"install_mode\" arg should be either \"copy\" or \"symlink\".") "\"install_mode\" arg should be either \"copy\" or \"symlink\".")
_package_definition_name = "cipd.yaml" _cipd_definition_yaml = "cipd.yaml"
if (defined(invoker.package_definition_name)) { if (defined(invoker.package_definition_yaml)) {
_package_definition_name = invoker.package_definition_name _cipd_definition_yaml = invoker.package_definition_yaml
} }
_package_root = "${target_gen_dir}/${target_name}" _package_staging_dir = "${target_gen_dir}/${target_name}"
action(target_name) { _yaml_contents = [
script = "//build/cipd/prepare_cipd_package_definition.py" "package: ${invoker.package}",
depfile = "$target_gen_dir/$target_name.d" "description: ${invoker.description}",
_definition_path = "${_package_root}/${_package_definition_name}" "root: \${outdir}/" + rebase_path(_package_staging_dir, root_build_dir),
outputs = [ _definition_path ] "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)
args = [ copy(target_name) {
"--pkg-name", outputs = [ "${_package_staging_dir}/{{source_file_part}}" ]
invoker.package,
"--description",
invoker.description,
"--pkg-root",
rebase_path(_package_root, root_build_dir),
"--install-mode",
_install_mode,
"--pkg-def",
rebase_path(_definition_path, root_build_dir),
"--depfile",
rebase_path(depfile, root_build_dir),
]
args += [ "--copy-files" ] + rebase_path(sources, root_build_dir)
} }
} }
#!/usr/bin/env python
#
# 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.
"""Prepares a directory and a corresponding package definition which can be
used to create a CIPD package."""
import argparse
import errno
import os
import sys
import yaml
def main(args):
parser = argparse.ArgumentParser()
parser.add_argument('--pkg-name',
type=str,
required=True,
help='Name of the CIPD package.')
parser.add_argument('--description',
type=str,
required=True,
help='Description of the CIPD package.')
parser.add_argument('--pkg-root',
type=str,
required=True,
help='Path to the package root.')
parser.add_argument('--install-mode',
type=str,
choices=['copy', 'symlink'],
required=True,
help='CIPD install mode.')
parser.add_argument('--pkg-def',
type=str,
required=True,
help='Path to the output package definition.')
parser.add_argument('--depfile',
type=str,
required=True,
help='Path to the depfile.')
parser.add_argument('--copy-files',
nargs='+',
help='Files to be copied into --pkg-root and included '
'in the package definition.')
args = parser.parse_args(args)
pkg_def = {
'package': args.pkg_name,
'description': args.description,
'root': '${outdir}/%s' % os.path.join(args.pkg_root),
'install_mode': args.install_mode,
'data': [],
}
deps = set()
# Copy files into the root.
for filepath in args.copy_files:
basename = os.path.basename(filepath)
dest = os.path.join(args.pkg_root, basename)
try:
os.link(filepath, dest)
except OSError as e:
if e.errno != errno.EEXIST:
raise
pkg_def['data'].append({'file': basename})
deps.add(dest)
with open(args.pkg_def, 'w') as f:
yaml.dump(pkg_def, f)
with open(args.depfile, 'w') as f:
f.writelines('%s: %s\n' % (args.pkg_def, ' '.join(sorted(deps))))
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
# Build targets for constructing CIPD release packages. # Build targets for constructing CIPD release archives.
assert(is_fuchsia) assert(is_fuchsia)
...@@ -16,10 +16,9 @@ if (host_os == "mac") { ...@@ -16,10 +16,9 @@ if (host_os == "mac") {
_gn_path = "//buildtools/linux64/gn" _gn_path = "//buildtools/linux64/gn"
} }
_license_path = "${target_gen_dir}/LICENSE"
# Produces a consolidated license file. # Produces a consolidated license file.
action("license") { action("license") {
_license_path = "${target_gen_dir}/LICENSE"
script = "//tools/licenses.py" script = "//tools/licenses.py"
inputs = [ "$_gn_path" ] inputs = [ "$_gn_path" ]
outputs = [ _license_path ] outputs = [ _license_path ]
...@@ -46,18 +45,18 @@ process_version("build_id") { ...@@ -46,18 +45,18 @@ process_version("build_id") {
process_only = true process_only = true
} }
# Prepares a CIPD package and generates a package definition. # Prepares a CIPD archive and generates a manifest file.
# #
# Parameters: # Parameters:
# package_definition_name: CIPD package definition filename. "cipd.yaml" # package_definition_yaml: The filename to use for the generated CIPD YAML
# if unspecified. # file.
# package: The path where the package will be located inside the CIPD # package: The path where the package will be located inside the CIPD
# repository. # repository.
# description: Sets the "description" field in CIPD metadata. # description: Sets the "description" field in CIPD metadata.
# install_mode: String, should be either "symlink" or "copy". # install_mode: String, should be either "symlink" or "copy".
# deps: A list of targets to build prior to copying files. # deps: A list of targets to build prior to copying files.
# sources: A list of files to copy into the staging root. # sources: A list of files to copy into the staging root.
template("cipd_package") { template("cipd_archive") {
forward_variables_from(invoker, forward_variables_from(invoker,
[ [
"deps", "deps",
...@@ -67,7 +66,15 @@ template("cipd_package") { ...@@ -67,7 +66,15 @@ template("cipd_package") {
if (!defined(deps)) { if (!defined(deps)) {
deps = [] deps = []
} }
deps += [ ":build_id" ] deps += [
":build_id",
":license",
]
if (!defined(sources)) {
sources = []
}
sources += get_target_outputs(":license")
cipd_package_definition(target_name) { cipd_package_definition(target_name) {
testonly = true testonly = true
...@@ -76,18 +83,17 @@ template("cipd_package") { ...@@ -76,18 +83,17 @@ template("cipd_package") {
"description", "description",
"install_mode", "install_mode",
"package", "package",
"package_definition_name", "package_definition_yaml",
]) ])
} }
} }
cipd_package("webrunner") { cipd_archive("webrunner") {
package_definition_name = "webrunner.yaml" package_definition_yaml = "webrunner.yaml"
package = "chromium/fuchsia/webrunner-\${targetarch}" package = "chromium/fuchsia/webrunner-\${targetarch}"
description = "Prebuilt Chrome and Web Runner binaries for Fuchsia." description = "Prebuilt Chrome and Web Runner binaries for Fuchsia."
deps = [ deps = [
":license",
"//fuchsia/engine:web_engine", "//fuchsia/engine:web_engine",
"//fuchsia/runners:web_runner_pkg", "//fuchsia/runners:web_runner_pkg",
] ]
...@@ -95,40 +101,27 @@ cipd_package("webrunner") { ...@@ -95,40 +101,27 @@ cipd_package("webrunner") {
sources = [ sources = [
"${root_gen_dir}/fuchsia/engine/web_engine/web_engine.far", "${root_gen_dir}/fuchsia/engine/web_engine/web_engine.far",
"${root_gen_dir}/fuchsia/runners/web_runner/web_runner.far", "${root_gen_dir}/fuchsia/runners/web_runner/web_runner.far",
_license_path,
] ]
} }
cipd_package("castrunner") { cipd_archive("castrunner") {
package_definition_name = "castrunner.yaml" package_definition_yaml = "castrunner.yaml"
package = "chromium/fuchsia/castrunner-\${targetarch}" package = "chromium/fuchsia/castrunner-\${targetarch}"
description = "Prebuilt Cast application Runner binaries for Fuchsia." description = "Prebuilt Cast application Runner binaries for Fuchsia."
deps = [ deps = [ "//fuchsia/runners:cast_runner_pkg" ]
":license",
"//fuchsia/runners:cast_runner_pkg",
]
sources = [ sources = [ "${root_gen_dir}/fuchsia/runners/cast_runner/cast_runner.far" ]
"${root_gen_dir}/fuchsia/runners/cast_runner/cast_runner.far",
_license_path,
]
} }
cipd_package("http") { cipd_archive("http") {
package_definition_name = "http.yaml" package_definition_yaml = "http.yaml"
package = "chromium/fuchsia/http-\${targetarch}" package = "chromium/fuchsia/http-\${targetarch}"
description = "Prebuilt HTTP service binary for Fuchsia." description = "Prebuilt HTTP service binary for Fuchsia."
deps = [ deps = [ "//fuchsia/http:http_pkg" ]
":license",
"//fuchsia/http:http_pkg",
]
sources = [ sources = [ "${root_gen_dir}/fuchsia/http/http/http.far" ]
"${root_gen_dir}/fuchsia/http/http/http.far",
_license_path,
]
} }
_stripped_chromedriver_file = "${root_out_dir}/clang_x64/stripped/chromedriver" _stripped_chromedriver_file = "${root_out_dir}/clang_x64/stripped/chromedriver"
...@@ -156,31 +149,23 @@ action("strip_chromedriver_binary") { ...@@ -156,31 +149,23 @@ action("strip_chromedriver_binary") {
visibility = [ ":*" ] visibility = [ ":*" ]
} }
cipd_package("chromedriver") { cipd_archive("chromedriver") {
package_definition_name = "chromedriver.yaml" package_definition_yaml = "chromedriver.yaml"
package = "chromium/fuchsia/chromedriver/\${os}-\${arch}" package = "chromium/fuchsia/chromedriver/\${os}-\${arch}"
description = "Prebuilt Chromedriver binary for Fuchsia host." description = "Prebuilt Chromedriver binary for Fuchsia host."
install_mode = "copy" install_mode = "copy"
deps = [ ":strip_chromedriver_binary" ]
deps = [ sources = [ _stripped_chromedriver_file ]
":license",
":strip_chromedriver_binary",
]
sources = [
_license_path,
_stripped_chromedriver_file,
]
} }
cipd_package("tests") { cipd_archive("tests") {
_manifest_path = "${target_gen_dir}/test_manifest.json" _manifest_path = "${target_gen_dir}/test_manifest.json"
package_definition_name = "tests.yaml" package_definition_yaml = "tests.yaml"
package = "chromium/fuchsia/tests-\${targetarch}" package = "chromium/fuchsia/tests-\${targetarch}"
description = "Prebuilt Chromium tests for Fuchsia." description = "Prebuilt Chromium tests for Fuchsia."
deps = [ deps = [
":license",
"//base:base_unittests_pkg", "//base:base_unittests_pkg",
"//fuchsia/runners:cast_runner_integration_tests_pkg", "//fuchsia/runners:cast_runner_integration_tests_pkg",
"//fuchsia/runners:web_runner_integration_tests_pkg", "//fuchsia/runners:web_runner_integration_tests_pkg",
...@@ -202,7 +187,7 @@ cipd_package("tests") { ...@@ -202,7 +187,7 @@ cipd_package("tests") {
"${root_gen_dir}/third_party/blink/common/blink_common_unittests/blink_common_unittests.far", "${root_gen_dir}/third_party/blink/common/blink_common_unittests/blink_common_unittests.far",
] ]
# Build a JSON manifest of the tests and include it in the package. # Build a JSON manifest of the tests and include it in the archive.
_manifest_contents = [] _manifest_contents = []
foreach(source, far_sources) { foreach(source, far_sources) {
package_name = get_path_info(source, "name") package_name = get_path_info(source, "name")
...@@ -216,14 +201,11 @@ cipd_package("tests") { ...@@ -216,14 +201,11 @@ cipd_package("tests") {
} }
write_file(_manifest_path, _manifest_contents, "json") write_file(_manifest_path, _manifest_contents, "json")
sources = far_sources + [ sources = far_sources + [ _manifest_path ]
_manifest_path,
_license_path,
]
} }
cipd_package("debug_symbols") { cipd_archive("debug_symbols") {
package_definition_name = "debug_symbols.yaml" package_definition_yaml = "debug_symbols.yaml"
package = "chromium/fuchsia/debug-symbols-\${targetarch}" package = "chromium/fuchsia/debug-symbols-\${targetarch}"
description = "Debugging symbols for prebuilt binaries from Chromium." description = "Debugging symbols for prebuilt binaries from Chromium."
...@@ -241,31 +223,21 @@ cipd_package("debug_symbols") { ...@@ -241,31 +223,21 @@ cipd_package("debug_symbols") {
write_file(_symbol_manifest, _symbol_manifest_contents, "json") write_file(_symbol_manifest, _symbol_manifest_contents, "json")
deps = [ deps = [
":license",
"//fuchsia/engine:symbol_archive", "//fuchsia/engine:symbol_archive",
"//fuchsia/runners:cast_runner_symbol_archive", "//fuchsia/runners:cast_runner_symbol_archive",
"//fuchsia/runners:web_runner_symbol_archive", "//fuchsia/runners:web_runner_symbol_archive",
] ]
sources = _symbol_tarballs + [ sources = [ _symbol_manifest ] + _symbol_tarballs
_symbol_manifest,
_license_path,
]
} }
cipd_package("clear_key_cdm") { cipd_archive("clear_key_cdm") {
package_definition_name = "clear_key_cdm.yaml" package_definition_yaml = "clear_key_cdm.yaml"
package = "chromium/fuchsia/libclearkeycdm-\${targetarch}" package = "chromium/fuchsia/libclearkeycdm-\${targetarch}"
description = "Prebuilt libclearkeycdm.so binary for Fuchsia." description = "Prebuilt libclearkeycdm.so binary for Fuchsia."
deps = [ deps = [ "//media/cdm/library_cdm/clear_key_cdm:clear_key_cdm" ]
":license",
"//media/cdm/library_cdm/clear_key_cdm:clear_key_cdm",
]
sources = [ sources = [ "${root_out_dir}/lib/libclearkeycdm.so" ]
"${root_out_dir}/lib/libclearkeycdm.so",
_license_path,
]
} }
group("cipd") { group("cipd") {
......
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