| # Copyright 2023 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| # Generate a final IDK archive, based on an `idk` target. |
| # |
| # The generated archive will go into |
| # $root_build_dir/sdk/archive/{output_name} |
| # |
| # Arguments: |
| # idk: (required) |
| # Label for an `idk` target that will be built and then archived. |
| # |
| # idk_output_name: (optional) |
| # `output_name` argument provided to the `idk` target, if any. By default, |
| # this will be the name of the `idk` target. |
| # |
| # output_name: (optional) |
| # Full name of the archive file, including `.tar.gz`. By default, this will |
| # be `idk_output_name` followed by `.tar.gz` |
| # |
| # testonly, visibility |
| # Usual GN meaning. |
| # |
| template("idk_archive") { |
| assert(defined(invoker.idk), "idk must be specified for $target_name") |
| |
| _idk_output_name = get_label_info(invoker.idk, "name") |
| if (defined(invoker.idk_output_name)) { |
| _idk_output_name = invoker.idk_output_name |
| } |
| |
| _archive_output_name = "${_idk_output_name}.tar.gz" |
| if (defined(invoker.output_name)) { |
| _archive_output_name = invoker.output_name |
| } |
| |
| _exported_dir = root_build_dir + "/sdk/exported/${_idk_output_name}" |
| _output_archive = root_build_dir + "/sdk/archive/${_archive_output_name}" |
| |
| action(target_name) { |
| script = "//scripts/sdk/merger/merge.py" |
| outputs = [ _output_archive ] |
| inputs = [ |
| # Invoked at runtime by this action's script. |
| "//prebuilt/third_party/pigz/pigz", |
| ] |
| mnemonic = "IDK_ARCHIVE" |
| args = [ |
| "--input-directory", |
| rebase_path(_exported_dir, root_build_dir), |
| "--output-archive", |
| rebase_path(outputs[0], root_build_dir), |
| ] |
| deps = [ invoker.idk ] |
| |
| hermetic_inputs_file = "$target_gen_dir/$target_name.hermetic_inputs" |
| |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| ]) |
| |
| metadata = { |
| sdk_archives = [ |
| { |
| name = _idk_output_name |
| |
| # TODO(https://fxbug.dev/126262): Determine which values are |
| # appropriate, since the archive contains binaries for all |
| # Fuchsia CPU architectures (but only one, or even two in |
| # the case of Linux) host CPU architectures! |
| os = current_os |
| cpu = current_cpu |
| label = get_label_info(":$target_name", "label_with_toolchain") |
| path = rebase_path(_output_archive, root_build_dir) |
| }, |
| ] |
| } |
| } |
| } |