Skip to content

Commit aeae0f3

Browse files
[libc][bazel] add rules to build the scanf family
Now that scanf is a little cleaner, this patch adds rules to build it via bazel.
1 parent 5981335 commit aeae0f3

File tree

2 files changed

+212
-0
lines changed

2 files changed

+212
-0
lines changed

utils/bazel/llvm-project-overlay/libc/BUILD.bazel

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4611,6 +4611,178 @@ libc_function(
46114611
],
46124612
)
46134613

4614+
libc_support_library(
4615+
name = "scanf_config",
4616+
hdrs = ["src/stdio/scanf_core/scanf_config.h"],
4617+
deps = [
4618+
],
4619+
)
4620+
4621+
libc_support_library(
4622+
name = "scanf_core_structs",
4623+
hdrs = ["src/stdio/scanf_core/core_structs.h"],
4624+
deps = [
4625+
":__support_cpp_bitset",
4626+
":__support_cpp_string_view",
4627+
":__support_fputil_fp_bits",
4628+
":scanf_config",
4629+
],
4630+
)
4631+
4632+
libc_support_library(
4633+
name = "scanf_parser",
4634+
hdrs = ["src/stdio/scanf_core/parser.h"],
4635+
deps = [
4636+
":__support_arg_list",
4637+
":__support_cpp_bitset",
4638+
":__support_ctype_utils",
4639+
":__support_str_to_integer",
4640+
":scanf_config",
4641+
":scanf_core_structs",
4642+
],
4643+
)
4644+
4645+
libc_support_library(
4646+
name = "scanf_reader",
4647+
hdrs = ["src/stdio/scanf_core/reader.h"],
4648+
deps = [
4649+
":__support_cpp_string_view",
4650+
":__support_macros_attributes",
4651+
":types_FILE",
4652+
],
4653+
)
4654+
4655+
libc_support_library(
4656+
name = "scanf_converter",
4657+
srcs = [
4658+
"src/stdio/scanf_core/converter.cpp",
4659+
"src/stdio/scanf_core/float_converter.cpp",
4660+
"src/stdio/scanf_core/int_converter.cpp",
4661+
"src/stdio/scanf_core/ptr_converter.cpp",
4662+
"src/stdio/scanf_core/string_converter.cpp",
4663+
],
4664+
hdrs = [
4665+
"src/stdio/scanf_core/converter.h",
4666+
"src/stdio/scanf_core/converter_utils.h",
4667+
"src/stdio/scanf_core/current_pos_converter.h",
4668+
"src/stdio/scanf_core/float_converter.h",
4669+
"src/stdio/scanf_core/int_converter.h",
4670+
"src/stdio/scanf_core/ptr_converter.h",
4671+
"src/stdio/scanf_core/string_converter.h",
4672+
],
4673+
deps = [
4674+
":__support_char_vector",
4675+
":__support_cpp_bitset",
4676+
":__support_cpp_limits",
4677+
":__support_cpp_string_view",
4678+
":__support_ctype_utils",
4679+
":__support_str_to_float",
4680+
":scanf_core_structs",
4681+
":scanf_reader",
4682+
],
4683+
)
4684+
4685+
libc_support_library(
4686+
name = "scanf_main",
4687+
srcs = ["src/stdio/scanf_core/scanf_main.cpp"],
4688+
hdrs = ["src/stdio/scanf_core/scanf_main.h"],
4689+
deps = [
4690+
":__support_arg_list",
4691+
":scanf_config",
4692+
":scanf_converter",
4693+
":scanf_core_structs",
4694+
":scanf_parser",
4695+
":scanf_reader",
4696+
],
4697+
)
4698+
4699+
libc_support_library(
4700+
name = "vfscanf_internal",
4701+
hdrs = ["src/stdio/scanf_core/vfscanf_internal.h"],
4702+
deps = [
4703+
":__support_arg_list",
4704+
":__support_file_file",
4705+
":__support_macros_attributes",
4706+
":scanf_main",
4707+
":scanf_reader",
4708+
":types_FILE",
4709+
],
4710+
)
4711+
4712+
libc_function(
4713+
name = "scanf",
4714+
srcs = ["src/stdio/scanf.cpp"],
4715+
hdrs = ["src/stdio/scanf.h"],
4716+
deps = [
4717+
":__support_arg_list",
4718+
":__support_file_file",
4719+
":types_FILE",
4720+
":vfscanf_internal",
4721+
],
4722+
)
4723+
4724+
libc_function(
4725+
name = "vscanf",
4726+
srcs = ["src/stdio/vscanf.cpp"],
4727+
hdrs = ["src/stdio/vscanf.h"],
4728+
deps = [
4729+
":__support_arg_list",
4730+
":__support_file_file",
4731+
":types_FILE",
4732+
":vfscanf_internal",
4733+
],
4734+
)
4735+
4736+
libc_function(
4737+
name = "fscanf",
4738+
srcs = ["src/stdio/fscanf.cpp"],
4739+
hdrs = ["src/stdio/fscanf.h"],
4740+
deps = [
4741+
":__support_arg_list",
4742+
":__support_file_file",
4743+
":types_FILE",
4744+
":vfscanf_internal",
4745+
],
4746+
)
4747+
4748+
libc_function(
4749+
name = "vfscanf",
4750+
srcs = ["src/stdio/vfscanf.cpp"],
4751+
hdrs = ["src/stdio/vfscanf.h"],
4752+
deps = [
4753+
":__support_arg_list",
4754+
":__support_file_file",
4755+
":types_FILE",
4756+
":vfscanf_internal",
4757+
],
4758+
)
4759+
4760+
libc_function(
4761+
name = "sscanf",
4762+
srcs = ["src/stdio/sscanf.cpp"],
4763+
hdrs = ["src/stdio/sscanf.h"],
4764+
deps = [
4765+
":__support_arg_list",
4766+
":__support_file_file",
4767+
":scanf_main",
4768+
":scanf_reader",
4769+
":types_FILE",
4770+
],
4771+
)
4772+
4773+
libc_function(
4774+
name = "vsscanf",
4775+
srcs = ["src/stdio/vsscanf.cpp"],
4776+
hdrs = ["src/stdio/vsscanf.h"],
4777+
deps = [
4778+
":__support_arg_list",
4779+
":__support_file_file",
4780+
":scanf_main",
4781+
":scanf_reader",
4782+
":types_FILE",
4783+
],
4784+
)
4785+
46144786
libc_function(
46154787
name = "remove",
46164788
srcs = ["src/stdio/linux/remove.cpp"],

utils/bazel/llvm-project-overlay/libc/test/src/stdio/BUILD.bazel

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,43 @@ libc_test(
132132
"//libc:close",
133133
],
134134
)
135+
136+
libc_test(
137+
name = "sscanf_test",
138+
srcs = ["sscanf_test.cpp"],
139+
libc_function_deps = [
140+
"//libc:sscanf",
141+
],
142+
deps = [
143+
"//libc:__support_cpp_limits",
144+
"//libc:__support_fputil_fp_bits",
145+
"//libc:hdr_stdio_macros",
146+
"//libc/test/UnitTest:fp_test_helpers",
147+
],
148+
)
149+
150+
libc_test(
151+
name = "fscanf_test",
152+
srcs = ["fscanf_test.cpp"],
153+
libc_function_deps = [
154+
"//libc:fscanf",
155+
],
156+
deps = ["//libc:__support_cpp_string_view"],
157+
)
158+
159+
libc_test(
160+
name = "vsscanf_test",
161+
srcs = ["vsscanf_test.cpp"],
162+
libc_function_deps = [
163+
"//libc:vsscanf",
164+
],
165+
)
166+
167+
libc_test(
168+
name = "vfscanf_test",
169+
srcs = ["vfscanf_test.cpp"],
170+
libc_function_deps = [
171+
"//libc:vfscanf",
172+
],
173+
deps = ["//libc:__support_cpp_string_view"],
174+
)

0 commit comments

Comments
 (0)