| # 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/zircon/zx_library.gni") |
| import("//tools/cppdocgen/cpp_docgen.gni") |
| |
| group("tests") { |
| testonly = true |
| deps = [ "tests" ] |
| } |
| |
| config("fdio_includes") { |
| include_dirs = [ "include" ] |
| } |
| |
| if (is_fuchsia) { |
| zx_library("fdio-spawn-actions") { |
| configs += [ "//build/config:all_source" ] |
| sdk = "source" |
| sdk_publishable = "partner" |
| sdk_headers = [ "lib/fdio/spawn-actions.h" ] |
| |
| deps = [ |
| ":fdio", |
| "//zircon/system/ulib/zx", |
| ] |
| } |
| } |
| |
| fdio_constants = [ |
| "include/lib/fdio/limits.h", |
| "include/lib/fdio/vfs.h", |
| ] |
| |
| # This target provides access to some shared constants and helper macros, without requiring fdio as |
| # a runtime dependency. This target must never provide (or reference) any public/extern symbols. |
| sdk_source_set("constants") { |
| category = "partner" |
| sdk_name = "fdio_constants" |
| include_base = "//sdk" |
| public_configs = [ ":fdio_includes" ] |
| sources = fdio_constants |
| } |
| |
| # Headers exposed by fdio that we also want to use for the documentation target. |
| fdio_public_headers = [ |
| "include/lib/fdio/directory.h", |
| "include/lib/fdio/fd.h", |
| "include/lib/fdio/fdio.h", |
| "include/lib/fdio/io.h", |
| "include/lib/fdio/namespace.h", |
| "include/lib/fdio/spawn.h", |
| "include/lib/fdio/unsafe.h", |
| "include/lib/fdio/watcher.h", |
| ] + fdio_constants |
| |
| # TODO(https://fxbug.dev/42113953): This is a kludge to make "foosan-fuzzer" builds actually just use |
| # the plain "foosan" build of libfdio. This works around the problem that |
| # libfuzzer itself calls into libfdio and so its own calls pollute the data |
| # it's collecting about the code under test. We explicitly depend on the build |
| # that has the same foosan instrumentation to catch bugs but doesn't have the |
| # fuzzer (i.e. coverage tracking) instrumentation that influences libfuzzer's |
| # choices. |
| # |
| # In Fuchsia's GN, this requires a `select_variant` scope in args.gn must |
| # specify the "foosan" varaint for the toolchain variant to be available. |
| # `fx set`ensures this by adding a `select_variant` scope for libfdio.so itself |
| # with its "-fuzz-with" parameter. |
| if (is_fuzzer) { |
| group("fdio") { |
| suffix = string_replace(toolchain_variant.suffix, "-fuzzer", "") |
| public_deps = [ ":fdio(${toolchain_variant.base}${suffix})" ] |
| public_configs = [ ":fdio_includes" ] |
| } |
| } else if (is_fuchsia) { |
| zx_library("fdio") { |
| configs += [ "//build/config:all_source" ] |
| sdk = "shared" |
| sdk_publishable = "partner" |
| |
| # This list is relative to the include/ directory. |
| sdk_headers = rebase_path(fdio_public_headers, "include") |
| |
| sources = [ |
| "bsdsocket.cc", |
| "directory.cc", |
| "directory_internal.h", |
| "errno.cc", |
| "event.cc", |
| "fd.cc", |
| "fdio.cc", |
| "fdio_slot.cc", |
| "fdio_slot.h", |
| "fdio_state.cc", |
| "fdio_state.h", |
| "fdio_unistd.cc", |
| "fdio_unistd.h", |
| "get_client.h", |
| "internal.h", |
| "io.cc", |
| "iovec.cc", |
| "mem.cc", |
| "namespace/local-connection.cc", |
| "namespace/local-filesystem.cc", |
| "namespace/local-vnode.cc", |
| "namespace/namespace.cc", |
| "null.cc", |
| "remoteio.cc", |
| "socket.cc", |
| "socket.h", |
| "spawn.cc", |
| "stubs.cc", |
| "timer.cc", |
| "uname.cc", |
| "unistd.cc", |
| "unistd.h", |
| "unsafe.cc", |
| "waitable.cc", |
| "watcher.cc", |
| "zxio.cc", |
| "zxio.h", |
| ] |
| deps = [ |
| ":cleanpath", |
| "//sdk/fidl/fuchsia.device:fuchsia.device_cpp", |
| "//sdk/fidl/fuchsia.io:fuchsia.io_cpp", |
| "//sdk/fidl/fuchsia.net:fuchsia.net_cpp", |
| "//sdk/fidl/fuchsia.net.name:fuchsia.net.name_cpp", |
| "//sdk/fidl/fuchsia.posix.socket:fuchsia.posix.socket_cpp", |
| "//sdk/fidl/fuchsia.posix.socket.packet:fuchsia.posix.socket.packet_cpp", |
| "//sdk/fidl/fuchsia.posix.socket.raw:fuchsia.posix.socket.raw_cpp", |
| "//sdk/fidl/fuchsia.process:fuchsia.process_cpp", |
| "//sdk/lib/fidl", |
| "//sdk/lib/fit", |
| "//sdk/lib/zxio", |
| "//sdk/lib/zxio:inception", |
| "//zircon/system/ulib/fbl", |
| "//zircon/system/ulib/zircon-internal", |
| "//zircon/system/ulib/zx", |
| "//zircon/third_party/ulib/musl:getifaddrs-internal", |
| "//zircon/third_party/ulib/safemath", |
| ] |
| |
| fdio_version_script = "fdio.ld" |
| symbols_api = "fdio.ifs" |
| inputs = [ fdio_version_script ] |
| ldflags = [ "-Wl,--version-script=" + |
| rebase_path(fdio_version_script, root_build_dir) ] |
| |
| configs += [ |
| # TODO(https://fxbug.dev/42085293): delete the below and fix compiler warnings |
| "//build/config:Wno-vla-cxx-extension", |
| |
| # TODO(b/331282813): 'ENODATA' is deprecated in ISO C++, disable the warning for now. |
| "//build/config:Wno-deprecated-pragma", |
| ] |
| } |
| } else { |
| source_set("fdio") { |
| public_configs = [ ":fdio_includes" ] |
| } |
| } |
| |
| source_set("cleanpath") { |
| visibility = [ |
| ":*", |
| "tests:*", |
| ] |
| sources = [ |
| "cleanpath.cc", |
| "cleanpath.h", |
| ] |
| deps = [ "//zircon/system/ulib/fbl" ] |
| } |
| |
| cpp_docgen("docs") { |
| headers = fdio_public_headers |
| overview = "README.md" |
| |
| include_dir = "include" |
| library_name = "fdio" |
| reference_repo_path = "sdk/lib/fdio" |
| deps = [ ":fdio" ] |
| } |