1#
2# Copyright 2017 The Abseil Authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      https://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
17load(
18    "//absl:copts/configure_copts.bzl",
19    "ABSL_DEFAULT_COPTS",
20    "ABSL_TEST_COPTS",
21)
22
23package(
24    default_visibility = ["//visibility:public"],
25    features = ["parse_headers"],
26)
27
28licenses(["notice"])
29
30cc_library(
31    name = "strings",
32    srcs = [
33        "ascii.cc",
34        "charconv.cc",
35        "escaping.cc",
36        "internal/charconv_bigint.cc",
37        "internal/charconv_bigint.h",
38        "internal/charconv_parse.cc",
39        "internal/charconv_parse.h",
40        "internal/memutil.cc",
41        "internal/memutil.h",
42        "internal/stl_type_traits.h",
43        "internal/str_join_internal.h",
44        "internal/str_split_internal.h",
45        "match.cc",
46        "numbers.cc",
47        "str_cat.cc",
48        "str_replace.cc",
49        "str_split.cc",
50        "string_view.cc",
51        "substitute.cc",
52    ],
53    hdrs = [
54        "ascii.h",
55        "charconv.h",
56        "escaping.h",
57        "match.h",
58        "numbers.h",
59        "str_cat.h",
60        "str_join.h",
61        "str_replace.h",
62        "str_split.h",
63        "string_view.h",
64        "strip.h",
65        "substitute.h",
66    ],
67    copts = ABSL_DEFAULT_COPTS,
68    deps = [
69        ":internal",
70        "//absl/base",
71        "//absl/base:bits",
72        "//absl/base:config",
73        "//absl/base:core_headers",
74        "//absl/base:endian",
75        "//absl/base:raw_logging_internal",
76        "//absl/base:throw_delegate",
77        "//absl/memory",
78        "//absl/meta:type_traits",
79        "//absl/numeric:int128",
80    ],
81)
82
83cc_library(
84    name = "internal",
85    srcs = [
86        "internal/escaping.cc",
87        "internal/ostringstream.cc",
88        "internal/utf8.cc",
89    ],
90    hdrs = [
91        "internal/char_map.h",
92        "internal/escaping.h",
93        "internal/ostringstream.h",
94        "internal/resize_uninitialized.h",
95        "internal/utf8.h",
96    ],
97    copts = ABSL_DEFAULT_COPTS,
98    deps = [
99        "//absl/base:config",
100        "//absl/base:core_headers",
101        "//absl/base:endian",
102        "//absl/base:raw_logging_internal",
103        "//absl/meta:type_traits",
104    ],
105)
106
107cc_test(
108    name = "match_test",
109    size = "small",
110    srcs = ["match_test.cc"],
111    copts = ABSL_TEST_COPTS,
112    visibility = ["//visibility:private"],
113    deps = [
114        ":strings",
115        "@com_google_googletest//:gtest_main",
116    ],
117)
118
119cc_test(
120    name = "escaping_test",
121    size = "small",
122    srcs = [
123        "escaping_test.cc",
124        "internal/escaping_test_common.h",
125    ],
126    copts = ABSL_TEST_COPTS,
127    visibility = ["//visibility:private"],
128    deps = [
129        ":cord",
130        ":strings",
131        "//absl/base:core_headers",
132        "//absl/container:fixed_array",
133        "@com_google_googletest//:gtest_main",
134    ],
135)
136
137cc_test(
138    name = "escaping_benchmark",
139    srcs = [
140        "escaping_benchmark.cc",
141        "internal/escaping_test_common.h",
142    ],
143    copts = ABSL_TEST_COPTS,
144    tags = ["benchmark"],
145    visibility = ["//visibility:private"],
146    deps = [
147        ":strings",
148        "//absl/base:raw_logging_internal",
149        "@com_github_google_benchmark//:benchmark_main",
150    ],
151)
152
153cc_test(
154    name = "ascii_test",
155    size = "small",
156    srcs = ["ascii_test.cc"],
157    copts = ABSL_TEST_COPTS,
158    visibility = ["//visibility:private"],
159    deps = [
160        ":strings",
161        "//absl/base:core_headers",
162        "@com_google_googletest//:gtest_main",
163    ],
164)
165
166cc_test(
167    name = "ascii_benchmark",
168    srcs = ["ascii_benchmark.cc"],
169    copts = ABSL_TEST_COPTS,
170    tags = ["benchmark"],
171    visibility = ["//visibility:private"],
172    deps = [
173        ":strings",
174        "@com_github_google_benchmark//:benchmark_main",
175    ],
176)
177
178cc_test(
179    name = "memutil_benchmark",
180    srcs = [
181        "internal/memutil.h",
182        "internal/memutil_benchmark.cc",
183    ],
184    copts = ABSL_TEST_COPTS,
185    tags = ["benchmark"],
186    visibility = ["//visibility:private"],
187    deps = [
188        ":strings",
189        "//absl/base:core_headers",
190        "@com_github_google_benchmark//:benchmark_main",
191    ],
192)
193
194cc_test(
195    name = "memutil_test",
196    size = "small",
197    srcs = [
198        "internal/memutil.h",
199        "internal/memutil_test.cc",
200    ],
201    copts = ABSL_TEST_COPTS,
202    visibility = ["//visibility:private"],
203    deps = [
204        ":strings",
205        "//absl/base:core_headers",
206        "@com_google_googletest//:gtest_main",
207    ],
208)
209
210cc_test(
211    name = "utf8_test",
212    size = "small",
213    srcs = [
214        "internal/utf8_test.cc",
215    ],
216    copts = ABSL_TEST_COPTS,
217    visibility = ["//visibility:private"],
218    deps = [
219        ":internal",
220        "//absl/base:core_headers",
221        "@com_google_googletest//:gtest_main",
222    ],
223)
224
225cc_test(
226    name = "string_view_benchmark",
227    srcs = ["string_view_benchmark.cc"],
228    copts = ABSL_TEST_COPTS,
229    tags = ["benchmark"],
230    visibility = ["//visibility:private"],
231    deps = [
232        ":strings",
233        "//absl/base:core_headers",
234        "//absl/base:raw_logging_internal",
235        "@com_github_google_benchmark//:benchmark_main",
236    ],
237)
238
239cc_test(
240    name = "string_view_test",
241    size = "small",
242    srcs = ["string_view_test.cc"],
243    copts = ABSL_TEST_COPTS,
244    visibility = ["//visibility:private"],
245    deps = [
246        ":strings",
247        "//absl/base:config",
248        "//absl/base:core_headers",
249        "//absl/base:dynamic_annotations",
250        "@com_google_googletest//:gtest_main",
251    ],
252)
253
254cc_library(
255    name = "cord_internal",
256    hdrs = ["internal/cord_internal.h"],
257    copts = ABSL_DEFAULT_COPTS,
258    visibility = ["//visibility:private"],
259    deps = [
260        ":strings",
261        "//absl/base:base_internal",
262        "//absl/container:compressed_tuple",
263        "//absl/meta:type_traits",
264    ],
265)
266
267cc_library(
268    name = "cord",
269    srcs = [
270        "cord.cc",
271    ],
272    hdrs = [
273        "cord.h",
274    ],
275    copts = ABSL_DEFAULT_COPTS,
276    deps = [
277        ":cord_internal",
278        ":internal",
279        ":str_format",
280        ":strings",
281        "//absl/base",
282        "//absl/base:core_headers",
283        "//absl/base:endian",
284        "//absl/base:raw_logging_internal",
285        "//absl/container:fixed_array",
286        "//absl/container:inlined_vector",
287        "//absl/functional:function_ref",
288        "//absl/meta:type_traits",
289        "//absl/types:optional",
290    ],
291)
292
293cc_library(
294    name = "cord_test_helpers",
295    testonly = 1,
296    hdrs = [
297        "cord_test_helpers.h",
298    ],
299    copts = ABSL_DEFAULT_COPTS,
300    deps = [
301        ":cord",
302    ],
303)
304
305cc_test(
306    name = "cord_test",
307    size = "medium",
308    srcs = ["cord_test.cc"],
309    copts = ABSL_TEST_COPTS,
310    visibility = ["//visibility:private"],
311    deps = [
312        ":cord",
313        ":cord_test_helpers",
314        ":str_format",
315        ":strings",
316        "//absl/base",
317        "//absl/base:config",
318        "//absl/base:core_headers",
319        "//absl/base:endian",
320        "//absl/base:raw_logging_internal",
321        "//absl/container:fixed_array",
322        "@com_google_googletest//:gtest_main",
323    ],
324)
325
326cc_test(
327    name = "substitute_test",
328    size = "small",
329    srcs = ["substitute_test.cc"],
330    copts = ABSL_TEST_COPTS,
331    visibility = ["//visibility:private"],
332    deps = [
333        ":strings",
334        "//absl/base:core_headers",
335        "@com_google_googletest//:gtest_main",
336    ],
337)
338
339cc_test(
340    name = "str_replace_benchmark",
341    srcs = ["str_replace_benchmark.cc"],
342    copts = ABSL_TEST_COPTS,
343    tags = ["benchmark"],
344    visibility = ["//visibility:private"],
345    deps = [
346        ":strings",
347        "//absl/base:raw_logging_internal",
348        "@com_github_google_benchmark//:benchmark_main",
349    ],
350)
351
352cc_test(
353    name = "str_replace_test",
354    size = "small",
355    srcs = ["str_replace_test.cc"],
356    copts = ABSL_TEST_COPTS,
357    visibility = ["//visibility:private"],
358    deps = [
359        ":strings",
360        "@com_google_googletest//:gtest_main",
361    ],
362)
363
364cc_test(
365    name = "str_split_test",
366    srcs = ["str_split_test.cc"],
367    copts = ABSL_TEST_COPTS,
368    visibility = ["//visibility:private"],
369    deps = [
370        ":strings",
371        "//absl/base:core_headers",
372        "//absl/base:dynamic_annotations",
373        "//absl/container:flat_hash_map",
374        "//absl/container:node_hash_map",
375        "@com_google_googletest//:gtest_main",
376    ],
377)
378
379cc_test(
380    name = "str_split_benchmark",
381    srcs = ["str_split_benchmark.cc"],
382    copts = ABSL_TEST_COPTS,
383    tags = ["benchmark"],
384    visibility = ["//visibility:private"],
385    deps = [
386        ":strings",
387        "//absl/base:raw_logging_internal",
388        "@com_github_google_benchmark//:benchmark_main",
389    ],
390)
391
392cc_test(
393    name = "ostringstream_test",
394    size = "small",
395    srcs = ["internal/ostringstream_test.cc"],
396    copts = ABSL_TEST_COPTS,
397    visibility = ["//visibility:private"],
398    deps = [
399        ":internal",
400        "@com_google_googletest//:gtest_main",
401    ],
402)
403
404cc_test(
405    name = "ostringstream_benchmark",
406    srcs = ["internal/ostringstream_benchmark.cc"],
407    copts = ABSL_TEST_COPTS,
408    tags = ["benchmark"],
409    visibility = ["//visibility:private"],
410    deps = [
411        ":internal",
412        "@com_github_google_benchmark//:benchmark_main",
413    ],
414)
415
416cc_test(
417    name = "resize_uninitialized_test",
418    size = "small",
419    srcs = [
420        "internal/resize_uninitialized.h",
421        "internal/resize_uninitialized_test.cc",
422    ],
423    copts = ABSL_TEST_COPTS,
424    visibility = ["//visibility:private"],
425    deps = [
426        "//absl/base:core_headers",
427        "//absl/meta:type_traits",
428        "@com_google_googletest//:gtest_main",
429    ],
430)
431
432cc_test(
433    name = "str_join_test",
434    size = "small",
435    srcs = ["str_join_test.cc"],
436    copts = ABSL_TEST_COPTS,
437    visibility = ["//visibility:private"],
438    deps = [
439        ":strings",
440        "//absl/base:core_headers",
441        "//absl/memory",
442        "@com_google_googletest//:gtest_main",
443    ],
444)
445
446cc_test(
447    name = "str_join_benchmark",
448    srcs = ["str_join_benchmark.cc"],
449    copts = ABSL_TEST_COPTS,
450    tags = ["benchmark"],
451    visibility = ["//visibility:private"],
452    deps = [
453        ":strings",
454        "@com_github_google_benchmark//:benchmark_main",
455    ],
456)
457
458cc_test(
459    name = "str_cat_test",
460    size = "small",
461    srcs = ["str_cat_test.cc"],
462    copts = ABSL_TEST_COPTS,
463    visibility = ["//visibility:private"],
464    deps = [
465        ":strings",
466        "//absl/base:core_headers",
467        "@com_google_googletest//:gtest_main",
468    ],
469)
470
471cc_test(
472    name = "str_cat_benchmark",
473    srcs = ["str_cat_benchmark.cc"],
474    copts = ABSL_TEST_COPTS,
475    tags = ["benchmark"],
476    visibility = ["//visibility:private"],
477    deps = [
478        ":strings",
479        "@com_github_google_benchmark//:benchmark_main",
480    ],
481)
482
483cc_test(
484    name = "numbers_test",
485    size = "medium",
486    srcs = [
487        "internal/numbers_test_common.h",
488        "numbers_test.cc",
489    ],
490    copts = ABSL_TEST_COPTS,
491    visibility = ["//visibility:private"],
492    deps = [
493        ":internal",
494        ":pow10_helper",
495        ":strings",
496        "//absl/base:config",
497        "//absl/base:raw_logging_internal",
498        "//absl/random",
499        "//absl/random:distributions",
500        "@com_google_googletest//:gtest_main",
501    ],
502)
503
504cc_test(
505    name = "numbers_benchmark",
506    srcs = ["numbers_benchmark.cc"],
507    copts = ABSL_TEST_COPTS,
508    tags = ["benchmark"],
509    visibility = ["//visibility:private"],
510    deps = [
511        ":strings",
512        "//absl/base:raw_logging_internal",
513        "//absl/random",
514        "//absl/random:distributions",
515        "@com_github_google_benchmark//:benchmark_main",
516    ],
517)
518
519cc_test(
520    name = "strip_test",
521    size = "small",
522    srcs = ["strip_test.cc"],
523    copts = ABSL_TEST_COPTS,
524    visibility = ["//visibility:private"],
525    deps = [
526        ":strings",
527        "@com_google_googletest//:gtest_main",
528    ],
529)
530
531cc_test(
532    name = "char_map_test",
533    srcs = ["internal/char_map_test.cc"],
534    copts = ABSL_TEST_COPTS,
535    deps = [
536        ":internal",
537        "@com_google_googletest//:gtest_main",
538    ],
539)
540
541cc_test(
542    name = "char_map_benchmark",
543    srcs = ["internal/char_map_benchmark.cc"],
544    copts = ABSL_TEST_COPTS,
545    tags = ["benchmark"],
546    deps = [
547        ":internal",
548        "@com_github_google_benchmark//:benchmark_main",
549    ],
550)
551
552cc_test(
553    name = "charconv_test",
554    srcs = ["charconv_test.cc"],
555    copts = ABSL_TEST_COPTS,
556    deps = [
557        ":pow10_helper",
558        ":str_format",
559        ":strings",
560        "@com_google_googletest//:gtest_main",
561    ],
562)
563
564cc_test(
565    name = "charconv_parse_test",
566    srcs = [
567        "internal/charconv_parse.h",
568        "internal/charconv_parse_test.cc",
569    ],
570    copts = ABSL_TEST_COPTS,
571    deps = [
572        ":strings",
573        "//absl/base:config",
574        "//absl/base:raw_logging_internal",
575        "@com_google_googletest//:gtest_main",
576    ],
577)
578
579cc_test(
580    name = "charconv_bigint_test",
581    srcs = [
582        "internal/charconv_bigint.h",
583        "internal/charconv_bigint_test.cc",
584        "internal/charconv_parse.h",
585    ],
586    copts = ABSL_TEST_COPTS,
587    deps = [
588        ":strings",
589        "//absl/base:config",
590        "@com_google_googletest//:gtest_main",
591    ],
592)
593
594cc_test(
595    name = "charconv_benchmark",
596    srcs = [
597        "charconv_benchmark.cc",
598    ],
599    tags = [
600        "benchmark",
601    ],
602    deps = [
603        ":strings",
604        "@com_github_google_benchmark//:benchmark_main",
605    ],
606)
607
608cc_library(
609    name = "str_format",
610    hdrs = [
611        "str_format.h",
612    ],
613    copts = ABSL_DEFAULT_COPTS,
614    deps = [
615        ":str_format_internal",
616    ],
617)
618
619cc_library(
620    name = "str_format_internal",
621    srcs = [
622        "internal/str_format/arg.cc",
623        "internal/str_format/bind.cc",
624        "internal/str_format/extension.cc",
625        "internal/str_format/float_conversion.cc",
626        "internal/str_format/output.cc",
627        "internal/str_format/parser.cc",
628    ],
629    hdrs = [
630        "internal/str_format/arg.h",
631        "internal/str_format/bind.h",
632        "internal/str_format/checker.h",
633        "internal/str_format/extension.h",
634        "internal/str_format/float_conversion.h",
635        "internal/str_format/output.h",
636        "internal/str_format/parser.h",
637    ],
638    copts = ABSL_DEFAULT_COPTS,
639    visibility = ["//visibility:private"],
640    deps = [
641        ":strings",
642        "//absl/base:bits",
643        "//absl/base:config",
644        "//absl/base:core_headers",
645        "//absl/functional:function_ref",
646        "//absl/meta:type_traits",
647        "//absl/numeric:int128",
648        "//absl/types:optional",
649        "//absl/types:span",
650    ],
651)
652
653cc_test(
654    name = "str_format_test",
655    srcs = ["str_format_test.cc"],
656    copts = ABSL_TEST_COPTS,
657    visibility = ["//visibility:private"],
658    deps = [
659        ":cord",
660        ":str_format",
661        ":strings",
662        "//absl/base:core_headers",
663        "@com_google_googletest//:gtest_main",
664    ],
665)
666
667cc_test(
668    name = "str_format_extension_test",
669    srcs = [
670        "internal/str_format/extension_test.cc",
671    ],
672    copts = ABSL_TEST_COPTS,
673    visibility = ["//visibility:private"],
674    deps = [
675        ":str_format",
676        ":str_format_internal",
677        ":strings",
678        "@com_google_googletest//:gtest_main",
679    ],
680)
681
682cc_test(
683    name = "str_format_arg_test",
684    srcs = ["internal/str_format/arg_test.cc"],
685    copts = ABSL_TEST_COPTS,
686    visibility = ["//visibility:private"],
687    deps = [
688        ":str_format",
689        ":str_format_internal",
690        "@com_google_googletest//:gtest_main",
691    ],
692)
693
694cc_test(
695    name = "str_format_bind_test",
696    srcs = ["internal/str_format/bind_test.cc"],
697    copts = ABSL_TEST_COPTS,
698    visibility = ["//visibility:private"],
699    deps = [
700        ":str_format_internal",
701        "@com_google_googletest//:gtest_main",
702    ],
703)
704
705cc_test(
706    name = "str_format_checker_test",
707    srcs = ["internal/str_format/checker_test.cc"],
708    copts = ABSL_TEST_COPTS,
709    visibility = ["//visibility:private"],
710    deps = [
711        ":str_format",
712        "@com_google_googletest//:gtest_main",
713    ],
714)
715
716cc_test(
717    name = "str_format_convert_test",
718    size = "medium",
719    srcs = ["internal/str_format/convert_test.cc"],
720    copts = ABSL_TEST_COPTS,
721    visibility = ["//visibility:private"],
722    deps = [
723        ":str_format_internal",
724        ":strings",
725        "//absl/base:raw_logging_internal",
726        "//absl/types:optional",
727        "@com_google_googletest//:gtest_main",
728    ],
729)
730
731cc_test(
732    name = "str_format_output_test",
733    srcs = ["internal/str_format/output_test.cc"],
734    copts = ABSL_TEST_COPTS,
735    visibility = ["//visibility:private"],
736    deps = [
737        ":cord",
738        ":str_format_internal",
739        "@com_google_googletest//:gtest_main",
740    ],
741)
742
743cc_test(
744    name = "str_format_parser_test",
745    srcs = ["internal/str_format/parser_test.cc"],
746    copts = ABSL_TEST_COPTS,
747    visibility = ["//visibility:private"],
748    deps = [
749        ":str_format_internal",
750        "//absl/base:core_headers",
751        "@com_google_googletest//:gtest_main",
752    ],
753)
754
755cc_library(
756    name = "pow10_helper",
757    testonly = True,
758    srcs = ["internal/pow10_helper.cc"],
759    hdrs = ["internal/pow10_helper.h"],
760    visibility = ["//visibility:private"],
761    deps = ["//absl/base:config"],
762)
763
764cc_test(
765    name = "pow10_helper_test",
766    srcs = ["internal/pow10_helper_test.cc"],
767    copts = ABSL_TEST_COPTS,
768    visibility = ["//visibility:private"],
769    deps = [
770        ":pow10_helper",
771        ":str_format",
772        "@com_google_googletest//:gtest_main",
773    ],
774)
775