Skip to content

Commit 1b72552

Browse files
committed
[bazel][libc] Add bazel support for a handful of string functions
1 parent b8eaceb commit 1b72552

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
@@ -5223,6 +5223,27 @@ libc_support_library(
52235223
],
52245224
)
52255225

5226+
libc_function(
5227+
name = "index",
5228+
srcs = ["src/strings/index.cpp"],
5229+
hdrs = ["src/strings/index.h"],
5230+
deps = [
5231+
":__support_common",
5232+
":string_utils",
5233+
],
5234+
)
5235+
5236+
libc_function(
5237+
name = "rindex",
5238+
srcs = ["src/strings/rindex.cpp"],
5239+
hdrs = ["src/strings/rindex.h"],
5240+
deps = [
5241+
":__support_common",
5242+
":__support_macros_null_check",
5243+
":string_utils",
5244+
],
5245+
)
5246+
52265247
libc_function(
52275248
name = "memchr",
52285249
srcs = ["src/string/memchr.cpp"],
@@ -5245,6 +5266,16 @@ libc_function(
52455266
],
52465267
)
52475268

5269+
libc_function(
5270+
name = "memccpy",
5271+
srcs = ["src/string/memccpy.cpp"],
5272+
hdrs = ["src/string/memccpy.h"],
5273+
deps = [
5274+
":__support_common",
5275+
":__support_macros_null_check",
5276+
],
5277+
)
5278+
52485279
libc_function(
52495280
name = "memset",
52505281
srcs = ["src/string/memset.cpp"],
@@ -5256,6 +5287,17 @@ libc_function(
52565287
],
52575288
)
52585289

5290+
libc_function(
5291+
name = "memset_explicit",
5292+
srcs = ["src/string/memset_explicit.cpp"],
5293+
hdrs = ["src/string/memset_explicit.h"],
5294+
deps = [
5295+
":__support_common",
5296+
":__support_macros_null_check",
5297+
":string_memory_utils",
5298+
],
5299+
)
5300+
52595301
libc_function(
52605302
name = "memmove",
52615303
srcs = ["src/string/memmove.cpp"],
@@ -5267,6 +5309,17 @@ libc_function(
52675309
],
52685310
)
52695311

5312+
libc_function(
5313+
name = "memmem",
5314+
srcs = ["src/string/memmem.cpp"],
5315+
hdrs = ["src/string/memmem.h"],
5316+
deps = [
5317+
":__support_common",
5318+
":__support_macros_null_check",
5319+
":string_memory_utils",
5320+
],
5321+
)
5322+
52705323
libc_function(
52715324
name = "mempcpy",
52725325
srcs = ["src/string/mempcpy.cpp"],
@@ -5331,6 +5384,30 @@ libc_function(
53315384
],
53325385
)
53335386

5387+
libc_function(
5388+
name = "stpcpy",
5389+
srcs = ["src/string/stpcpy.cpp"],
5390+
hdrs = ["src/string/stpcpy.h"],
5391+
deps = [
5392+
":__support_common",
5393+
":__support_macros_null_check",
5394+
":string_memory_utils",
5395+
":string_utils",
5396+
],
5397+
)
5398+
5399+
libc_function(
5400+
name = "stpncpy",
5401+
srcs = ["src/string/stpncpy.cpp"],
5402+
hdrs = ["src/string/stpncpy.h"],
5403+
deps = [
5404+
":__support_common",
5405+
":__support_macros_null_check",
5406+
":string_memory_utils",
5407+
":string_utils",
5408+
],
5409+
)
5410+
53345411
libc_function(
53355412
name = "strlen",
53365413
srcs = ["src/string/strlen.cpp"],
@@ -5354,6 +5431,17 @@ libc_function(
53545431
],
53555432
)
53565433

5434+
libc_function(
5435+
name = "strlcpy",
5436+
srcs = ["src/string/strlcpy.cpp"],
5437+
hdrs = ["src/string/strlcpy.h"],
5438+
deps = [
5439+
":__support_common",
5440+
":llvm_libc_types_size_t",
5441+
":string_utils",
5442+
],
5443+
)
5444+
53575445
libc_function(
53585446
name = "strncpy",
53595447
srcs = ["src/string/strncpy.cpp"],
@@ -5375,6 +5463,40 @@ libc_function(
53755463
],
53765464
)
53775465

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

5520+
libc_function(
5521+
name = "strchrnul",
5522+
srcs = ["src/string/strchrnul.cpp"],
5523+
hdrs = ["src/string/strchrnul.h"],
5524+
deps = [
5525+
":__support_common",
5526+
":string_utils",
5527+
],
5528+
)
5529+
53985530
libc_function(
53995531
name = "strsep",
54005532
srcs = ["src/string/strsep.cpp"],
@@ -5420,6 +5552,51 @@ libc_function(
54205552
],
54215553
)
54225554

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