aboutsummaryrefslogtreecommitdiff
path: root/libc/src/stdio/printf_core/CMakeLists.txt
blob: 02819ea25ea055405f1a3af67b5c5c28b574f18e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
if(LIBC_CONF_PRINTF_DISABLE_FLOAT)
  list(APPEND printf_config_copts "-DLIBC_COPT_PRINTF_DISABLE_FLOAT")
endif()
if(LIBC_CONF_PRINTF_DISABLE_INDEX_MODE)
  list(APPEND printf_config_copts "-DLIBC_COPT_PRINTF_DISABLE_INDEX_MODE")
endif()
if(LIBC_CONF_PRINTF_DISABLE_WRITE_INT)
  list(APPEND printf_config_copts "-DLIBC_COPT_PRINTF_DISABLE_WRITE_INT")
endif()
if(LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE)
  list(APPEND printf_config_copts "-DLIBC_COPT_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE")
endif()
if(LIBC_CONF_PRINTF_DISABLE_FIXED_POINT)
  list(APPEND printf_config_copts "-DLIBC_COPT_PRINTF_DISABLE_FIXED_POINT")
endif()
if(printf_config_copts)
  list(PREPEND printf_config_copts "COMPILE_OPTIONS")
endif()

add_header_library(
  printf_config
  HDRS
    printf_config.h
  ${printf_config_copts}
)

add_header_library(
  core_structs
  HDRS
    core_structs.h
  DEPENDS
    libc.src.__support.CPP.string_view
    libc.src.__support.FPUtil.fp_bits
)

add_header_library(
  parser
  HDRS
    parser.h
  DEPENDS
    .core_structs
    libc.src.__support.arg_list
    libc.src.__support.ctype_utils
    libc.src.__support.str_to_integer
    libc.src.__support.CPP.bit
    libc.src.__support.CPP.optional
    libc.src.__support.CPP.string_view
    libc.src.__support.CPP.type_traits
    libc.src.__support.common
)

add_object_library(
  writer
  SRCS
    writer.cpp
  HDRS
    writer.h
  DEPENDS
    .core_structs
    libc.src.__support.CPP.string_view
    libc.src.__support.macros.optimization
    libc.src.string.memory_utils.inline_memcpy
    libc.src.string.memory_utils.inline_memset
)

add_object_library(
  converter
  SRCS
    converter.cpp
  HDRS
    converter.h
    converter_atlas.h
    converter_utils.h
    string_converter.h
    char_converter.h
    int_converter.h
    ptr_converter.h
    write_int_converter.h
    float_inf_nan_converter.h
    float_hex_converter.h
    float_dec_converter.h
    fixed_converter.h #TODO: Check if this should be disabled when fixed unavail
  DEPENDS
    .writer
    .core_structs
    .printf_config
    libc.src.__support.CPP.limits
    libc.src.__support.CPP.span
    libc.src.__support.CPP.string_view
    libc.src.__support.FPUtil.fp_bits
    libc.src.__support.FPUtil.fenv_impl
    libc.src.__support.FPUtil.rounding_mode
    libc.src.__support.common
    libc.src.__support.libc_assert
    libc.src.__support.uint
    libc.src.__support.uint128
    libc.src.__support.integer_to_string
    libc.src.__support.float_to_string
)


add_object_library(
  printf_main
  SRCS
    printf_main.cpp
  HDRS
    printf_main.h
  DEPENDS
    .parser
    .converter
    .writer
    .core_structs
    libc.src.__support.arg_list
)

if(NOT (TARGET libc.src.__support.File.file) AND LLVM_LIBC_FULL_BUILD)
  # Not all platforms have a file implementation. If file is unvailable, and a
  # full build is requested, then we must skip all file based printf sections.
  return()
endif()

add_header_library(
  vfprintf_internal
  HDRS
    vfprintf_internal.h
  DEPENDS
    libc.include.stdio
    libc.src.__support.File.file
    libc.src.__support.arg_list
    libc.src.stdio.printf_core.printf_main
    libc.src.stdio.printf_core.writer
  ${use_system_file}
)