[Workflow] Roll back some settings since they caused more issues
[llvm-project.git] / libc / src / stdio / CMakeLists.txt
blob9c24c567b6c1d5bd33c92c9c0e51667510d61ee5
1 # Helper function that creates an alias if a target specific implementation
2 # exists, otherwise it uses a generic one.
3 function(add_stdio_entrypoint_object name)
4   if(TARGET libc.src.stdio.${LIBC_TARGET_OS}.${name})
5     add_entrypoint_object(
6       ${name}
7       ALIAS
8       DEPENDS
9         .${LIBC_TARGET_OS}.${name}
10     )
11   elseif(TARGET libc.src.stdio.generic.${name})
12     add_entrypoint_object(
13       ${name}
14       ALIAS
15       DEPENDS
16         .generic.${name}
17     )
18   endif()
19 endfunction(add_stdio_entrypoint_object)
21 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
22   add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
23 endif()
25 if(NOT LIBC_TARGET_ARCHITECTURE_IS_GPU)
26   add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/generic)
27 endif()
29 add_entrypoint_object(
30   fflush
31   SRCS
32     fflush.cpp
33   HDRS
34     fflush.h
35   DEPENDS
36     libc.src.errno.errno
37     libc.include.stdio
38     libc.src.__support.File.file
39     libc.src.__support.File.platform_file
42 add_entrypoint_object(
43   flockfile
44   SRCS
45     flockfile.cpp
46   HDRS
47     flockfile.h
48   DEPENDS
49     libc.include.stdio
50     libc.src.__support.File.file
51     libc.src.__support.File.platform_file
54 add_entrypoint_object(
55   funlockfile
56   SRCS
57     funlockfile.cpp
58   HDRS
59     funlockfile.h
60   DEPENDS
61     libc.include.stdio
62     libc.src.__support.File.file
63     libc.src.__support.File.platform_file
66 add_entrypoint_object(
67   fseek
68   SRCS
69     fseek.cpp
70   HDRS
71     fseek.h
72   DEPENDS
73     libc.src.errno.errno
74     libc.include.stdio
75     libc.src.__support.File.file
76     libc.src.__support.File.platform_file
79 add_entrypoint_object(
80   ungetc
81   SRCS
82     ungetc.cpp
83   HDRS
84     ungetc.h
85   DEPENDS
86     libc.include.stdio
87     libc.src.__support.File.file
88     libc.src.__support.File.platform_file
91 add_entrypoint_object(
92   fopencookie
93   SRCS
94     fopencookie.cpp
95   HDRS
96     fopencookie.h
97   DEPENDS
98     libc.include.stdio
99     libc.src.__support.CPP.new
100     libc.src.__support.File.file
103 add_entrypoint_object(
104   setbuf
105   SRCS
106     setbuf.cpp
107   HDRS
108     setbuf.h
109   DEPENDS
110     libc.src.errno.errno
111     libc.include.stdio
112     libc.src.__support.File.file
113     libc.src.__support.File.platform_file
116 add_entrypoint_object(
117   setvbuf
118   SRCS
119     setvbuf.cpp
120   HDRS
121     setvbuf.h
122   DEPENDS
123     libc.src.errno.errno
124     libc.include.stdio
125     libc.src.__support.File.file
126     libc.src.__support.File.platform_file
129 list(APPEND scanf_deps
130       libc.src.__support.arg_list
131       libc.src.stdio.scanf_core.vfscanf_internal
134 if(LLVM_LIBC_FULL_BUILD)
135   list(APPEND scanf_deps
136       libc.src.__support.File.file
137       libc.src.__support.File.platform_file
138       libc.src.__support.File.platform_stdin
139   )
140 else()
141   list(APPEND scanf_copts "-DLIBC_COPT_STDIO_USE_SYSTEM_FILE")
142 endif()
144 add_entrypoint_object(
145   sscanf
146   SRCS
147     sscanf.cpp
148   HDRS
149     sscanf.h
150   DEPENDS
151     libc.src.__support.arg_list
152     libc.src.stdio.scanf_core.reader
153     libc.src.stdio.scanf_core.scanf_main
156 add_entrypoint_object(
157   fscanf
158   SRCS
159     fscanf.cpp
160   HDRS
161     fscanf.h
162   DEPENDS
163     ${scanf_deps}
164   COMPILE_OPTIONS
165     ${scanf_copts}
168 add_entrypoint_object(
169   scanf
170   SRCS
171     scanf.cpp
172   HDRS
173     scanf.h
174   DEPENDS
175     ${scanf_deps}
176   COMPILE_OPTIONS
177     ${scanf_copts}
180 add_entrypoint_object(
181   sprintf
182   SRCS
183     sprintf.cpp
184   HDRS
185     sprintf.h
186   DEPENDS
187     libc.src.stdio.printf_core.printf_main
188     libc.src.stdio.printf_core.writer
191 add_entrypoint_object(
192   snprintf
193   SRCS
194     snprintf.cpp
195   HDRS
196     snprintf.h
197   DEPENDS
198     libc.src.stdio.printf_core.printf_main
199     libc.src.stdio.printf_core.writer
202 list(APPEND printf_deps
203       libc.src.__support.arg_list
204       libc.src.stdio.printf_core.vfprintf_internal
207 if(LIBC_CONF_PRINTF_DISABLE_FLOAT)
208   list(APPEND printf_copts "-DLIBC_COPT_PRINTF_DISABLE_FLOAT")
209 endif()
210 if(LIBC_CONF_PRINTF_DISABLE_INDEX_MODE)
211   list(APPEND printf_copts "-DLIBC_COPT_PRINTF_DISABLE_INDEX_MODE")
212 endif()
213 if(LIBC_CONF_PRINTF_DISABLE_WRITE_INT)
214   list(APPEND printf_copts "-DLIBC_COPT_PRINTF_DISABLE_WRITE_INT")
215 endif()
216 if(LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE)
217   list(APPEND printf_copts "-DLIBC_COPT_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE")
218 endif()
220 if(LLVM_LIBC_FULL_BUILD)
221   list(APPEND printf_deps
222       libc.src.__support.File.file
223       libc.src.__support.File.platform_file
224       libc.src.__support.File.platform_stdout
225   )
226 else()
227   list(APPEND printf_copts "-DLIBC_COPT_STDIO_USE_SYSTEM_FILE")
228 endif()
230 add_entrypoint_object(
231   printf
232   SRCS
233     printf.cpp
234   HDRS
235     printf.h
236   DEPENDS
237     ${printf_deps}
238   COMPILE_OPTIONS
239     ${printf_copts}
242 add_entrypoint_object(
243   fprintf
244   SRCS
245     fprintf.cpp
246   HDRS
247     fprintf.h
248   DEPENDS
249     libc.src.__support.arg_list
250     libc.src.stdio.printf_core.vfprintf_internal
251   COMPILE_OPTIONS
252     ${printf_copts}
255 add_entrypoint_object(
256   vsprintf
257   SRCS
258     vsprintf.cpp
259   HDRS
260     vsprintf.h
261   DEPENDS
262     libc.src.stdio.printf_core.printf_main
263     libc.src.stdio.printf_core.writer
266 add_entrypoint_object(
267   vsnprintf
268   SRCS
269     vsnprintf.cpp
270   HDRS
271     vsnprintf.h
272   DEPENDS
273     libc.src.stdio.printf_core.printf_main
274     libc.src.stdio.printf_core.writer
277 add_entrypoint_object(
278   vprintf
279   SRCS
280     vprintf.cpp
281   HDRS
282     vprintf.h
283   DEPENDS
284     ${printf_deps}
285   COMPILE_OPTIONS
286     ${printf_copts}
289 add_entrypoint_object(
290   vfprintf
291   SRCS
292     vfprintf.cpp
293   HDRS
294     vfprintf.h
295   DEPENDS
296     libc.src.__support.arg_list
297     libc.src.stdio.printf_core.vfprintf_internal
298   COMPILE_OPTIONS
299     ${printf_copts}
302 add_subdirectory(printf_core)
303 add_subdirectory(scanf_core)
305 add_entrypoint_object(
306   ftell
307   SRCS
308     ftell.cpp
309   HDRS
310     ftell.h
311   DEPENDS
312     libc.src.errno.errno
313     libc.include.stdio
314     libc.src.__support.File.file
315     libc.src.__support.File.platform_file
318 add_entrypoint_object(
319   remove
320   ALIAS
321   DEPENDS
322     .${LIBC_TARGET_OS}.remove
325 # These entrypoints have multiple potential implementations.
326 add_stdio_entrypoint_object(feof)
327 add_stdio_entrypoint_object(feof_unlocked)
328 add_stdio_entrypoint_object(ferror)
329 add_stdio_entrypoint_object(ferror_unlocked)
330 add_stdio_entrypoint_object(clearerr)
331 add_stdio_entrypoint_object(clearerr_unlocked)
332 add_stdio_entrypoint_object(fopen)
333 add_stdio_entrypoint_object(fclose)
334 add_stdio_entrypoint_object(fread_unlocked)
335 add_stdio_entrypoint_object(fread)
336 add_stdio_entrypoint_object(puts)
337 add_stdio_entrypoint_object(fputs)
338 add_stdio_entrypoint_object(fwrite_unlocked)
339 add_stdio_entrypoint_object(fwrite)
340 add_stdio_entrypoint_object(fputc)
341 add_stdio_entrypoint_object(putc)
342 add_stdio_entrypoint_object(putchar)
343 add_stdio_entrypoint_object(fgetc)
344 add_stdio_entrypoint_object(fgetc_unlocked)
345 add_stdio_entrypoint_object(getc)
346 add_stdio_entrypoint_object(getc_unlocked)
347 add_stdio_entrypoint_object(getchar)
348 add_stdio_entrypoint_object(getchar_unlocked)
349 add_stdio_entrypoint_object(fgets)
350 add_stdio_entrypoint_object(stdin)
351 add_stdio_entrypoint_object(stdout)
352 add_stdio_entrypoint_object(stderr)