Skip to content

Commit 5518538

Browse files
authored
[bazel][libc] Add bazel support for a handful of string functions (#158327)
1 parent 0741209 commit 5518538

File tree

3 files changed

+315
-0
lines changed

3 files changed

+315
-0
lines changed

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

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5225,6 +5225,27 @@ libc_support_library(
52255225
],
52265226
)
52275227

5228+
libc_function(
5229+
name = "index",
5230+
srcs = ["src/strings/index.cpp"],
5231+
hdrs = ["src/strings/index.h"],
5232+
deps = [
5233+
":__support_common",
5234+
":string_utils",
5235+
],
5236+
)
5237+
5238+
libc_function(
5239+
name = "rindex",
5240+
srcs = ["src/strings/rindex.cpp"],
5241+
hdrs = ["src/strings/rindex.h"],
5242+
deps = [
5243+
":__support_common",
5244+
":__support_macros_null_check",
5245+
":string_utils",
5246+
],
5247+
)
5248+
52285249
libc_function(
52295250
name = "memchr",
52305251
srcs = ["src/string/memchr.cpp"],
@@ -5247,6 +5268,16 @@ libc_function(
52475268
],
52485269
)
52495270

5271+
libc_function(
5272+
name = "memccpy",
5273+
srcs = ["src/string/memccpy.cpp"],
5274+
hdrs = ["src/string/memccpy.h"],
5275+
deps = [
5276+
":__support_common",
5277+
":__support_macros_null_check",
5278+
],
5279+
)
5280+
52505281
libc_function(
52515282
name = "memset",
52525283
srcs = ["src/string/memset.cpp"],
@@ -5258,6 +5289,17 @@ libc_function(
52585289
],
52595290
)
52605291

5292+
libc_function(
5293+
name = "memset_explicit",
5294+
srcs = ["src/string/memset_explicit.cpp"],
5295+
hdrs = ["src/string/memset_explicit.h"],
5296+
deps = [
5297+
":__support_common",
5298+
":__support_macros_null_check",
5299+
":string_memory_utils",
5300+
],
5301+
)
5302+
52615303
libc_function(
52625304
name = "memmove",
52635305
srcs = ["src/string/memmove.cpp"],
@@ -5269,6 +5311,17 @@ libc_function(
52695311
],
52705312
)
52715313

5314+
libc_function(
5315+
name = "memmem",
5316+
srcs = ["src/string/memmem.cpp"],
5317+
hdrs = ["src/string/memmem.h"],
5318+
deps = [
5319+
":__support_common",
5320+
":__support_macros_null_check",
5321+
":string_memory_utils",
5322+
],
5323+
)
5324+
52725325
libc_function(
52735326
name = "mempcpy",
52745327
srcs = ["src/string/mempcpy.cpp"],
@@ -5333,6 +5386,30 @@ libc_function(
53335386
],
53345387
)
53355388

5389+
libc_function(
5390+
name = "stpcpy",
5391+
srcs = ["src/string/stpcpy.cpp"],
5392+
hdrs = ["src/string/stpcpy.h"],
5393+
deps = [
5394+
":__support_common",
5395+
":__support_macros_null_check",
5396+
":string_memory_utils",
5397+
":string_utils",
5398+
],
5399+
)
5400+
5401+
libc_function(
5402+
name = "stpncpy",
5403+
srcs = ["src/string/stpncpy.cpp"],
5404+
hdrs = ["src/string/stpncpy.h"],
5405+
deps = [
5406+
":__support_common",
5407+
":__support_macros_null_check",
5408+
":string_memory_utils",
5409+
":string_utils",
5410+
],
5411+
)
5412+
53365413
libc_function(
53375414
name = "strlen",
53385415
srcs = ["src/string/strlen.cpp"],
@@ -5356,6 +5433,17 @@ libc_function(
53565433
],
53575434
)
53585435

