blob: 78ff0ce0f27cabf79bc3c47351a765314f9dd65c [file] [log] [blame]
# Copyright 2019 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/fidl/fidl.gni")
import("//build/rust/rustc_binary.gni")
import("//build/rust/rustc_library.gni")
import("//build/test/test_package.gni")
import("//build/testing/environments.gni")
rustc_library("process_builder") {
with_unit_tests = true
edition = "2018"
deps = [
"//src/lib/fidl/rust/fidl",
"//src/lib/fuchsia-async",
"//src/lib/fuchsia-runtime",
"//src/lib/zerocopy",
"//src/lib/zircon/rust:fuchsia-zircon",
"//third_party/rust_crates:anyhow",
"//third_party/rust_crates:bitflags",
"//third_party/rust_crates:futures",
"//third_party/rust_crates:lazy_static",
"//third_party/rust_crates:log",
"//third_party/rust_crates:num-derive",
"//third_party/rust_crates:num-traits",
"//third_party/rust_crates:owning_ref",
"//third_party/rust_crates:static_assertions",
"//third_party/rust_crates:thiserror",
"//zircon/system/fidl/fuchsia-io:fuchsia-io-rustc",
"//zircon/system/fidl/fuchsia-ldsvc:fuchsia-ldsvc-rustc",
"//zircon/system/fidl/fuchsia-process:fuchsia-process-rustc",
]
# TODO(46774): Fix the leaks and remove this.
non_rust_deps = [ "//build/config/sanitizers:suppress-lsan.DO-NOT-USE-THIS" ]
# Test-only deps. Prefer adding deps used only in tests here instead of
# above, which has the benefit of keeping unneeded deps out of the production
# library and allows depending on 'testonly' targets.
test_deps = [
":test-util-fidl-rustc",
"//src/lib/fdio/rust:fdio",
"//src/lib/storage/pseudo-fs",
]
}
group("tests") {
testonly = true
data_deps = [ ":process_builder_tests" ]
}
rustc_binary("root_job_test_runner") {
testonly = true
edition = "2018"
source_root = "root_job_test_runner/main.rs"
deps = [
"//garnet/examples/fidl/services:echo-rustc",
"//garnet/lib/rust/io_util",
"//src/lib/fdio/rust:fdio",
"//src/lib/fidl/rust/fidl",
"//src/lib/fuchsia-async",
"//src/lib/fuchsia-component",
"//src/lib/zircon/rust:fuchsia-zircon",
"//third_party/rust_crates:anyhow",
"//third_party/rust_crates:futures",
"//third_party/rust_crates:thiserror",
"//zircon/system/fidl/fuchsia-boot:fuchsia-boot-rustc",
]
# TODO(46556): Fix the leaks and remove this.
non_rust_deps = [ "//build/config/sanitizers:suppress-lsan.DO-NOT-USE-THIS" ]
}
fidl("test-util-fidl") {
# TODO(TC-582): Still can't use testonly here :(
# testonly = true
name = "test.processbuilder"
sources = [ "test_util.test.fidl" ]
}
rustc_binary("test_util") {
testonly = true
name = "process_builder_test_util"
edition = "2018"
source_root = "test/test_util.rs"
deps = [
":test-util-fidl-rustc",
"//src/lib/fidl/rust/fidl",
"//src/lib/fuchsia-async",
"//src/lib/fuchsia-component",
"//src/lib/fuchsia-runtime",
"//src/lib/zircon/rust:fuchsia-zircon",
"//third_party/rust_crates:anyhow",
"//third_party/rust_crates:futures",
"//third_party/rust_crates:thiserror",
]
}
config("static-pie-config") {
visibility = [ ":*" ]
cflags = [
"-fno-sanitize=all",
"-fno-stack-protector",
]
ldflags = [
"-nostdlib",
"-Wl,-no-dynamic-linker",
]
}
# This is used to test the library's handling of statically linked PIE
# executables. Warning: Don't copy this unless you know what you're doing.
executable("static_pie_test_util") {
testonly = true
sources = [ "test/static_pie_test_util.c" ]
configs += [ ":static-pie-config" ]
# Profiling instrumentation needs to be disabled too, but
# is not covered by `-fno-sanitize=all`.
if (toolchain_variant.name == "profile") {
configs -= [ "//build/config/profile" ]
}
}
test_package("process_builder_tests") {
rootjob_svc = "//build"
deps = [
":process_builder_test",
":root_job_test_runner",
":static_pie_test_util",
":test_util",
]
binaries = [
{
name = "root_job_test_runner"
},
{
name = "process_builder_test_util"
},
{
name = "static_pie_test_util"
},
]
tests = [
{
name = "process_builder_lib_test"
dest = "process_builder_tests"
environments = basic_envs
},
]
}