blob: cb2b704066b27e32cb76654c88ee32cf699ec910 [file] [log] [blame]
# 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/components.gni")
# Defines a starnix runner package with a provided configuration file and system image.
#
# Parameters
#
# `config` (required, string): path to a JSON configuration file.
#
# `system_image` (optional, string): path to a system image file for the galaxy.
#
# `deps` (optional, list of targets): additional dependencies.
template("starnix_galaxy_package") {
assert(defined(invoker.config),
"must define `config` as a path to JSON file with startup config")
group_target = "${target_name}_deps"
has_system_image = defined(invoker.system_image)
component_target = "${target_name}_component"
config_target = "${target_name}_config"
manifest_target = "${target_name}_manifest_compile"
data_tmp_target = "${target_name}_data_tmp"
data_init_target = "${target_name}_data_init"
if (has_system_image) {
system_image_target = "${target_name}_system_image"
}
fuchsia_component_manifest(manifest_target) {
component_name = "starnix_runner"
manifest = "//src/proc/bin/starnix/meta/starnix_runner.cml"
}
fuchsia_component(component_target) {
cm_label = ":${manifest_target}"
deps = [ "//src/proc/bin/starnix:starnix_runner_bin" ]
}
fuchsia_structured_config_values(config_target) {
cm_label = ":${manifest_target}"
values_source = invoker.config
}
if (has_system_image) {
resource(system_image_target) {
sources = [ invoker.system_image ]
outputs = [ "data/system.img" ]
}
}
# A file that makes sure that the data/tmp directory exists.
resource(data_tmp_target) {
sources = [ "//src/proc/bin/galaxies/placeholder" ]
outputs = [ "data/tmp/.placeholder" ]
}
# The default init executable. Used if the configuration has no init.
resource(data_init_target) {
init_label =
"//src/proc/bin/galaxies/default_init(//build/toolchain:linux_x64)"
out_dir = get_label_info(init_label, "root_out_dir")
sources = [ "${out_dir}/default_init" ]
outputs = [ "data/init" ]
deps = [ init_label ]
}
# A group containing all the dependency of the galaxy package, so that a
# galaxy can be injected into another package. It is used in particular for
# test to ensure hermeticity.
group(group_target) {
deps = [
":${component_target}",
":${config_target}",
":${data_init_target}",
":${data_tmp_target}",
]
if (has_system_image) {
deps += [ ":${system_image_target}" ]
}
if (defined(invoker.deps)) {
deps += invoker.deps
}
}
fuchsia_package(target_name) {
deps = [ ":${group_target}" ]
}
}