| # Copyright 2025 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. | |
| # | |
| # This file exports the restricted_loadable_module() template for building | |
| # loadable code blobs for restricted_machine::Environment. | |
| # It also exports if an additional cpu is available, e.g., arm for arm64. | |
| additional_restricted_cpu = "" | |
| # https://fxbug.dev/382971270 enable lower mem allocations when under asan | |
| if (current_cpu == "arm64" && !is_asan) { | |
| # Only arm64 supports an additional cpu. | |
| additional_restricted_cpu = "arm" | |
| } | |
| # Provides the template for building loadable modules for restricted_machine | |
| # usage. | |
| template("restricted_loadable_module") { | |
| loadable_module(target_name) { | |
| configs += [ "//src/bringup/lib/restricted-machine/loadable:restricted-loadable-config" ] | |
| exclude_toolchain_tags = [ "instrumented" ] | |
| deps = [] | |
| forward_variables_from(invoker, | |
| [ | |
| "args", | |
| "disabled", | |
| "environments", | |
| "sources", | |
| ]) | |
| if (defined(invoker.deps)) { | |
| deps += invoker.deps | |
| } | |
| if (defined(invoker.configs)) { | |
| configs += invoker.configs | |
| } | |
| metadata = { | |
| # Place the test module in the package with the CPU-specific name. The | |
| # test will use the fuchsia.ldsvc (userboot in the standalone case) to | |
| # acquire each as a VMO, which will look for them in lib/ (within the | |
| # package namespace for the component test, otherwise under /boot). | |
| distribution_entries = [ | |
| { | |
| destination = "lib/restricted-loadable/$target_name.$current_cpu.so" | |
| source = rebase_path("$root_out_dir/$target_name.so", root_build_dir) | |
| label = get_label_info(":$target_name", "label_with_toolchain") | |
| }, | |
| ] | |
| } | |
| } | |
| } |