tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

cipd.gni (5017B)


      1 # Copyright 2020 The Chromium Authors
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 # Build targets for constructing CIPD packages.
      6 #
      7 # Prepares a CIPD archive and generates a manifest file.
      8 #
      9 # TODO(crbug.com/40115002): Add support for including directories.
     10 #
     11 # Parameters:
     12 #   package_definition_yaml: CIPD package definition filename. "cipd.yaml"
     13 #                            if unspecified.
     14 #   package: The path where the package will be located inside the CIPD
     15 #            repository.
     16 #   description: Sets the "description" field in CIPD package definition.
     17 #   install_mode: String, should be either "symlink" or "copy". Defaults to
     18 #                 "symlink".
     19 #   deps: A list of targets to build prior to copying files.
     20 #   sources: A list of files to copy into the staging root.
     21 #   source_directories: A list of directories to include in the package. Should
     22 #                       only be used when listing out all the files (in a given
     23 #                       directory) in |sources| is unfeasible.
     24 #
     25 # Example:
     26 #   cipd_package_definition("chromedriver") {
     27 #     package = "path/to/cipd/package"
     28 #     description = "Prebuilt test binary."
     29 #     install_mode = "copy"
     30 #     deps = [ "//path/to:test_binary_target" ]
     31 #     sources = [ "//path/to:test_binary_file" ]
     32 #   }
     33 #
     34 template("cipd_package_definition") {
     35   forward_variables_from(invoker,
     36                          [
     37                            "deps",
     38                            "data",
     39                            "source_directories",
     40                            "data_deps",
     41                            "sources",
     42                            "testonly",
     43                          ])
     44 
     45   assert(defined(sources) || defined(source_directories),
     46          "At least one sources input must be specified.")
     47 
     48   _install_mode = "symlink"
     49   if (defined(invoker.install_mode)) {
     50     _install_mode = invoker.install_mode
     51   }
     52   assert(_install_mode == "copy" || _install_mode == "symlink",
     53          "\"install_mode\" arg should be either \"copy\" or \"symlink\".")
     54 
     55   _cipd_definition_yaml = "cipd.yaml"
     56   if (defined(invoker.package_definition_yaml)) {
     57     _cipd_definition_yaml = invoker.package_definition_yaml
     58   }
     59 
     60   _package_staging_dir = "${target_gen_dir}/${target_name}"
     61 
     62   _yaml_contents = [
     63     "package: ${invoker.package}",
     64     "description: ${invoker.description}",
     65     "root: " + rebase_path(_package_staging_dir),
     66     "install_mode: ${_install_mode}",
     67     "data:",
     68   ]
     69 
     70   if (defined(sources)) {
     71     foreach(source, sources) {
     72       _yaml_contents += [ "  - file: " + get_path_info(source, "file") ]
     73     }
     74     copy(target_name) {
     75       outputs = [ "${_package_staging_dir}/{{source_file_part}}" ]
     76     }
     77   }
     78 
     79   if (defined(source_directories)) {
     80     foreach(directory, source_directories) {
     81       _yaml_contents += [ "  - dir: " + directory ]
     82     }
     83   }
     84 
     85   write_file("${_package_staging_dir}/${_cipd_definition_yaml}", _yaml_contents)
     86 }
     87 
     88 # Create a cipd file based on inputs and FILES.cfg config. Most of the arguments
     89 # are similar with |cipd_package_definition| above.
     90 #
     91 # Additional parameters:
     92 #
     93 #   package_definition_yaml: The output yaml file. Default is
     94 #                            ${target_name}_cipd.yaml.
     95 #   files_file: The file defines what files and directories to include.
     96 #               Example: //tools/build/chromeos/FILES.cfg.
     97 #   buildtype: str, required. It can be "dev" or "official".
     98 #              Only when the file has the same buildtype, it will be included.
     99 #   arch: str, required. It can be "32bit", "64bit", "arm".
    100 #
    101 # Example:
    102 # cipd_package_definition_by_file("chrome_cipd") {
    103 #     package = "path/to/cipd/package"
    104 #     description = "Prebuilt test binary."
    105 #     install_mode = "copy"
    106 #     files_file = "//chrome/tools/build/chromeos/FILES.json"
    107 #     buildtype = "dev"
    108 #     arch = "64bit"
    109 #     deps = [ "//path/to:test_binary_target" ]
    110 #   }
    111 template("cipd_package_definition_by_file") {
    112   forward_variables_from(invoker,
    113                          [
    114                            "deps",
    115                            "data",
    116                            "data_deps",
    117                            "sources",
    118                            "testonly",
    119                          ])
    120   _output_yaml_filename = "${target_name}_cipd.yaml"
    121   if (defined(invoker.package_definition_yaml)) {
    122     _output_yaml_filename = invoker.package_definition_yaml
    123   }
    124   action(target_name) {
    125     script = "//chromium/build/cipd/cipd_from_file.py"
    126     inputs = [ invoker.files_file ]
    127     args = [
    128       "--description=" + invoker.description,
    129       "--buildtype=" + invoker.buildtype,
    130       "--arch=" + invoker.arch,
    131       "--files_file=" + rebase_path(invoker.files_file, root_build_dir),
    132       "--package=" + invoker.package,
    133       "--install_mode=" + invoker.install_mode,
    134       "--output_yaml_file=" +
    135           rebase_path("${root_out_dir}/" + _output_yaml_filename,
    136                       root_build_dir),
    137     ]
    138     outputs = [ "${root_out_dir}/" + _output_yaml_filename ]
    139   }
    140 }