summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/build/config/fuchsia/package.gni
blob: ff6ffd0a3d2b30583064be234a912bd331bb4229 (plain)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# 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.

import("//third_party/fuchsia-sdk/sdk/build/component.gni")
import("//third_party/fuchsia-sdk/sdk/build/package.gni")

# DEPRECATED: Use the Fuchsia SDK's fuchsia_component() and fuchsia_package()
# templates directly, in new code.
#
# Creates a Fuchsia .far package file containing a Fuchsia component.
#
# Parameters are:
# package_name_override: Specifies the name of the package to generate,
#     if different than |target_name|.
# binary: The executable target which should be launched.
# manifest: A path to the manifest that will be used.
#     "testonly" targets default to using
#     //build/config/fuchsia/tests-with-exec.cmx.
#     Non-test targets must explicitly specify a |manifest|.
# additional_manifests: Manifest files that should be included in the package in
#     the /meta directory. This allows to package more than one component per
#     manifest. These manifest files must specify program/binary to run, which
#     is not required for the main manifest file where this parameter is added
#     during build.
# component_name_override: If set, specifies the name of the component.
#     By default, the component name is the same as the package name.
# deps: Additional targets to build and include in the package (optional).
#
# TODO(https://crbug.com/1050703): Migrate consumers to GN SDK equivalents.
template("cr_fuchsia_package") {
  assert(defined(invoker.binary))

  if (defined(invoker.package_name_override)) {
    _package_name = invoker.package_name_override
  } else {
    _package_name = invoker.target_name
  }

  _package_contents = [ invoker.binary ]
  if (defined(invoker.deps)) {
    _package_contents += invoker.deps
  }

  _component_cmx_target = target_name + "__cr-component-cmx"
  _component_target = target_name + "__cr-component"
  _package_components = [ ":${_component_target}" ]
  _component_manifest = "${target_gen_dir}/${target_name}.cmx"

  # Process the CMX fragment in |manifest| to get a full manifest.
  action(_component_cmx_target) {
    forward_variables_from(invoker,
                           [
                             "deps",
                             "testonly",
                           ])

    script = "//build/config/fuchsia/build_cmx_from_fragment.py"

    inputs = [ invoker.manifest ]
    outputs = [ _component_manifest ]

    args = [
      "--cmx-fragment",
      rebase_path(invoker.manifest),
      "--cmx",
      rebase_path(_component_manifest),
      "--program",
      get_label_info(invoker.binary, "name"),
    ]
  }

  # Declare the primary component for this package.
  fuchsia_component(_component_target) {
    forward_variables_from(invoker, [ "testonly" ])

    deps = [ ":${_component_cmx_target}" ]
    data_deps = _package_contents
    manifest = _component_manifest

    if (defined(invoker.component_name_override)) {
      manifest_output_name = "${invoker.component_name_override}"
    } else {
      manifest_output_name = "${_package_name}"
    }
  }

  # Bundle manifests providing additional entrypoints into the package.
  if (defined(invoker.additional_manifests)) {
    foreach(filename, invoker.additional_manifests) {
      _additional_component_target =
          target_name + "_" + get_path_info(filename, "name")
      _package_components += [ ":${_additional_component_target}" ]
      fuchsia_component(_additional_component_target) {
        forward_variables_from(invoker, [ "testonly" ])
        data_deps = _package_contents
        manifest = filename

        # Depend upon the invoker's |deps|, in case they include a dependency
        # responsible for generating this additional component's manifest file.
        deps = _package_contents
      }
    }
  }

  fuchsia_package(target_name) {
    forward_variables_from(invoker, [ "testonly" ])
    package_name = _package_name
    if (defined(invoker.excluded_files)) {
      excluded_files = invoker.excluded_files
    }
    deps = _package_components
  }
}