blob: 76d67c5ec7085eadcbeac2c4a85d0a48d148fe10 [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/components/fuchsia_component.gni")
import("//build/zircon/zx_library.gni")
template("memfs_lib") {
static_library(target_name) {
public = [
"memfs.h",
"vnode.h",
"vnode_dir.h",
"vnode_file.h",
"vnode_vmo.h",
]
sources = [
"dnode.cc",
"include/lib/memfs/memfs.h",
"memfs.cc",
"vnode.cc",
"vnode_dir.cc",
"vnode_file.cc",
"vnode_vmo.cc",
]
public_deps = [
# <memfs.h> has #include "src/lib/storage/vfs/*.h"
"//src/lib/storage/vfs/cpp",
"//zircon/system/ulib/async-loop:async-loop-cpp",
]
deps = [
"//sdk/lib/syslog/cpp",
"//zircon/system/ulib/async",
"//zircon/system/ulib/async:async-cpp",
"//zircon/system/ulib/fbl",
"//zircon/system/ulib/sync",
"//zircon/third_party/ulib/safemath",
]
forward_variables_from(invoker, [ "defines" ])
}
}
# The in-memory filesystem implementation.
#
# Most users will want to consume the shared library rather than statically linking this
# implementation. To do that, either use the "memfs" target (C) or the "cpp" target (C++).
memfs_lib("lib") {
}
# A memfs implementation that supports client side streams. This implementation uses un-stabilized
# syscalls. All components that include this library must enable "use_next_vdso".
#
# TODO(fxbug.dev/95299): Consolidate with ":lib" once zx_pager_query_vmo_stats stabilizes.
memfs_lib("lib-with-client-side-streams") {
defines = [ "MEMFS_ENABLE_CLIENT_SIDE_STREAMS" ]
}
# libmemfs.so: The C ABI client library.
#
# Used to create local temporary filesystems.
zx_library("memfs") {
sdk = "shared"
sdk_publishable = true
sdk_headers = [ "lib/memfs/memfs.h" ]
sources = [ "memfs_api.cc" ]
public_deps = [
# <lib/memfs/memfs.h> has #include <lib/async/dispatcher.h>.
"//zircon/system/ulib/async",
# <lib/memfs/memfs.h> has #include <lib/sync/completion.h>.
"//zircon/system/ulib/sync",
]
deps = [
":lib",
"//sdk/lib/fdio",
"//src/lib/storage/vfs/cpp",
"//zircon/system/ulib/fbl",
]
runtime_deps = [
"//sdk/lib/fdio:fdio_sdk",
"//zircon/system/ulib/trace-engine:trace-engine_sdk",
]
}
# A C++ wrapper around the C "memfs" shared library that handles setup and tear-down.
source_set("cpp") {
public = [ "scoped_memfs.h" ]
public_deps = [
":memfs",
"//sdk/fidl/fuchsia.io:fuchsia.io_cpp_wire",
]
}
executable("memfs_bin") {
output_name = "memfs"
sources = [ "component.cc" ]
deps = [
":lib",
"//sdk/lib/syslog/cpp",
"//zircon/system/ulib/async-loop:async-loop-cpp",
"//zircon/system/ulib/async-loop:async-loop-default",
]
}
fuchsia_component("memfs_component") {
manifest = "meta/memfs.cml"
component_name = "memfs"
deps = [ ":memfs_bin" ]
}
group("tests") {
testonly = true
deps = [ "test:tests" ]
}