Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 23 additions & 34 deletions libc/src/stdio/scanf_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ if(scanf_config_copts)
list(PREPEND scanf_config_copts "COMPILE_OPTIONS")
endif()


list(APPEND file_deps libc.hdr.types.FILE)
if(LIBC_TARGET_OS_IS_GPU)
list(APPEND file_deps
libc.src.stdio.getc
libc.src.stdio.ungetc
libc.src.stdio.ferror
)
elseif(LLVM_LIBC_FULL_BUILD)
list(APPEND file_deps
libc.src.__support.File.file
)
endif()

add_header_library(
scanf_config
HDRS
Expand Down Expand Up @@ -52,30 +66,19 @@ add_object_library(
.converter
.core_structs
libc.src.__support.arg_list
${file_deps}
${use_system_file}
)

if(LIBC_TARGET_OS_IS_GPU)
add_header_library(
reader
HDRS
reader.h
DEPENDS
libc.src.__support.macros.attributes
libc.src.stdio.getc
libc.src.stdio.ungetc
)
elseif((TARGET libc.src.__support.File.file) OR (NOT LLVM_LIBC_FULL_BUILD))
add_header_library(
reader
HDRS
reader.h
DEPENDS
libc.src.__support.macros.attributes
libc.hdr.types.FILE
libc.src.__support.File.file
${file_deps}
${use_system_file}
)
endif()

add_object_library(
converter
Expand Down Expand Up @@ -103,33 +106,19 @@ add_object_library(
libc.src.__support.CPP.limits
libc.src.__support.char_vector
libc.src.__support.str_to_float
${file_deps}
${use_system_file}
)

if(LIBC_TARGET_OS_IS_GPU)
add_header_library(
vfscanf_internal
HDRS
vfscanf_internal.h
DEPENDS
.reader
.scanf_main
libc.include.stdio
libc.src.__support.arg_list
libc.src.stdio.getc
libc.src.stdio.ungetc
libc.src.stdio.ferror
)
elseif(TARGET libc.src.__support.File.file OR (NOT LLVM_LIBC_FULL_BUILD))
add_header_library(
#TODO: condense the file-related code as possible.
add_header_library(
vfscanf_internal
HDRS
vfscanf_internal.h
DEPENDS
.reader
.scanf_main
libc.include.stdio
libc.src.__support.File.file
libc.src.__support.arg_list
${file_deps}
${use_system_file}
)
endif()
)
15 changes: 9 additions & 6 deletions libc/test/src/stdio/scanf_core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
if(NOT(LLVM_LIBC_FULL_BUILD))
# in overlay mode, use the system's file to test the reader.
set(use_system_file "-DLIBC_COPT_STDIO_USE_SYSTEM_FILE")
endif()

add_libc_unittest(
parser_test
SUITE
Expand All @@ -22,14 +27,10 @@ add_libc_unittest(
DEPENDS
libc.src.stdio.scanf_core.reader
libc.src.__support.CPP.string_view
COMPILE_OPTIONS
${use_system_file}
)

if(NOT (TARGET libc.src.__support.File.file))
# Not all platforms have a file implementation. If file is unvailable,
# then we must skip all the parts that need file.
return()
endif()

add_libc_unittest(
converter_test
SUITE
Expand All @@ -40,4 +41,6 @@ add_libc_unittest(
libc.src.stdio.scanf_core.reader
libc.src.stdio.scanf_core.converter
libc.src.__support.CPP.string_view
COMPILE_OPTIONS
${use_system_file}
)
Loading