xref: /aosp_15_r20/external/cronet/build/config/fuchsia/fuchsia_package_metadata.gni (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1# Copyright 2022 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
5assert(is_fuchsia)
6
7# Generates a metadata file under root_gen_dir which provides information about
8# a Fuchsia package.
9# Parameters:
10#   package_deps: An array of package_paths which specify the location of all
11#                 .far files that the package depends on.
12template("fuchsia_package_metadata") {
13  _pkg_dir = "$root_out_dir/gen/" + get_label_info(invoker.package, "dir") +
14             "/" + target_name
15  _pkg_path = "$_pkg_dir/${target_name}.far"
16  pkg_dep_paths = [ rebase_path(_pkg_path, root_build_dir) ]
17  if (defined(invoker.package_deps)) {
18    foreach(package_dep, invoker.package_deps) {
19      _pkg_dep_target = package_dep[0]
20      _pkg_dep_name = package_dep[1]
21      pkg_dep_path =
22          rebase_path(get_label_info(_pkg_dep_target, "target_gen_dir") + "/" +
23                          _pkg_dep_name + "/" + _pkg_dep_name + ".far",
24                      root_build_dir)
25      pkg_dep_paths += [ pkg_dep_path ]
26    }
27  }
28
29  pkg_metadata = "${target_name}_script_meta"
30  generated_file(pkg_metadata) {
31    forward_variables_from(invoker, TESTONLY_AND_VISIBILITY)
32    contents = {
33      packages = pkg_dep_paths
34    }
35    output_conversion = "json"
36    outputs = [ "$root_gen_dir/package_metadata/${invoker.target_name}.meta" ]
37  }
38}
39