1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70

build / ios / extension_bundle_data.gni [blame]

# Copyright 2021 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# Template to package an app extension into an app.
#
# Parameters
#
#   extension_target:
#     name of the extension target to package; the extension
#     bundle name must be derived from the target name
#
#   extension_name:
#     (optional) name of the extension appex file; derived from
#     the target name if omitted
#
template("extension_bundle_data") {
  assert(defined(invoker.extension_target),
         "extension_target must be defined for $target_name")

  _extension_name = get_label_info(invoker.extension_target, "name") + ".appex"
  if (defined(invoker.extension_name)) {
    _extension_name = invoker.extension_name
  }

  _extension_dir = "PlugIns"
  if (defined(invoker.extension_dir)) {
    _extension_dir = invoker.extension_dir
  }

  if (defined(invoker.variants) && invoker.variants != []) {
    _variants = []
    foreach(_variant, invoker.variants) {
      _variants += [
        {
          name = _variant.name
        },
      ]
    }
  } else {
    _variants = []
  }

  _target_name = target_name
  if (_variants != []) {
    foreach(_variant, _variants) {
      _extension_target =
          get_label_info(invoker.extension_target, "label_no_toolchain") +
          "_variants_${_variant.name}" + "(" +
          get_label_info(invoker.extension_target, "toolchain") + ")"

      bundle_data("${_target_name}_variants_${_variant.name}") {
        forward_variables_from(invoker, [ "testonly" ])
        public_deps = [ _extension_target ]
        outputs =
            [ "{{bundle_contents_dir}}/$_extension_dir/{{source_file_part}}" ]
        sources = [ get_label_info(_extension_target, "root_out_dir") +
                    "/variants/${_variant.name}/$_extension_name" ]
      }
    }
  }

  bundle_data(_target_name) {
    forward_variables_from(invoker, [ "testonly" ])
    public_deps = [ invoker.extension_target ]
    outputs = [ "{{bundle_contents_dir}}/$_extension_dir/{{source_file_part}}" ]
    sources = [ get_label_info(invoker.extension_target, "root_out_dir") +
                "/$_extension_name" ]
  }
}