Skip to content

Commit 7f5a2cb

Browse files
[libc][bazel] add targets to build the scanf family (#128082)
Now that scanf is a little cleaner, this patch adds rules to build it via bazel.
1 parent 61c6e00 commit 7f5a2cb

File tree

2 files changed

+210
-0
lines changed

2 files changed

+210
-0
lines changed

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

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

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