blob: 74fdc6fd5927ec261f41c73a3ac2248fbc8c1975 [file] [log] [blame]
# 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/components.gni")
import("//build/components/fuchsia_unittest_component.gni")
import("//build/fidl/fidl.gni")
import("//build/rust/rustc_binary.gni")
import("//build/rust/rustc_library.gni")
import("//build/rust/rustc_macro.gni")
import("//src/storage/fs_test/suite.gni")
# Set to true to enable tracing. For now this cannot be enabled by default due to
# https://fxbug.dev/66819#c88. Enabling it trips an LSAN bug that is triggered by the
# implementation of trace_provider_create_with_fdio.
tracing_enabled = false
fxfs_deps = [
":serialize-macros",
"//src/lib/async-utils",
"//src/lib/fuchsia-async",
"//src/lib/storage/storage_device",
"//src/storage/lib/interval_tree",
"//third_party/rust_crates:anyhow",
"//third_party/rust_crates:async-lock",
"//third_party/rust_crates:async-trait",
"//third_party/rust_crates:bincode",
"//third_party/rust_crates:byteorder",
"//third_party/rust_crates:either-v1_5_0",
"//third_party/rust_crates:event-listener",
"//third_party/rust_crates:futures",
"//third_party/rust_crates:log",
"//third_party/rust_crates:once_cell",
"//third_party/rust_crates:pin-project",
"//third_party/rust_crates:rand",
"//third_party/rust_crates:serde",
"//third_party/rust_crates:slab",
"//third_party/rust_crates:thiserror",
]
fxfs_test_deps = [ "//third_party/rust_crates:matches" ]
fxfs_sources = [
"src/debug_assert_not_too_long.rs",
"src/errors.rs",
"src/lib.rs",
"src/lsm_tree.rs",
"src/lsm_tree/merge.rs",
"src/lsm_tree/simple_persistent_layer.rs",
"src/lsm_tree/skip_list_layer.rs",
"src/lsm_tree/types.rs",
"src/mkfs.rs",
"src/mount.rs",
"src/object_handle.rs",
"src/object_store.rs",
"src/object_store/allocator.rs",
"src/object_store/allocator/merge.rs",
"src/object_store/caching_object_handle.rs",
"src/object_store/constants.rs",
"src/object_store/crypt.rs",
"src/object_store/data_buffer.rs",
"src/object_store/directory.rs",
"src/object_store/extent_record.rs",
"src/object_store/filesystem.rs",
"src/object_store/fsck.rs",
"src/object_store/fsck/errors.rs",
"src/object_store/fsck/store_scanner.rs",
"src/object_store/fsck/tests.rs",
"src/object_store/graveyard.rs",
"src/object_store/journal.rs",
"src/object_store/journal/checksum_list.rs",
"src/object_store/journal/handle.rs",
"src/object_store/journal/reader.rs",
"src/object_store/journal/super_block.rs",
"src/object_store/journal/writer.rs",
"src/object_store/merge.rs",
"src/object_store/object_manager.rs",
"src/object_store/object_record.rs",
"src/object_store/store_object_handle.rs",
"src/object_store/testing.rs",
"src/object_store/testing/fake_allocator.rs",
"src/object_store/testing/fake_filesystem.rs",
"src/object_store/transaction.rs",
"src/object_store/tree.rs",
"src/object_store/volume.rs",
"src/object_store/writeback_cache.rs",
"src/range.rs",
"src/round.rs",
"src/serialized_types/mod.rs",
"src/serialized_types/test_traits.rs",
"src/serialized_types/tests.rs",
"src/serialized_types/traits.rs",
"src/testing.rs",
"src/testing/fake_object.rs",
"src/trace.rs",
]
if (is_fuchsia) {
fxfs_deps += [
":fuchsia.fxfs-rustc",
"//sdk/fidl/fuchsia.fs:fuchsia.fs-rustc",
"//sdk/fidl/fuchsia.hardware.block:fuchsia.hardware.block-rustc",
"//sdk/fidl/fuchsia.io:fuchsia.io-rustc",
"//sdk/fidl/fuchsia.io2:fuchsia.io2-rustc",
"//sdk/fidl/fuchsia.mem:fuchsia.mem-rustc",
"//src/lib/fdio/rust:fdio",
"//src/lib/fidl/rust/fidl",
"//src/lib/fuchsia-component",
"//src/lib/fuchsia-runtime",
"//src/lib/storage/block_client/rust:remote-block-device",
"//src/lib/storage/vfs/rust:vfs",
"//src/lib/zircon/rust:fuchsia-zircon",
]
if (tracing_enabled) {
fxfs_deps += [ "//src/lib/trace/rust:trace" ]
}
fxfs_test_deps += [
":fxfs-test-manifest",
"//garnet/lib/rust/files_async",
"//garnet/lib/rust/io_util",
"//src/lib/storage/fs_management/rust:fs_management",
]
fxfs_sources += [
"src/object_store/vmo_data_buffer.rs",
"src/pager.rs",
"src/remote_crypt.rs",
"src/server.rs",
"src/server/device.rs",
"src/server/directory.rs",
"src/server/errors.rs",
"src/server/file.rs",
"src/server/node.rs",
"src/server/testing.rs",
"src/server/volume.rs",
]
}
rustc_macro("serialize-macros") {
name = "serialize-macros"
deps = [
"//third_party/rust_crates:proc-macro2",
"//third_party/rust_crates:quote",
"//third_party/rust_crates:syn",
]
source_root = "src/serialized_types/macros.rs"
sources = [ "src/serialized_types/macros.rs" ]
}
rustc_library("lib") {
edition = "2018"
with_unit_tests = true
name = "fxfs"
deps = fxfs_deps
sources = fxfs_sources
test_deps = fxfs_test_deps
if (tracing_enabled && is_fuchsia) {
features = [ "tracing" ]
}
}
group("fxfs-test-manifest") {
metadata = {
test_component_manifest_cml = [
{
use = [
{
# This allows tests to launch BlobFS
protocol = [ "fuchsia.process.Launcher" ]
},
]
},
]
}
}
fuchsia_unittest_component("fxfs-test") {
deps = [ ":lib_test" ]
}
fuchsia_test_package("fxfs-tests") {
test_components = [ ":fxfs-test" ]
}
rustc_binary("fxfs") {
edition = "2018"
deps = [
":fuchsia.fxfs-rustc",
":lib",
"//src/lib/fuchsia-async",
"//src/lib/fuchsia-component",
"//src/lib/fuchsia-runtime",
"//src/lib/storage/block_client/rust:remote-block-device",
"//src/lib/storage/storage_device",
"//src/lib/syslog/rust:syslog",
"//src/lib/trace/rust:trace-provider",
"//src/lib/zircon/rust:fuchsia-zircon",
"//third_party/rust_crates:anyhow",
"//third_party/rust_crates:argh",
"//third_party/rust_crates:log",
]
sources = [ "src/main.rs" ]
if (tracing_enabled && is_fuchsia) {
features = [ "tracing" ]
}
}
fuchsia_shell_package("fxfs-bin") {
deps = [ ":fxfs" ]
}
fidl("fuchsia.fxfs") {
sources = [ "fidl/fxfs.fidl" ]
public_deps = [
"//sdk/fidl/fuchsia.io",
"//zircon/vdso/zx",
]
}
fs_test_config("fxfs") {
timestamp_granularity = 1
supports_hard_links = true
supports_resize = true
supports_mmap = true
supports_mmap_shared_write = false
max_file_size = 9223372036854775807
options = [
{
description = "Fxfs"
use_fvm = false
has_min_volume_size = true
device_block_count = 24576
device_block_size = 512
},
]
}
fs_test_suite("fxfs") {
deps = [
":fxfs_fs_test_config",
"//src/storage/fxfs",
]
}
slow_fs_test_suite("fxfs") {
deps = [
":fxfs_fs_test_config",
"//src/storage/fxfs",
]
}
group("tests") {
testonly = true
deps = [
":fxfs-fs-tests",
":fxfs-slow-fs-tests",
":fxfs-tests",
":lib_test($host_toolchain)",
]
}