| # Copyright 2021 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/rust/rustc_binary.gni") |
| import("//build/rust/rustc_test.gni") |
| import("//build/rust/rustc_macro.gni") |
| import("//src/sys/build/components.gni") |
| |
| group("starnix") { |
| deps = [ |
| ":android_starnix", |
| ":hello_starnix", |
| ":pkg", |
| ] |
| } |
| |
| if (target_cpu == "x64") { |
| rustc_binary("starnix_bin") { |
| name = "starnix" |
| edition = "2018" |
| with_unit_tests = true |
| |
| source_root = "main.rs" |
| deps = [ |
| ":starnix_macros", |
| "//garnet/lib/rust/io_util", |
| "//sdk/fidl/fuchsia.component.runner:fuchsia.component.runner-rustc", |
| "//sdk/fidl/fuchsia.io:fuchsia.io-rustc", |
| "//sdk/fidl/fuchsia.ldsvc:fuchsia.ldsvc-rustc", |
| "//sdk/fidl/fuchsia.kernel:fuchsia.kernel-rustc", |
| "//src/lib/fdio/rust:fdio", |
| "//src/lib/fidl/rust/fidl", |
| "//src/lib/fuchsia-async", |
| "//src/lib/fuchsia-component", |
| "//src/lib/fuchsia-runtime", |
| "//src/lib/process_builder", |
| "//src/lib/syslog/rust:syslog", |
| "//src/lib/zerocopy", |
| "//src/lib/zircon/rust:fuchsia-zircon", |
| "//src/sys/lib/library_loader", |
| "//src/sys/lib/runner", |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:futures", |
| "//third_party/rust_crates:lazy_static", |
| "//third_party/rust_crates:log", |
| "//third_party/rust_crates:memchr", |
| "//third_party/rust_crates:parking_lot", |
| ] |
| |
| sources = [ |
| "executive.rs", |
| "fs/fd.rs", |
| "fs/fidl_file.rs", |
| "fs/mod.rs", |
| "loader.rs", |
| "main.rs", |
| "syscall_table.rs", |
| "syscalls.rs", |
| "types.rs", |
| ] |
| } |
| |
| fuchsia_component("starnix_component") { |
| component_name = "starnix" |
| deps = [ ":starnix_bin" ] |
| manifest = "meta/starnix.cml" |
| } |
| |
| fuchsia_unittest_package("starnix-tests") { |
| manifest = "meta/starnix-tests.cml" |
| deps = [ ":starnix_bin_test" ] |
| } |
| } |
| |
| rustc_macro("starnix_macros") { |
| deps = [ |
| "//third_party/rust_crates:proc-macro2", |
| "//third_party/rust_crates:quote", |
| "//third_party/rust_crates:syn", |
| ] |
| source_root = "macro.rs" |
| sources = [ |
| "macro.rs", |
| ] |
| } |
| |
| resource("hello_starnix_bin") { |
| # Switch these two |sources| declarations to test locally. |
| sources = [ "fixtures/hello_starnix.c" ] |
| |
| # sources = [ "fixtures/hello_starnix.bin" ] |
| |
| # We need to have this output in the package even when we do not actually have a |
| # hello_starnix.bin file in order for hello_starnix.cml to pass validation. |
| outputs = [ "bin/hello_starnix.bin" ] |
| } |
| |
| fuchsia_component("hello_starnix_component") { |
| component_name = "hello_starnix" |
| manifest = "meta/hello_starnix.cml" |
| |
| deps = [ ":hello_starnix_bin" ] |
| } |
| |
| fuchsia_package("hello_starnix") { |
| deps = [ ":hello_starnix_component" ] |
| } |
| |
| fuchsia_component("starnix_manager") { |
| manifest = "meta/starnix_manager.cml" |
| } |
| |
| fuchsia_package("pkg") { |
| package_name = "starnix" |
| |
| deps = [ ":starnix_manager" ] |
| |
| if (target_cpu == "x64") { |
| deps += [ ":starnix_component" ] |
| } |
| } |
| |
| template("tar_resource") { |
| main_target = target_name |
| untar_target = "${target_name}__untar" |
| manifest_file = "$target_gen_dir/$target_name.manifest.json" |
| action(untar_target) { |
| script = "tar_to_fini.py" |
| inputs = [ invoker.tarfile ] |
| outputs = [ manifest_file ] |
| depfile = "$target_gen_dir/$target_name.d" |
| args = [ |
| "--tar-file", |
| rebase_path(inputs[0], root_build_dir), |
| "--unpack-dir", |
| rebase_path("$target_gen_dir/$target_name", root_build_dir), |
| "--manifest-file", |
| rebase_path(manifest_file, root_build_dir), |
| "--dep-file", |
| rebase_path(depfile, root_build_dir), |
| ] |
| if (defined(invoker.subdir)) { |
| args += [ |
| "--package-subdir", |
| invoker.subdir, |
| ] |
| } |
| } |
| distribution_entries_from_fini(main_target) { |
| file = manifest_file |
| deps = [ ":$untar_target" ] |
| } |
| } |
| |
| tar_resource("android_system_image") { |
| tarfile = "//prebuilt/starnix/android-root-amd64/system.img.tar" |
| subdir = "root" |
| } |
| |
| fuchsia_package_with_single_component("android_starnix") { |
| manifest = "meta/android_starnix.cml" |
| deps = [ ":android_system_image" ] |
| |
| # This package intentionally contains many non-Fuchia ELF binaries that |
| # are not under /data/, and some of them are even unstripped, so disable |
| # theses checks to build successfully. |
| disable_elf_binaries_checks = true |
| } |
| |
| group("tests") { |
| testonly = true |
| |
| if (target_cpu == "x64") { |
| deps = [ ":starnix-tests" ] |
| } |
| } |