tor-browser

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

compile_plist.gni (2580B)


      1 # Copyright 2021 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 # Template to merge multiple plist files and perform variable substitutions.
      6 #
      7 # Arguments
      8 #
      9 #     plist_templates:
     10 #         string array, paths to plist files which will be used for the bundle.
     11 #
     12 #     format:
     13 #         string, the format to `plutil -convert` the plist to when
     14 #         generating the output.
     15 #
     16 #     substitutions:
     17 #         string array, 'key=value' pairs used to replace ${key} by value
     18 #         when generating the output plist file.
     19 #
     20 #     output_name:
     21 #         string, name of the generated plist file.
     22 template("compile_plist") {
     23   assert(defined(invoker.plist_templates),
     24          "A list of template plist files must be specified for $target_name")
     25   assert(defined(invoker.format),
     26          "The plist format must be specified for $target_name")
     27   assert(defined(invoker.substitutions),
     28          "A list of key=value pairs must be specified for $target_name")
     29   assert(defined(invoker.output_name),
     30          "The name of the output file must be specified for $target_name")
     31 
     32   _output_name = invoker.output_name
     33   _merged_name = get_path_info(_output_name, "dir") + "/" +
     34                  get_path_info(_output_name, "name") + "_merged." +
     35                  get_path_info(_output_name, "extension")
     36 
     37   _merge_target = target_name + "_merge"
     38 
     39   action(_merge_target) {
     40     forward_variables_from(invoker,
     41                            [
     42                              "deps",
     43                              "testonly",
     44                            ])
     45 
     46     script = "//chromium/build/apple/plist_util.py"
     47     sources = invoker.plist_templates
     48     outputs = [ _merged_name ]
     49     args = [
     50              "merge",
     51              "-f=" + invoker.format,
     52              "-o=" + rebase_path(_merged_name, root_build_dir),
     53            ] + rebase_path(invoker.plist_templates, root_build_dir)
     54   }
     55 
     56   action(target_name) {
     57     forward_variables_from(invoker,
     58                            [
     59                              "testonly",
     60                              "visibility",
     61                            ])
     62     script = "//chromium/build/apple/plist_util.py"
     63     sources = [ _merged_name ]
     64     outputs = [ _output_name ]
     65     args = [
     66       "substitute",
     67       "-f=" + invoker.format,
     68       "-o=" + rebase_path(_output_name, root_build_dir),
     69       "-t=" + rebase_path(_merged_name, root_build_dir),
     70     ]
     71     foreach(_substitution, invoker.substitutions) {
     72       args += [ "-s=$_substitution" ]
     73     }
     74     deps = [ ":$_merge_target" ]
     75   }
     76 }