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