| # Copyright 2022 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. |
| |
| import("//build/sdk/sdk_atom.gni") |
| |
| declare_args() { |
| # If true, then the arm64 host tools are included in the SDK. |
| arm_sdk_tools = false |
| } |
| |
| # Defines an SDK companion tool element for the emulator prebuilts. |
| # |
| # Outputs |
| # sdk_atom named ${target_name}. |
| # |
| # Parameters |
| # default_binary - path to the binary that is run to run this tool. |
| # This path ends up being the first element in the files of the SDK |
| # atom metadata. |
| # prebuilt_path - path to the directory to copy for this prebuilt tool. |
| # This should be an ancestor or the same as the directory of the |
| # default_binary.' |
| # prebuilt_files - list of files to include in the SDK. If this is not |
| # specified, all files in the prebuilt_path are included. |
| # sdk_dest_path - relative path for the destination of the companion tool |
| # in the SDK structure. A typical value is |
| # `tools/${current_cpu}/${target_name}`. |
| |
| template("emu_companion") { |
| assert(defined(invoker.default_binary), |
| "Must define the default binary for this companion tool") |
| assert(defined(invoker.prebuilt_path), |
| "Must define the prebuilt directory path") |
| assert(defined(invoker.sdk_dest_path), |
| "Must define the destination path relative to SDK root") |
| |
| if (defined(invoker.prebuilt_files)) { |
| assert( |
| invoker.prebuilt_files != [], |
| "prebuilt_files is optional, meaning all file in prebuilt_path, or if specified, a non-empty list of files") |
| included_files = [] |
| foreach(f, invoker.prebuilt_files) { |
| included_files += [ rebase_path(f, invoker.prebuilt_path) ] |
| } |
| } |
| |
| sdk_atom(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| ]) |
| id = "sdk://tools/$current_cpu/${target_name}" |
| category = "partner" |
| |
| meta = { |
| dest = "${invoker.sdk_dest_path}-meta.json" |
| type = "companion_host_tool" |
| source_prebuild_info = { |
| name = invoker.target_name |
| binary = rebase_path(invoker.default_binary, root_build_dir) |
| src_root = rebase_path(invoker.prebuilt_path, root_build_dir) |
| dest_root = invoker.sdk_dest_path |
| if (defined(included_files)) { |
| prebuilt_files = included_files |
| } |
| } |
| } |
| } |
| } |