blob: 9da31fbcf2d748e76825389c2134ac2c799fc1cd [file] [log] [blame]
# Copyright 2018 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")
import("//build/rust/rustc_library.gni")
common_deps = [
"//src/lib/zerocopy/zerocopy-derive",
"//third_party/rust_crates:byteorder",
]
common_sources = [
"src/byteorder.rs",
"src/lib.rs",
]
common_test_deps = [ "//third_party/rust_crates:rand" ]
rustc_library("zerocopy") {
name = "zerocopy"
version = "0.1.0"
edition = "2021"
with_unit_tests = true
deps = common_deps
test_deps = common_test_deps
sources = common_sources
features = [ "alloc" ]
configs -= [ "//build/config/rust/lints:allow_unused_results" ]
}
rustc_library("zerocopy-noalloc") {
name = "zerocopy-noalloc"
version = "0.1.0"
edition = "2021"
with_unit_tests = true
deps = common_deps
test_deps = common_test_deps
sources = common_sources
features = []
configs -= [ "//build/config/rust/lints:allow_unused_results" ]
}
rustc_library("zerocopy-simd") {
name = "zerocopy-simd"
version = "0.1.0"
edition = "2021"
with_unit_tests = true
deps = common_deps
test_deps = common_test_deps
sources = common_sources
features = [ "simd" ]
# The "simd" feature is unstable because the layout of standard library SIMD
# types may change. This GN target exists only so that we build with the
# "simd" feature enabled in our build system in order to prevent bitrot.
#
# Note that the "simd-nightly" feature requires an unstable compiler feature
# which isn't supported by our build system, so we cannot build it in GN.
visibility = [ ":*" ]
configs -= [ "//build/config/rust/lints:allow_unused_results" ]
}
fuchsia_unittest_component("zerocopy-test-component") {
deps = [ ":zerocopy_test" ]
}
fuchsia_unittest_component("zerocopy-noalloc-test-component") {
deps = [ ":zerocopy-noalloc_test" ]
}
fuchsia_unittest_component("zerocopy-simd-test-component") {
deps = [ ":zerocopy-noalloc_test" ]
}
fuchsia_test_package("zerocopy-test-package") {
package_name = "zerocopy-test"
test_components = [
":zerocopy-noalloc-test-component",
":zerocopy-simd-test-component",
":zerocopy-test-component",
]
}
group("tests") {
testonly = true
public_deps = [
":zerocopy-noalloc_test($host_toolchain)",
":zerocopy-simd_test($host_toolchain)",
":zerocopy-test-package",
":zerocopy_test($host_toolchain)",
"zerocopy-derive:tests",
]
# Make sure that all features are at least compiled even if they're not used
# by any other Fuchsia code. Even though the `public_deps` above will cause
# the test target to be build (with `--cfg test` passed during compilation),
# they will not cause the non-test target to be built. We depend on those here
# to ensure that they're built as well.
deps = [
":zerocopy",
":zerocopy-noalloc",
":zerocopy-simd",
]
}