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