• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright 2019 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#
16
17load(
18    "//absl:copts/configure_copts.bzl",
19    "ABSL_DEFAULT_COPTS",
20    "ABSL_DEFAULT_LINKOPTS",
21    "ABSL_TEST_COPTS",
22)
23
24package(
25    default_visibility = ["//visibility:public"],
26    features = [
27        "header_modules",
28        "layering_check",
29        "parse_headers",
30    ],
31)
32
33licenses(["notice"])
34
35cc_library(
36    name = "path_util",
37    hdrs = [
38        "internal/path_util.h",
39    ],
40    copts = ABSL_DEFAULT_COPTS,
41    linkopts = ABSL_DEFAULT_LINKOPTS,
42    visibility = [
43        "//absl/flags:__pkg__",
44    ],
45    deps = [
46        "//absl/base:config",
47        "//absl/strings",
48    ],
49)
50
51cc_library(
52    name = "program_name",
53    srcs = [
54        "internal/program_name.cc",
55    ],
56    hdrs = [
57        "internal/program_name.h",
58    ],
59    copts = ABSL_DEFAULT_COPTS,
60    linkopts = ABSL_DEFAULT_LINKOPTS,
61    visibility = [
62        "//absl/flags:__pkg__",
63        "//absl/log:__pkg__",
64    ],
65    deps = [
66        ":path_util",
67        "//absl/base:config",
68        "//absl/base:core_headers",
69        "//absl/strings",
70        "//absl/synchronization",
71    ],
72)
73
74cc_library(
75    name = "config",
76    srcs = [
77        "usage_config.cc",
78    ],
79    hdrs = [
80        "config.h",
81        "usage_config.h",
82    ],
83    copts = ABSL_DEFAULT_COPTS,
84    linkopts = ABSL_DEFAULT_LINKOPTS,
85    deps = [
86        ":path_util",
87        ":program_name",
88        "//absl/base:config",
89        "//absl/base:core_headers",
90        "//absl/strings",
91        "//absl/synchronization",
92    ],
93)
94
95cc_library(
96    name = "marshalling",
97    srcs = [
98        "marshalling.cc",
99    ],
100    hdrs = [
101        "marshalling.h",
102    ],
103    copts = ABSL_DEFAULT_COPTS,
104    linkopts = ABSL_DEFAULT_LINKOPTS,
105    deps = [
106        "//absl/base:config",
107        "//absl/base:core_headers",
108        "//absl/base:log_severity",
109        "//absl/numeric:int128",
110        "//absl/strings",
111        "//absl/strings:str_format",
112        "//absl/types:optional",
113    ],
114)
115
116cc_library(
117    name = "commandlineflag_internal",
118    srcs = [
119        "internal/commandlineflag.cc",
120    ],
121    hdrs = [
122        "internal/commandlineflag.h",
123    ],
124    copts = ABSL_DEFAULT_COPTS,
125    linkopts = ABSL_DEFAULT_LINKOPTS,
126    visibility = [
127        "//visibility:private",
128    ],
129    deps = [
130        "//absl/base:config",
131        "//absl/base:fast_type_id",
132    ],
133)
134
135cc_library(
136    name = "commandlineflag",
137    srcs = [
138        "commandlineflag.cc",
139    ],
140    hdrs = [
141        "commandlineflag.h",
142    ],
143    copts = ABSL_DEFAULT_COPTS,
144    linkopts = ABSL_DEFAULT_LINKOPTS,
145    deps = [
146        ":commandlineflag_internal",
147        "//absl/base:config",
148        "//absl/base:fast_type_id",
149        "//absl/strings",
150        "//absl/types:optional",
151    ],
152)
153
154cc_library(
155    name = "private_handle_accessor",
156    srcs = [
157        "internal/private_handle_accessor.cc",
158    ],
159    hdrs = [
160        "internal/private_handle_accessor.h",
161    ],
162    copts = ABSL_DEFAULT_COPTS,
163    linkopts = ABSL_DEFAULT_LINKOPTS,
164    visibility = [
165        "//absl/flags:__pkg__",
166    ],
167    deps = [
168        ":commandlineflag",
169        ":commandlineflag_internal",
170        "//absl/base:config",
171        "//absl/strings",
172    ],
173)
174
175cc_library(
176    name = "reflection",
177    srcs = [
178        "reflection.cc",
179    ],
180    hdrs = [
181        "internal/registry.h",
182        "reflection.h",
183    ],
184    copts = ABSL_DEFAULT_COPTS,
185    linkopts = ABSL_DEFAULT_LINKOPTS,
186    deps = [
187        ":commandlineflag",
188        ":commandlineflag_internal",
189        ":config",
190        ":private_handle_accessor",
191        "//absl/base:config",
192        "//absl/base:core_headers",
193        "//absl/base:no_destructor",
194        "//absl/container:flat_hash_map",
195        "//absl/strings",
196        "//absl/synchronization",
197    ],
198)
199
200cc_library(
201    name = "flag_internal",
202    srcs = [
203        "internal/flag.cc",
204    ],
205    hdrs = [
206        "internal/flag.h",
207        "internal/sequence_lock.h",
208    ],
209    copts = ABSL_DEFAULT_COPTS,
210    linkopts = ABSL_DEFAULT_LINKOPTS,
211    visibility = ["//absl/base:__subpackages__"],
212    deps = [
213        ":commandlineflag",
214        ":commandlineflag_internal",
215        ":config",
216        ":marshalling",
217        ":reflection",
218        "//absl/base",
219        "//absl/base:config",
220        "//absl/base:core_headers",
221        "//absl/base:dynamic_annotations",
222        "//absl/memory",
223        "//absl/meta:type_traits",
224        "//absl/strings",
225        "//absl/synchronization",
226        "//absl/utility",
227    ],
228)
229
230cc_library(
231    name = "flag",
232    hdrs = [
233        "declare.h",
234        "flag.h",
235    ],
236    copts = ABSL_DEFAULT_COPTS,
237    linkopts = ABSL_DEFAULT_LINKOPTS,
238    deps = [
239        ":config",
240        ":flag_internal",
241        ":reflection",
242        "//absl/base",
243        "//absl/base:config",
244        "//absl/base:core_headers",
245        "//absl/strings",
246    ],
247)
248
249cc_library(
250    name = "usage_internal",
251    srcs = [
252        "internal/usage.cc",
253    ],
254    hdrs = [
255        "internal/usage.h",
256    ],
257    copts = ABSL_DEFAULT_COPTS,
258    linkopts = ABSL_DEFAULT_LINKOPTS,
259    visibility = [
260        "//absl/flags:__pkg__",
261    ],
262    deps = [
263        ":commandlineflag",
264        ":config",
265        ":flag",
266        ":flag_internal",
267        ":path_util",
268        ":private_handle_accessor",
269        ":program_name",
270        ":reflection",
271        "//absl/base:config",
272        "//absl/base:core_headers",
273        "//absl/strings",
274        "//absl/synchronization",
275    ],
276)
277
278cc_library(
279    name = "usage",
280    srcs = [
281        "usage.cc",
282    ],
283    hdrs = [
284        "usage.h",
285    ],
286    copts = ABSL_DEFAULT_COPTS,
287    linkopts = ABSL_DEFAULT_LINKOPTS,
288    deps = [
289        ":usage_internal",
290        "//absl/base:config",
291        "//absl/base:core_headers",
292        "//absl/base:raw_logging_internal",
293        "//absl/strings",
294        "//absl/synchronization",
295    ],
296)
297
298cc_library(
299    name = "parse",
300    srcs = ["parse.cc"],
301    hdrs = [
302        "internal/parse.h",
303        "parse.h",
304    ],
305    copts = ABSL_DEFAULT_COPTS,
306    linkopts = ABSL_DEFAULT_LINKOPTS,
307    deps = [
308        ":commandlineflag",
309        ":commandlineflag_internal",
310        ":config",
311        ":flag",
312        ":flag_internal",
313        ":private_handle_accessor",
314        ":program_name",
315        ":reflection",
316        ":usage",
317        ":usage_internal",
318        "//absl/algorithm:container",
319        "//absl/base:config",
320        "//absl/base:core_headers",
321        "//absl/strings",
322        "//absl/synchronization",
323    ],
324)
325
326############################################################################
327# Unit tests in alphabetical order.
328
329cc_test(
330    name = "commandlineflag_test",
331    size = "small",
332    srcs = [
333        "commandlineflag_test.cc",
334    ],
335    copts = ABSL_TEST_COPTS,
336    linkopts = ABSL_DEFAULT_LINKOPTS,
337    tags = [
338        "no_test:os:android",
339        "no_test:os:ios",
340        "no_test_android",
341        "no_test_ios",
342        "no_test_wasm",
343    ],
344    deps = [
345        ":commandlineflag",
346        ":commandlineflag_internal",
347        ":config",
348        ":flag",
349        ":private_handle_accessor",
350        ":reflection",
351        "//absl/memory",
352        "//absl/strings",
353        "@com_google_googletest//:gtest",
354        "@com_google_googletest//:gtest_main",
355    ],
356)
357
358cc_test(
359    name = "config_test",
360    size = "small",
361    srcs = [
362        "config_test.cc",
363    ],
364    copts = ABSL_TEST_COPTS,
365    linkopts = ABSL_DEFAULT_LINKOPTS,
366    deps = [
367        ":config",
368        "@com_google_googletest//:gtest",
369        "@com_google_googletest//:gtest_main",
370    ],
371)
372
373cc_test(
374    name = "flag_test",
375    size = "small",
376    srcs = [
377        "flag_test.cc",
378        "flag_test_defs.cc",
379    ],
380    copts = ABSL_TEST_COPTS,
381    linkopts = ABSL_DEFAULT_LINKOPTS,
382    tags = [
383        "no_test:os:android",
384        "no_test:os:ios",
385        "no_test_android",
386        "no_test_ios",
387        "no_test_wasm",
388    ],
389    deps = [
390        ":config",
391        ":flag",
392        ":flag_internal",
393        ":marshalling",
394        ":reflection",
395        "//absl/base:core_headers",
396        "//absl/base:malloc_internal",
397        "//absl/numeric:int128",
398        "//absl/strings",
399        "//absl/time",
400        "@com_google_googletest//:gtest",
401        "@com_google_googletest//:gtest_main",
402    ],
403)
404
405cc_binary(
406    name = "flag_benchmark",
407    testonly = 1,
408    srcs = [
409        "flag_benchmark.cc",
410    ],
411    copts = ABSL_TEST_COPTS,
412    linkopts = select({
413        "//conditions:default": [],
414    }) + ABSL_DEFAULT_LINKOPTS,
415    tags = ["benchmark"],
416    visibility = ["//visibility:private"],
417    deps = [
418        "flag_benchmark.lds",
419        ":flag",
420        ":marshalling",
421        ":parse",
422        ":reflection",
423        "//absl/strings",
424        "//absl/time",
425        "//absl/types:optional",
426        "@com_github_google_benchmark//:benchmark_main",
427    ],
428)
429
430cc_test(
431    name = "marshalling_test",
432    size = "small",
433    srcs = [
434        "marshalling_test.cc",
435    ],
436    copts = ABSL_TEST_COPTS,
437    linkopts = ABSL_DEFAULT_LINKOPTS,
438    deps = [
439        ":marshalling",
440        "@com_google_googletest//:gtest",
441        "@com_google_googletest//:gtest_main",
442    ],
443)
444
445cc_test(
446    name = "parse_test",
447    size = "small",
448    timeout = "moderate",
449    srcs = [
450        "parse_test.cc",
451    ],
452    copts = ABSL_TEST_COPTS,
453    linkopts = ABSL_DEFAULT_LINKOPTS,
454    tags = [
455        "no_test:os:android",
456        "no_test:os:ios",
457        "no_test_android",
458        "no_test_ios",
459        "no_test_wasm",
460    ],
461    deps = [
462        ":flag",
463        ":parse",
464        ":reflection",
465        ":usage_internal",
466        "//absl/base:scoped_set_env",
467        "//absl/log",
468        "//absl/strings",
469        "//absl/types:span",
470        "@com_google_googletest//:gtest",
471        "@com_google_googletest//:gtest_main",
472    ],
473)
474
475cc_test(
476    name = "path_util_test",
477    size = "small",
478    srcs = [
479        "internal/path_util_test.cc",
480    ],
481    copts = ABSL_TEST_COPTS,
482    linkopts = ABSL_DEFAULT_LINKOPTS,
483    deps = [
484        ":path_util",
485        "@com_google_googletest//:gtest",
486        "@com_google_googletest//:gtest_main",
487    ],
488)
489
490cc_test(
491    name = "program_name_test",
492    size = "small",
493    srcs = [
494        "internal/program_name_test.cc",
495    ],
496    copts = ABSL_TEST_COPTS,
497    linkopts = ABSL_DEFAULT_LINKOPTS,
498    tags = ["no_test_wasm"],
499    deps = [
500        ":program_name",
501        "//absl/strings",
502        "@com_google_googletest//:gtest",
503        "@com_google_googletest//:gtest_main",
504    ],
505)
506
507cc_test(
508    name = "reflection_test",
509    size = "small",
510    srcs = [
511        "reflection_test.cc",
512    ],
513    copts = ABSL_TEST_COPTS,
514    linkopts = ABSL_DEFAULT_LINKOPTS,
515    tags = [
516        "no_test:os:android",
517        "no_test:os:ios",
518        "no_test_android",
519        "no_test_ios",
520        "no_test_wasm",
521    ],
522    deps = [
523        ":commandlineflag_internal",
524        ":flag",
525        ":marshalling",
526        ":reflection",
527        ":usage_internal",
528        "//absl/memory",
529        "//absl/strings",
530        "@com_google_googletest//:gtest",
531        "@com_google_googletest//:gtest_main",
532    ],
533)
534
535cc_test(
536    name = "sequence_lock_test",
537    size = "small",
538    timeout = "moderate",
539    srcs = [
540        "internal/sequence_lock_test.cc",
541    ],
542    copts = ABSL_TEST_COPTS,
543    linkopts = ABSL_DEFAULT_LINKOPTS,
544    shard_count = 31,
545    tags = ["no_test_wasm"],
546    deps = [
547        ":flag_internal",
548        "//absl/base",
549        "//absl/container:fixed_array",
550        "//absl/time",
551        "@com_google_googletest//:gtest",
552        "@com_google_googletest//:gtest_main",
553    ],
554)
555
556cc_test(
557    name = "usage_config_test",
558    size = "small",
559    srcs = [
560        "usage_config_test.cc",
561    ],
562    copts = ABSL_TEST_COPTS,
563    linkopts = ABSL_DEFAULT_LINKOPTS,
564    deps = [
565        ":config",
566        ":path_util",
567        ":program_name",
568        "//absl/strings",
569        "@com_google_googletest//:gtest",
570        "@com_google_googletest//:gtest_main",
571    ],
572)
573
574cc_test(
575    name = "usage_test",
576    size = "small",
577    srcs = [
578        "internal/usage_test.cc",
579    ],
580    copts = ABSL_TEST_COPTS,
581    linkopts = ABSL_DEFAULT_LINKOPTS,
582    tags = [
583        "no_test:os:android",
584        "no_test:os:ios",
585        "no_test_android",
586        "no_test_ios",
587        "no_test_wasm",
588    ],
589    deps = [
590        ":config",
591        ":flag",
592        ":parse",
593        ":path_util",
594        ":program_name",
595        ":reflection",
596        ":usage",
597        ":usage_internal",
598        "//absl/strings",
599        "@com_google_googletest//:gtest",
600    ],
601)
602