381 changes: 227 additions & 154 deletions libc/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,53 @@ add_header(
__llvm-libc-common.h
)

add_gen_header(
macro(add_header_macro TARGET_NAME YAML_FILE DEF_FILE GEN_HDR DEPENDS)
if (LIBC_USE_NEW_HEADER_GEN)
add_gen_header2(
${TARGET_NAME}
YAML_FILE ${YAML_FILE}
DEF_FILE ${DEF_FILE}
GEN_HDR ${GEN_HDR}
${DEPENDS}
${ARGN}
)
else()
add_gen_header(
${TARGET_NAME}
DEF_FILE ${DEF_FILE}
GEN_HDR ${GEN_HDR}
${DEPENDS}
${ARGN}
)
endif()
endmacro()

add_header_macro(
ctype
DEF_FILE ctype.h.def
GEN_HDR ctype.h
../libc/newhdrgen/yaml/ctype.yaml
ctype.h.def
ctype.h
DEPENDS
.llvm_libc_common_h
)

add_gen_header(
add_header_macro(
dirent
DEF_FILE dirent.h.def
GEN_HDR dirent.h
../libc/newhdrgen/yaml/dirent.yaml
dirent.h.def
dirent.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-types.ino_t
.llvm-libc-types.DIR
.llvm-libc-types.struct_dirent
)

add_gen_header(
add_header_macro(
fcntl
DEF_FILE fcntl.h.def
GEN_HDR fcntl.h
../libc/newhdrgen/yaml/fcntl.yaml
fcntl.h.def
fcntl.h
DEPENDS
.llvm-libc-macros.fcntl_macros
.llvm-libc-types.mode_t
Expand All @@ -51,73 +75,81 @@ add_gen_header(
.llvm_libc_common_h
)

add_gen_header(
add_header_macro(
dlfcn
DEF_FILE dlfcn.h.def
GEN_HDR dlfcn.h
../libc/newhdrgen/yaml/dlfcn.yaml
dlfcn.h.def
dlfcn.h
DEPENDS
.llvm-libc-macros.dlfcn_macros
.llvm_libc_common_h
)

add_gen_header(
add_header_macro(
features
DEF_FILE features.h.def
GEN_HDR features.h
../libc/newhdrgen/yaml/features.yaml
features.h.def
features.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.features_macros
)

add_gen_header(
add_header_macro(
fenv
DEF_FILE fenv.h.def
GEN_HDR fenv.h
../libc/newhdrgen/yaml/fenv.yaml
fenv.h.def
fenv.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.fenv_macros
.llvm-libc-types.fenv_t
.llvm-libc-types.fexcept_t
)

add_gen_header(
add_header_macro(
inttypes
DEF_FILE inttypes.h.def
GEN_HDR inttypes.h
../libc/newhdrgen/yaml/inttypes.yaml
inttypes.h.def
inttypes.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-types.imaxdiv_t
.llvm-libc-macros.inttypes_macros
)

add_gen_header(
add_header_macro(
float
DEF_FILE float.h.def
GEN_HDR float.h
../libc/newhdrgen/yaml/float.yaml
float.h.def
float.h
DEPENDS
.llvm-libc-macros.float_macros
)

add_gen_header(
add_header_macro(
stdint
DEF_FILE stdint.h.def
GEN_HDR stdint.h
../libc/newhdrgen/yaml/stdint.yaml
stdint.h.def
stdint.h
DEPENDS
.llvm-libc-macros.stdint_macros
)

add_gen_header(
add_header_macro(
limits
DEF_FILE limits.h.def
GEN_HDR limits.h
../libc/newhdrgen/yaml/limits.yaml
limits.h.def
limits.h
DEPENDS
.llvm-libc-macros.limits_macros
)

add_gen_header(
add_header_macro(
math
DEF_FILE math.h.def
GEN_HDR math.h
../libc/newhdrgen/yaml/math.yaml
math.h.def
math.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.float16_macros
Expand All @@ -128,66 +160,73 @@ add_gen_header(
.llvm-libc-types.float128
)

add_gen_header(
add_header_macro(
stdfix
DEF_FILE stdfix.h.def
GEN_HDR stdfix.h
../libc/newhdrgen/yaml/stdfix.yaml
stdfix.h.def
stdfix.h
DEPENDS
.llvm-libc-macros.stdfix_macros
)

# TODO: This should be conditional on POSIX networking being included.
file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/arpa)

add_gen_header(
add_header_macro(
arpa_inet
DEF_FILE arpa/inet.h.def
GEN_HDR arpa/inet.h
../libc/newhdrgen/yaml/arpa/arpa_inet.yaml
arpa/inet.h.def
arpa/inet.h
DEPENDS
.llvm_libc_common_h
)

add_gen_header(
add_header_macro(
assert
DEF_FILE assert.h.def
GEN_HDR assert.h
../libc/newhdrgen/yaml/assert.yaml
assert.h.def
assert.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.assert_macros
)

add_gen_header(
add_header_macro(
setjmp
DEF_FILE setjmp.h.def
GEN_HDR setjmp.h
../libc/newhdrgen/yaml/setjmp.yaml
setjmp.h.def
setjmp.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-types.jmp_buf
)

add_gen_header(
add_header_macro(
string
DEF_FILE string.h.def
GEN_HDR string.h
../libc/newhdrgen/yaml/string.yaml
string.h.def
string.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.null_macro
.llvm-libc-types.size_t
)

add_gen_header(
add_header_macro(
strings
DEF_FILE strings.h.def
GEN_HDR strings.h
../libc/newhdrgen/yaml/strings.yaml
strings.h.def
strings.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-types.size_t
)

add_gen_header(
add_header_macro(
search
DEF_FILE search.h.def
GEN_HDR search.h
../libc/newhdrgen/yaml/search.yaml
search.h.def
search.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-types.ACTION
Expand All @@ -196,10 +235,11 @@ add_gen_header(
.llvm-libc-types.size_t
)

add_gen_header(
add_header_macro(
time
DEF_FILE time.h.def
GEN_HDR time.h
../libc/newhdrgen/yaml/time.yaml
time.h.def
time.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.time_macros
Expand All @@ -211,10 +251,11 @@ add_gen_header(
.llvm-libc-types.clockid_t
)

add_gen_header(
add_header_macro(
threads
DEF_FILE threads.h.def
GEN_HDR threads.h
../libc/newhdrgen/yaml/threads.yaml
threads.h.def
threads.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-types.__call_once_func_t
Expand All @@ -227,19 +268,21 @@ add_gen_header(
.llvm-libc-types.tss_dtor_t
)

add_gen_header(
add_header_macro(
errno
DEF_FILE errno.h.def
GEN_HDR errno.h
../libc/newhdrgen/yaml/errno.yaml
errno.h.def
errno.h
DEPENDS
.llvm-libc-macros.generic_error_number_macros
.llvm-libc-macros.error_number_macros
)

add_gen_header(
add_header_macro(
signal
DEF_FILE signal.h.def
GEN_HDR signal.h
../libc/newhdrgen/yaml/signal.yaml
signal.h.def
signal.h
DEPENDS
.llvm-libc-macros.signal_macros
.llvm-libc-types.sig_atomic_t
Expand All @@ -251,28 +294,31 @@ add_gen_header(
.llvm-libc-types.pid_t
)

add_gen_header(
add_header_macro(
stdbit
DEF_FILE stdbit.h.def
GEN_HDR stdbit.h
../libc/newhdrgen/yaml/stdbit.yaml
stdbit.h.def
stdbit.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.stdbit_macros
)

add_gen_header(
add_header_macro(
stdckdint
DEF_FILE stdckdint.h.def
GEN_HDR stdckdint.h
../libc/newhdrgen/yaml/stdckdint.yaml
stdckdint.h.def
stdckdint.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.stdckdint_macros
)

add_gen_header(
add_header_macro(
stdio
DEF_FILE stdio.h.def
GEN_HDR stdio.h
../libc/newhdrgen/yaml/stdio.yaml
stdio.h.def
stdio.h
DEPENDS
.llvm-libc-macros.file_seek_macros
.llvm-libc-macros.stdio_macros
Expand All @@ -284,10 +330,11 @@ add_gen_header(
.llvm_libc_common_h
)

add_gen_header(
add_header_macro(
stdlib
DEF_FILE stdlib.h.def
GEN_HDR stdlib.h
../libc/newhdrgen/yaml/stdlib.yaml
stdlib.h.def
stdlib.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.stdlib_macros
Expand All @@ -301,10 +348,11 @@ add_gen_header(
.llvm-libc-types.__atexithandler_t
)

add_gen_header(
add_header_macro(
unistd
DEF_FILE unistd.h.def
GEN_HDR unistd.h
../libc/newhdrgen/yaml/unistd.yaml
unistd.h.def
unistd.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.file_seek_macros
Expand All @@ -319,10 +367,11 @@ add_gen_header(
.llvm-libc-types.__getoptargv_t
)

add_gen_header(
add_header_macro(
pthread
DEF_FILE pthread.h.def
GEN_HDR pthread.h
../libc/newhdrgen/yaml/pthread.yaml
pthread.h.def
pthread.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-types.__atfork_callback_t
Expand All @@ -340,10 +389,11 @@ add_gen_header(
.llvm-libc-types.pthread_t
)

add_gen_header(
add_header_macro(
sched
DEF_FILE sched.h.def
GEN_HDR sched.h
../libc/newhdrgen/yaml/sched.yaml
sched.h.def
sched.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.sched_macros
Expand All @@ -356,10 +406,11 @@ add_gen_header(
.llvm-libc-types.struct_timespec
)

add_gen_header(
add_header_macro(
spawn
DEF_FILE spawn.h.def
GEN_HDR spawn.h
../libc/newhdrgen/yaml/spawn.yaml
spawn.h.def
spawn.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-types.mode_t
Expand All @@ -373,19 +424,21 @@ add_gen_header(
# them.
file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/sys)

add_gen_header(
add_header_macro(
sys_auxv
DEF_FILE sys/auxv.h.def
GEN_HDR sys/auxv.h
../libc/newhdrgen/yaml/sys/sys_auxv.yaml
sys/auxv.h.def
sys/auxv.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.sys_auxv_macros
)

add_gen_header(
add_header_macro(
sys_epoll
DEF_FILE sys/epoll.h.def
GEN_HDR sys/epoll.h
../libc/newhdrgen/yaml/sys/sys_epoll.yaml
sys/epoll.h.def
sys/epoll.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-types.struct_epoll_event
Expand All @@ -394,19 +447,21 @@ add_gen_header(
.llvm-libc-macros.sys_epoll_macros
)

add_gen_header(
add_header_macro(
sys_ioctl
DEF_FILE sys/ioctl.h.def
GEN_HDR sys/ioctl.h
../libc/newhdrgen/yaml/sys/sys_ioctl.yaml
sys/ioctl.h.def
sys/ioctl.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.sys_ioctl_macros
)

add_gen_header(
add_header_macro(
sys_mman
DEF_FILE sys/mman.h.def
GEN_HDR sys/mman.h
../libc/newhdrgen/yaml/sys/sys_mman.yaml
sys/mman.h.def
sys/mman.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.sys_mman_macros
Expand All @@ -415,10 +470,11 @@ add_gen_header(
.llvm-libc-types.ssize_t
)

add_gen_header(
add_header_macro(
sys_prctl
DEF_FILE sys/prctl.h.def
GEN_HDR sys/prctl.h
../libc/newhdrgen/yaml/sys/sys_prctl.yaml
sys/prctl.h.def
sys/prctl.h
DEPENDS
.llvm_libc_common_h
)
Expand All @@ -431,32 +487,35 @@ add_header(
.llvm-libc-macros.sys_queue_macros
)

add_gen_header(
add_header_macro(
sys_random
DEF_FILE sys/random.h.def
GEN_HDR sys/random.h
../libc/newhdrgen/yaml/sys/sys_random.yaml
sys/random.h.def
sys/random.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.sys_random_macros
.llvm-libc-types.size_t
.llvm-libc-types.ssize_t
)

add_gen_header(
add_header_macro(
sys_resource
DEF_FILE sys/resource.h.def
GEN_HDR sys/resource.h
../libc/newhdrgen/yaml/sys/sys_resource.yaml
sys/resource.h.def
sys/resource.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.sys_resource_macros
.llvm-libc-types.rlim_t
.llvm-libc-types.struct_rlimit
)

add_gen_header(
add_header_macro(
sys_stat
DEF_FILE sys/stat.h.def
GEN_HDR sys/stat.h
../libc/newhdrgen/yaml/sys/sys_stat.yaml
sys/stat.h.def
sys/stat.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.sys_stat_macros
Expand All @@ -474,10 +533,11 @@ add_gen_header(
.llvm-libc-types.struct_stat
)

add_gen_header(
add_header_macro(
sys_select
DEF_FILE sys/select.h.def
GEN_HDR sys/select.h
../libc/newhdrgen/yaml/sys/sys_select.yaml
sys/select.h.def
sys/select.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.sys_select_macros
Expand All @@ -489,21 +549,23 @@ add_gen_header(
.llvm-libc-types.struct_timeval
)

add_gen_header(
add_header_macro(
sys_sendfile
DEF_FILE sys/sendfile.h.def
GEN_HDR sys/sendfile.h
../libc/newhdrgen/yaml/sys/sys_sendfile.yaml
sys/sendfile.h.def
sys/sendfile.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-types.off_t
.llvm-libc-types.size_t
.llvm-libc-types.ssize_t
)

add_gen_header(
add_header_macro(
sys_socket
DEF_FILE sys/socket.h.def
GEN_HDR sys/socket.h
../libc/newhdrgen/yaml/sys/sys_socket.yaml
sys/socket.h.def
sys/socket.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.sys_socket_macros
Expand All @@ -513,35 +575,40 @@ add_gen_header(
.llvm-libc-types.struct_sockaddr_un
)

add_gen_header(
add_header_macro(
sys_statvfs
DEF_FILE sys/statvfs.h.def
GEN_HDR sys/statvfs.h
../libc/newhdrgen/yaml/sys/sys_statvfs.yaml
sys/statvfs.h.def
sys/statvfs.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-types.struct_statvfs
)

add_gen_header(
add_header_macro(
sys_syscall
DEF_FILE sys/syscall.h.def
GEN_HDR sys/syscall.h
../libc/newhdrgen/yaml/sys/sys_syscall.yaml
sys/syscall.h.def
sys/syscall.h
DEPENDS
)

add_gen_header(
add_header_macro(
sys_time
DEF_FILE sys/time.h.def
GEN_HDR sys/time.h
../libc/newhdrgen/yaml/sys/sys_time.yaml
sys/time.h.def
sys/time.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-types.struct_timeval
.llvm-libc-macros.sys_time_macros
)

add_gen_header(
add_header_macro(
sys_types
DEF_FILE sys/types.h.def
GEN_HDR sys/types.h
../libc/newhdrgen/yaml/sys/sys_types.yaml
sys/types.h.def
sys/types.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-types.blkcnt_t
Expand All @@ -567,19 +634,21 @@ add_gen_header(
.llvm-libc-types.uid_t
)

add_gen_header(
add_header_macro(
sys_utsname
DEF_FILE sys/utsname.h.def
GEN_HDR sys/utsname.h
../libc/newhdrgen/yaml/sys/sys_utsname.yaml
sys/utsname.h.def
sys/utsname.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-types.struct_utsname
)

add_gen_header(
add_header_macro(
sys_wait
DEF_FILE sys/wait.h.def
GEN_HDR sys/wait.h
../libc/newhdrgen/yaml/sys/sys_wait.yaml
sys/wait.h.def
sys/wait.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.sys_wait_macros
Expand All @@ -588,10 +657,11 @@ add_gen_header(
.llvm-libc-types.siginfo_t
)

add_gen_header(
add_header_macro(
termios
DEF_FILE termios.h.def
GEN_HDR termios.h
../libc/newhdrgen/yaml/termios.yaml
termios.h.def
termios.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.termios_macros
Expand All @@ -602,10 +672,11 @@ add_gen_header(
.llvm-libc-types.tcflag_t
)

add_gen_header(
add_header_macro(
uchar
DEF_FILE uchar.h.def
GEN_HDR uchar.h
../libc/newhdrgen/yaml/uchar.yaml
uchar.h.def
uchar.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-types.mbstate_t
Expand All @@ -614,10 +685,11 @@ add_gen_header(
.llvm-libc-types.char32_t
)

add_gen_header(
add_header_macro(
wchar
DEF_FILE wchar.h.def
GEN_HDR wchar.h
../libc/newhdrgen/yaml/wchar.yaml
wchar.h.def
wchar.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-macros.wchar_macros
Expand All @@ -630,10 +702,11 @@ add_gen_header(
if(LIBC_TARGET_OS_IS_GPU)
file(MAKE_DIRECTORY ${LIBC_INCLUDE_DIR}/gpu)

add_gen_header(
add_header_macro(
gpu_rpc
DEF_FILE gpu/rpc.h.def
GEN_HDR gpu/rpc.h
../libc/newhdrgen/yaml/gpu/rpc.yaml
gpu/rpc.h.def
gpu/rpc.h
DEPENDS
.llvm_libc_common_h
.llvm-libc-types.rpc_opcodes_t
Expand Down Expand Up @@ -703,4 +776,4 @@ if(LLVM_LIBC_FULL_BUILD)
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
# Stripping is a no-op for headers
add_custom_target(install-libc-headers-stripped DEPENDS install-libc-headers)
endif()
endif()