| # 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. |
| |
| _linux_toolchain = "//build/toolchain:linux_${current_cpu}" |
| |
| # Creates a Linux "init" program, intending as the first userspace program |
| # launched (A.K.A, PID 1), leveraged as a dependency of a |
| # linux_test_initramfs() target |
| # |
| # See executable() for parameters. |
| template("linux_test_init") { |
| if (toolchain_variant.base == _linux_toolchain) { |
| executable(target_name) { |
| testonly = true |
| forward_variables_from(invoker, "*", [ "testonly" ]) |
| |
| if (!defined(output_name)) { |
| output_name = target_name |
| } |
| output_path = "$root_out_dir/$output_name" |
| if (defined(output_extension)) { |
| output_path += ".${output_extension}" |
| } |
| |
| # There isn't too much value derived from instrumenting the init program: |
| # pragmatically, we suppress the variants that don't 'just work'. |
| exclude_toolchain_tags = [ "asan" ] |
| |
| metadata = { |
| distribution_entries_barrier = [] |
| distribution_entries = [ |
| { |
| source = rebase_path(output_path, root_build_dir) |
| destination = "init" # Destination of /init means auto-executed |
| label = get_label_info(":$target_name", "label_with_toolchain") |
| }, |
| ] |
| } |
| } |
| } else { |
| group(target_name) { |
| testonly = true |
| forward_variables_from(invoker, [ "visibility" ]) |
| deps = [ ":$target_name($_linux_toolchain)" ] |
| } |
| not_needed(invoker, "*", [ "visibility" ]) |
| } |
| } |