summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/build/cipd
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/libwebrtc/build/cipd')
-rw-r--r--third_party/libwebrtc/build/cipd/cipd.gni140
-rwxr-xr-xthird_party/libwebrtc/build/cipd/cipd_from_file.py65
-rwxr-xr-xthird_party/libwebrtc/build/cipd/clobber_cipd_root.py33
3 files changed, 238 insertions, 0 deletions
diff --git a/third_party/libwebrtc/build/cipd/cipd.gni b/third_party/libwebrtc/build/cipd/cipd.gni
new file mode 100644
index 0000000000..e7795c1062
--- /dev/null
+++ b/third_party/libwebrtc/build/cipd/cipd.gni
@@ -0,0 +1,140 @@
+# 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.
+# source_directories: A list of directories to include in the package. Should
+# only be used when listing out all the files (in a given
+# directory) in |sources| is unfeasible.
+#
+# 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",
+ "source_directories",
+ "data_deps",
+ "sources",
+ "testonly",
+ ])
+
+ assert(defined(sources) || defined(source_directories),
+ "At least one sources input 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: " + rebase_path(_package_staging_dir),
+ "install_mode: ${_install_mode}",
+ "data:",
+ ]
+
+ if (defined(sources)) {
+ foreach(source, sources) {
+ _yaml_contents += [ " - file: " + get_path_info(source, "file") ]
+ }
+ copy(target_name) {
+ outputs = [ "${_package_staging_dir}/{{source_file_part}}" ]
+ }
+ }
+
+ if (defined(source_directories)) {
+ foreach(directory, source_directories) {
+ _yaml_contents += [ " - dir: " + directory ]
+ }
+ }
+
+ write_file("${_package_staging_dir}/${_cipd_definition_yaml}", _yaml_contents)
+}
+
+# Create a cipd file based on inputs and FILES.cfg config. Most of the arguments
+# are similar with |cipd_package_definition| above.
+#
+# Additional parameters:
+#
+# package_definition_yaml: The output yaml file. Default is
+# ${target_name}_cipd.yaml.
+# files_file: The file defines what files and directories to include.
+# Example: //tools/build/chromeos/FILES.cfg.
+# buildtype: str, required. It can be "dev" or "official".
+# Only when the file has the same buildtype, it will be included.
+# arch: str, required. It can be "32bit", "64bit", "arm".
+#
+# Example:
+# cipd_package_definition_by_file("chrome_cipd") {
+# package = "path/to/cipd/package"
+# description = "Prebuilt test binary."
+# install_mode = "copy"
+# files_file = "//chrome/tools/build/chromeos/FILES.json"
+# buildtype = "dev"
+# arch = "64bit"
+# deps = [ "//path/to:test_binary_target" ]
+# }
+template("cipd_package_definition_by_file") {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "data",
+ "data_deps",
+ "sources",
+ "testonly",
+ ])
+ _output_yaml_filename = "${target_name}_cipd.yaml"
+ if (defined(invoker.package_definition_yaml)) {
+ _output_yaml_filename = invoker.package_definition_yaml
+ }
+ action(target_name) {
+ script = "//build/cipd/cipd_from_file.py"
+ inputs = [ "//build/cipd/cipd_from_file.py" ]
+ args = [
+ "--description=" + invoker.description,
+ "--buildtype=" + invoker.buildtype,
+ "--arch=" + invoker.arch,
+ "--files_file=" + rebase_path(invoker.files_file, root_build_dir),
+ "--package=" + invoker.package,
+ "--install_mode=" + invoker.install_mode,
+ "--output_yaml_file=" +
+ rebase_path("${root_out_dir}/" + _output_yaml_filename,
+ root_build_dir),
+ ]
+ outputs = [ "${root_out_dir}/" + _output_yaml_filename ]
+ }
+}
diff --git a/third_party/libwebrtc/build/cipd/cipd_from_file.py b/third_party/libwebrtc/build/cipd/cipd_from_file.py
new file mode 100755
index 0000000000..0f08f692e3
--- /dev/null
+++ b/third_party/libwebrtc/build/cipd/cipd_from_file.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python3
+# Copyright 2021 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.
+"""Script to generate yaml file based on FILES.cfg."""
+
+import argparse
+import os
+
+
+def _ParseFilesCfg(files_file):
+ """Return the dictionary of archive file info read from the given file."""
+ if not os.path.exists(files_file):
+ raise IOError('Files list does not exist (%s).' % files_file)
+ exec_globals = {'__builtins__': None}
+
+ exec(open(files_file).read(), exec_globals)
+ return exec_globals['FILES']
+
+
+def _Process(args):
+ yaml_content = ('package: ' + args.package + '\ndescription: ' +
+ args.description + '\ninstall_mode: ' + args.install_mode +
+ '\ndata:\n')
+ fileobj = _ParseFilesCfg(args.files_file)
+ for item in fileobj:
+ if 'buildtype' in item:
+ if args.buildtype not in item['buildtype']:
+ continue
+ if 'arch' in item:
+ if args.arch not in item['arch']:
+ continue
+ if 'type' in item and item['type'] == 'folder':
+ yaml_content += ' - dir: ' + item['filename'] + '\n'
+ else:
+ yaml_content += ' - file: ' + item['filename'] + '\n'
+
+ with open(args.output_yaml_file, 'w') as f:
+ f.write(yaml_content)
+
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--output_yaml_file', help='File to create.')
+ parser.add_argument(
+ '--package',
+ help='The path where the package will be located inside the CIPD\
+ repository.')
+ parser.add_argument(
+ '--description',
+ help='Sets the "description" field in CIPD package definition.')
+ parser.add_argument('--install_mode',
+ help='String, should be either "symlink" or "copy".')
+ parser.add_argument('--files_file',
+ help='FILES.cfg describes what files to include.')
+ parser.add_argument('--buildtype', help='buildtype for FILES.cfg.')
+ parser.add_argument('--arch', help='arch for FILES.cfg')
+
+ args = parser.parse_args()
+
+ _Process(args)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/third_party/libwebrtc/build/cipd/clobber_cipd_root.py b/third_party/libwebrtc/build/cipd/clobber_cipd_root.py
new file mode 100755
index 0000000000..5d36c72239
--- /dev/null
+++ b/third_party/libwebrtc/build/cipd/clobber_cipd_root.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+#
+# Copyright 2018 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.
+
+"""Clobbers a CIPD root."""
+
+import argparse
+import os
+import shutil
+import sys
+
+
+def main():
+ parser = argparse.ArgumentParser(
+ description='Clobbers the CIPD root in the given directory.')
+
+ parser.add_argument(
+ '--root',
+ required=True,
+ help='Root directory for dependency.')
+ args = parser.parse_args()
+
+ cipd_root_dir = os.path.join(args.root, '.cipd')
+ if os.path.exists(cipd_root_dir):
+ shutil.rmtree(cipd_root_dir)
+
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main())