5436+
libc_function(
5437+
name = "strlcpy",
5438+
srcs = ["src/string/strlcpy.cpp"],
5439+
hdrs = ["src/string/strlcpy.h"],
5440+
deps = [
5441+
":__support_common",
5442+
":llvm_libc_types_size_t",
5443+
":string_utils",
5444+
],
5445+
)
5446+
53595447
libc_function(
53605448
name = "strncpy",
53615449
srcs = ["src/string/strncpy.cpp"],
@@ -5377,6 +5465,40 @@ libc_function(
53775465
],
53785466
)
53795467

5468+
libc_function(
5469+
name = "strncmp",
5470+
srcs = ["src/string/strncmp.cpp"],
5471+
hdrs = ["src/string/strncmp.h"],
5472+
deps = [
5473+
":__support_common",
5474+
":__support_macros_null_check",
5475+
":string_memory_utils",
5476+
":string_utils",
5477+
],
5478+
)
5479+
5480+
libc_function(
5481+
name = "strcasecmp",
5482+
srcs = ["src/strings/strcasecmp.cpp"],
5483+
hdrs = ["src/strings/strcasecmp.h"],
5484+
deps = [
5485+
":__support_common",
5486+
":__support_ctype_utils",
5487+
":string_memory_utils",
5488+
],
5489+
)
5490+
5491+
libc_function(
5492+
name = "strncasecmp",
5493+
srcs = ["src/strings/strncasecmp.cpp"],
5494+
hdrs = ["src/strings/strncasecmp.h"],
5495+
deps = [
5496+
":__support_common",
5497+
":__support_ctype_utils",
5498+
":string_memory_utils",
5499+
],
5500+
)
5501+
53805502
libc_function(
53815503
name = "strchr",
53825504
srcs = ["src/string/strchr.cpp"],
@@ -5397,6 +5519,16 @@ libc_function(
53975519
],
53985520
)
53995521

5522+
libc_function(
5523+
name = "strchrnul",
5524+
srcs = ["src/string/strchrnul.cpp"],
5525+
hdrs = ["src/string/strchrnul.h"],
5526+
deps = [
5527+
":__support_common",
5528+
":string_utils",
5529+
],
5530+
)
5531+
54005532
libc_function(
54015533
name = "strsep",
54025534
srcs = ["src/string/strsep.cpp"],
@@ -5422,6 +5554,51 @@ libc_function(
54225554
],
54235555
)
54245556

5557+
libc_function(
5558+
name = "strcasestr",
5559+
srcs = ["src/string/strcasestr.cpp"],
5560+
hdrs = ["src/string/strcasestr.h"],
5561+
deps = [
5562+
":__support_common",
5563+
":__support_ctype_utils",
5564+
":__support_macros_null_check",
5565+
":string_memory_utils",
5566+
":string_utils",
5567+
],
5568+
)
5569+
5570+
libc_function(
5571+
name = "strcat",
5572+
srcs = ["src/string/strcat.cpp"],
5573+
hdrs = ["src/string/strcat.h"],
5574+
deps = [
5575+
":__support_common",
5576+
":__support_macros_null_check",
5577+
":string_utils",
5578+
],
5579+
)
5580+
5581+
libc_function(
5582+
name = "strlcat",
5583+
srcs = ["src/string/strlcat.cpp"],
5584+
hdrs = ["src/string/strlcat.h"],
5585+
deps = [
5586+
":__support_common",
5587+
":string_utils",
5588+
],
5589+
)
5590+
5591+
libc_function(
5592+
name = "strncat",
5593+
srcs = ["src/string/strncat.cpp"],
5594+
hdrs = ["src/string/strncat.h"],
5595+
deps = [
5596+
":__support_common",
5597+
":__support_macros_null_check",
5598+
":string_utils",
5599+
],
5600+
)
5601+
54255602
libc_function(
54265603
name = "strnlen",
54275604
srcs = ["src/string/strnlen.cpp"],

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

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,33 @@ libc_test(
2727
],
2828
)
2929

