• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1add_subdirectory(assert)
2add_subdirectory(ctype)
3add_subdirectory(errno)
4add_subdirectory(fenv)
5add_subdirectory(math)
6add_subdirectory(signal)
7add_subdirectory(stdio)
8add_subdirectory(stdlib)
9add_subdirectory(string)
10add_subdirectory(sys)
11add_subdirectory(threads)
12add_subdirectory(time)
13add_subdirectory(unistd)
14
15set(public_test ${CMAKE_CURRENT_BINARY_DIR}/public_integration_test.cpp)
16
17set(entrypoints_name_list "")
18foreach(entry IN LISTS TARGET_LIBC_ENTRYPOINTS TARGET_LIBM_ENTRYPOINTS)
19  get_target_property(entry_name ${entry} "ENTRYPOINT_NAME")
20  list(APPEND entrypoints_name_list ${entry_name})
21endforeach()
22
23# TODO: Remove these when they are added to the TableGen.
24list(REMOVE_ITEM entrypoints_name_list "__assert_fail" "__errno_location")
25list(TRANSFORM entrypoints_name_list PREPEND "-e=")
26
27file(GLOB spec_files ${LIBC_SOURCE_DIR}/spec/*.td)
28
29# Generate integration test souce code.
30add_custom_command(
31  OUTPUT ${public_test}
32  COMMAND $<TARGET_FILE:libc-prototype-testgen> -o ${public_test}
33          ${entrypoints_name_list}
34          -I ${LIBC_SOURCE_DIR}
35          ${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td
36
37  DEPENDS ${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/api.td ${spec_files}
38          libc-prototype-testgen ${TARGET_PUBLIC_HEADERS}
39          llvmlibc llvmlibm
40)
41
42add_executable(
43  libc-integration-test
44  EXCLUDE_FROM_ALL
45  ${public_test}
46)
47# Blank out default include directories to prevent accidentally including
48# system headers or our own internal headers.
49set_target_properties(
50  libc-integration-test
51  PROPERTIES
52  INCLUDE_DIRECTORIES ""
53)
54# Only include we need is the include for cpp::IsSame and our generated
55# public headers.
56target_include_directories(
57  libc-integration-test BEFORE
58  PRIVATE
59    "${LIBC_SOURCE_DIR}/utils/CPP"
60    "${LIBC_BUILD_DIR}/include"
61)
62target_compile_options(
63  libc-integration-test
64  PRIVATE
65  -ffreestanding
66)
67target_link_options(
68  libc-integration-test
69  PRIVATE "-nostdlib"
70)
71set(library_files)
72foreach(library_name IN LISTS "llvmlibc;llvmlibm")
73  get_target_property(library_file ${library_name} "LIBRARY_FILE")
74  list(APPEND library_files ${library_file})
75endforeach()
76
77if(COMPILER_RESOURCE_DIR AND LLVM_LIBC_ENABLE_LINTING)
78  add_custom_target(
79    libc-integration-test-tidy
80    VERBATIM
81    COMMAND $<TARGET_FILE:clang-tidy> --system-headers
82      --checks=-*,llvmlibc-restrict-system-libc-headers
83      "--extra-arg=-resource-dir=${COMPILER_RESOURCE_DIR}"
84      --header-filter=.*
85      --warnings-as-errors=llvmlibc-*
86      "-config={CheckOptions: [{key: llvmlibc-restrict-system-libc-headers.Includes, value: '-*, linux/*, asm/*.h, asm-generic/*.h'}]}"
87      --quiet
88      -p ${PROJECT_BINARY_DIR}
89      ${public_test}
90    DEPENDS
91      clang-tidy ${public_test}
92  )
93  add_dependencies(libc-integration-test libc-integration-test-tidy)
94endif()
95
96target_link_libraries(libc-integration-test
97  PRIVATE
98  ${library_files}
99)
100