| # Copyright 2025 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. | |
| # This lists all the different kinds of public headers that libc is responsible | |
| # for. See README.md for more details. These are in a separate .gni file so | |
| # that they can be used by the sysroot_entries.gni machinery and in BUILD.gn. | |
| libc_headers = { | |
| root_dir = "//sdk/lib/c/include" | |
| golden_gen_dir = "$root_dir/gen" | |
| # Each element of the list describes one of the directories where header file | |
| # sources are found. The comments for the first element give the schema. | |
| include_dirs = [ | |
| { | |
| # Files shared with llvm-libc. Eventually these will be the majority. | |
| # **NOTE:** This _must_ be first in the list! The logic below collects | |
| # header dependencies of generated headers. The $llvm_libc/include | |
| # headers provide some of the dependencies also needed by other headers. | |
| # Those names will be de-duplicated when they're found in later header | |
| # dependency lists, so they're only expected to exist in the first place | |
| # that lists them. | |
| # This is the source-absolute path of the source files for this set. | |
| dir = "//third_party/llvm-libc/src/include" | |
| # This must be defined to support generated headers. This file is | |
| # generated but then checked into the source tree. Note that all these | |
| # JSON files go into $root_dir, regardless of $dir. | |
| json_file = "llvm-libc-generated.json" | |
| json_data = read_file("$root_dir/$json_file", "json") | |
| # This lists all the public API header files. These are the headers that | |
| # users should include directly, and that should be tested for being used | |
| # standalone (roughly a proxy for each one being used before some other | |
| # particular header that may interact). Each `.yaml` file listed means | |
| # the corresponding `.h` file is generated from that YAML file; each `.h` | |
| # file listed is just used verbatim. | |
| public = [ | |
| "dlfcn.yaml", | |
| "fenv.yaml", | |
| "malloc.yaml", | |
| ] | |
| # This lists additional headers that are transitive dependencies of some | |
| # public header, but should not themselves be named directly by users. | |
| # The dependencies of generated headers are filled in automatically. | |
| sources = [] | |
| }, | |
| { | |
| # Files maintained here in $libc/include. These are Fuchsia inventions | |
| # and their only source of truth is right here. | |
| dir = root_dir | |
| json_file = "generated.json" | |
| json_data = read_file("$root_dir/$json_file", "json") | |
| public = [ | |
| "zircon/dlfcn.h", | |
| "zircon/lookup.h", | |
| "zircon/process.yaml", | |
| "zircon/sanitizer.h", | |
| "zircon/startup.h", | |
| "zircon/threads.h", | |
| "zircon/utc.h", | |
| ] | |
| sources = [] | |
| }, | |
| { | |
| # Files inherited from the legacy musl fork. These are maintained within | |
| # the source tree and have no other active source of truth, but they are | |
| # not original to Fuchsia. These will eventually be replaced or moved | |
| # elsewhere. | |
| dir = "//zircon/third_party/ulib/musl/include" | |
| public = [ | |
| "alloca.h", | |
| "ar.h", | |
| "arpa/ftp.h", | |
| "arpa/inet.h", | |
| "arpa/nameser.h", | |
| "arpa/nameser_compat.h", | |
| "arpa/telnet.h", | |
| "arpa/tftp.h", | |
| "assert.h", | |
| "byteswap.h", | |
| "complex.h", | |
| "cpio.h", | |
| "ctype.h", | |
| "dirent.h", | |
| "elf.h", | |
| "endian.h", | |
| "err.h", | |
| "errno.h", | |
| "fcntl.h", | |
| "features.h", | |
| "fnmatch.h", | |
| "getopt.h", | |
| "glob.h", | |
| "grp.h", | |
| "iconv.h", | |
| "ifaddrs.h", | |
| "inttypes.h", | |
| "iso646.h", | |
| "langinfo.h", | |
| "libgen.h", | |
| "limits.h", | |
| "link.h", | |
| "locale.h", | |
| "math.h", | |
| "memory.h", | |
| "monetary.h", | |
| "net/ethernet.h", | |
| "net/if.h", | |
| "net/if_arp.h", | |
| "net/route.h", | |
| "netdb.h", | |
| "netinet/ether.h", | |
| "netinet/icmp6.h", | |
| "netinet/if_ether.h", | |
| "netinet/igmp.h", | |
| "netinet/in.h", | |
| "netinet/in_systm.h", | |
| "netinet/ip.h", | |
| "netinet/ip6.h", | |
| "netinet/ip_icmp.h", | |
| "netinet/tcp.h", | |
| "netinet/udp.h", | |
| "netpacket/packet.h", | |
| "nl_types.h", | |
| "paths.h", | |
| "poll.h", | |
| "pthread.h", | |
| "pwd.h", | |
| "regex.h", | |
| "resolv.h", | |
| "sched.h", | |
| "semaphore.h", | |
| "setjmp.h", | |
| "signal.h", | |
| "spawn.h", | |
| "stdio.h", | |
| "stdlib.h", | |
| "string.h", | |
| "strings.h", | |
| "stropts.h", | |
| "sys/acct.h", | |
| "sys/auxv.h", | |
| "sys/dir.h", | |
| "sys/eventfd.h", | |
| "sys/file.h", | |
| "sys/inotify.h", | |
| "sys/io.h", | |
| "sys/ioctl.h", | |
| "sys/ipc.h", | |
| "sys/mman.h", | |
| "sys/mount.h", | |
| "sys/msg.h", | |
| "sys/mtio.h", | |
| "sys/param.h", | |
| "sys/random.h", | |
| "sys/select.h", | |
| "sys/sem.h", | |
| "sys/shm.h", | |
| "sys/socket.h", | |
| "sys/stat.h", | |
| "sys/statfs.h", | |
| "sys/statvfs.h", | |
| "sys/stropts.h", | |
| "sys/syslog.h", | |
| "sys/time.h", | |
| "sys/timeb.h", | |
| "sys/timerfd.h", | |
| "sys/times.h", | |
| "sys/ttydefaults.h", | |
| "sys/types.h", | |
| "sys/ucontext.h", | |
| "sys/uio.h", | |
| "sys/un.h", | |
| "sys/utsname.h", | |
| "sys/vfs.h", | |
| "sys/wait.h", | |
| "sysexits.h", | |
| "syslog.h", | |
| "tar.h", | |
| "termios.h", | |
| "threads.h", | |
| "time.h", | |
| "uchar.h", | |
| "ucontext.h", | |
| "unistd.h", | |
| "utime.h", | |
| "values.h", | |
| "wchar.h", | |
| "wctype.h", | |
| "wordexp.h", | |
| ] | |
| sources = [ | |
| "bits/aarch64/setjmp.h", | |
| "bits/alltypes.h", | |
| "bits/errno.h", | |
| "bits/io.h", | |
| "bits/ioctl.h", | |
| "bits/ipc.h", | |
| "bits/limits.h", | |
| "bits/null.h", | |
| "bits/poll.h", | |
| "bits/posix.h", | |
| "bits/resource.h", | |
| "bits/riscv64/setjmp.h", | |
| "bits/setjmp.h", | |
| "bits/signal.h", | |
| "bits/stat.h", | |
| "bits/statfs.h", | |
| "bits/termios.h", | |
| "bits/x86_64/io.h", | |
| "bits/x86_64/setjmp.h", | |
| "sys/errno.h", | |
| "sys/fcntl.h", | |
| "sys/poll.h", | |
| "sys/signal.h", | |
| "sys/termios.h", | |
| "wait.h", | |
| ] | |
| }, | |
| ] | |
| # These headers will get tested for standalone use. | |
| all_public_headers = [] | |
| # These headers will be installed as implementation dependencies. | |
| all_impl_headers = [] | |
| # This is in the format used by sysroot_entries.gni; it uses only this. | |
| sysroot_entries = [] | |
| # This lists the extra files that are read directly by | |
| # //build/bazel/fuchsia_idk/generate_repository.py | |
| idk_generate_inputs = [] | |
| _all_generated_headers = [] | |
| foreach(set, include_dirs) { | |
| all_public_headers += filter_exclude(set.public, [ "*.yaml" ]) | |
| all_impl_headers += set.sources | |
| # Read the metadata about the generated headers (if any). | |
| if (defined(set.json_file)) { | |
| idk_generate_inputs += [ "$root_dir/${set.json_file}" ] | |
| set.generated = [] | |
| foreach(header, set.json_data) { | |
| # Each generated header is public. | |
| set.generated += [ header.name ] | |
| all_public_headers += [ header.name ] | |
| # Each dependency is installed from this set if it wasn't already | |
| # installed from an earlier set. | |
| foreach(dep_header, filter_exclude(header.includes, [ "<*>" ])) { | |
| if (all_public_headers + all_impl_headers + [ dep_header ] - | |
| [ dep_header ] == all_public_headers + all_impl_headers) { | |
| set.sources += [ dep_header ] | |
| all_impl_headers += [ dep_header ] | |
| } | |
| } | |
| } | |
| # **NOTE:** When adding new generated headers, Ninja may give errors | |
| # about golden files not existing. If that happens, temporarily comment | |
| # out this line such that an `update_goldens=true` build can progress far | |
| # enough to create the golden files. Then uncomment it again so that the | |
| # sysroot population won't be all broken; after that just another build | |
| # iteration or two should right things fully. | |
| _all_generated_headers += set.generated | |
| } | |
| sysroot_entries += [ | |
| { | |
| sdk = { | |
| include_dir = set.dir | |
| headers = filter_exclude(set.public, [ "*.yaml" ]) + set.sources | |
| } | |
| }, | |
| ] | |
| } | |
| # The golden files for generated headers from all sets all go into the same | |
| # directory in the source tree, so they only need one entry here. | |
| sysroot_entries += [ | |
| { | |
| sdk = { | |
| include_dir = golden_gen_dir | |
| headers = _all_generated_headers | |
| # The deps must ensure they get generated before they're needed. | |
| deps = [ root_dir ] | |
| } | |
| }, | |
| ] | |
| } |