30+
libc_test(
31+
name = "strlcpy_test",
32+
srcs = ["strlcpy_test.cpp"],
33+
deps = [
34+
"//libc:strlcpy",
35+
],
36+
)
37+
38+
libc_test(
39+
name = "stpcpy_test",
40+
srcs = ["stpcpy_test.cpp"],
41+
deps = [
42+
"//libc:stpcpy",
43+
"//libc:string_utils",
44+
],
45+
)
46+
47+
libc_test(
48+
name = "stpncpy_test",
49+
srcs = ["stpncpy_test.cpp"],
50+
deps = [
51+
"//libc:__support_cpp_span",
52+
"//libc:hdr_signal_macros",
53+
"//libc:stpncpy",
54+
],
55+
)
56+
3057
libc_test(
3158
name = "strcmp_test",
3259
srcs = ["strcmp_test.cpp"],
@@ -35,6 +62,14 @@ libc_test(
3562
],
3663
)
3764

65+
libc_test(
66+
name = "strncmp_test",
67+
srcs = ["strncmp_test.cpp"],
68+
deps = [
69+
"//libc:strncmp",
70+
],
71+
)
72+
3873
libc_test(
3974
name = "memchr_test",
4075
srcs = ["memchr_test.cpp"],
@@ -59,6 +94,14 @@ libc_test(
5994
],
6095
)
6196

97+
libc_test(
98+
name = "strchrnul_test",
99+
srcs = ["strchrnul_test.cpp"],
100+
deps = [
101+
"//libc:strchrnul",
102+
],
103+
)
104+
62105
libc_test(
63106
name = "strpbrk_test",
64107
srcs = ["strpbrk_test.cpp"],
@@ -110,6 +153,39 @@ libc_test(
110153
],
111154
)
112155

156+
libc_test(
157+
name = "strcasestr_test",
158+
srcs = ["strcasestr_test.cpp"],
159+
deps = [
160+
"//libc:strcasestr",
161+
],
162+
)
163+
164+
libc_test(
165+
name = "strcat_test",
166+
srcs = ["strcat_test.cpp"],
167+
deps = [
168+
"//libc:hdr_signal_macros",
169+
"//libc:strcat",
170+
],
171+
)
172+
173+
libc_test(
174+
name = "strlcat_test",
175+
srcs = ["strlcat_test.cpp"],
176+
deps = [
177+
"//libc:strlcat",
178+
],
179+
)
180+
181+
libc_test(
182+
name = "strncat_test",
183+
srcs = ["strncat_test.cpp"],
184+
deps = [
185+
"//libc:strncat",
186+
],
187+
)
188+
113189
libc_test(
114190
name = "strcspn_test",
115191
srcs = ["strcspn_test.cpp"],
@@ -178,6 +254,15 @@ libc_test(
178254
],
179255
)
180256

257+
libc_test(
258+
name = "memccpy_test",
259+
srcs = ["memccpy_test.cpp"],
260+
deps = [
261+
"//libc:__support_cpp_span",
262+
"//libc:memccpy",
263+
],
264+
)
265+
181266
libc_test(
182267
name = "mempcpy_test",
183268
srcs = ["mempcpy_test.cpp"],
@@ -199,6 +284,16 @@ libc_test(
199284
],
200285
)
201286

287+
libc_test(
288+
name = "memset_explicit_test",
289+
srcs = ["memset_explicit_test.cpp"],
290+
deps = [
291+
":memory_check_utils",
292+
"//libc:memset_explicit",
293+
"//libc:string_memory_utils",
294+
],
295+
)
296+
202297
libc_test(
203298
name = "memmove_test",
204299
srcs = ["memmove_test.cpp"],
@@ -222,3 +317,12 @@ libc_test(
222317
"//libc/test/UnitTest:test_logger",
223318
],
224319
)
320+
321+
libc_test(
322+
name = "memmem_test",
323+
srcs = ["memmem_test.cpp"],
324+
deps = [
325+
"//libc:memmem",
326+
"//libc:string_utils",
327+
],
328+
)

0 commit comments

Comments
 (0)