summaryrefslogtreecommitdiff
path: root/BUILD
blob: cf85354619c09f8d06af840ceab7ebe03dbb39ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Bazel build file for gflags
#
# See INSTALL.md for instructions for adding gflags to a Bazel workspace.

licenses(["notice"])

cc_library(
    name = "gflags",
    srcs = [
        "src/gflags.cc",
        "src/gflags_completions.cc",
        "src/gflags_reporting.cc",
        "src/mutex.h",
        "src/util.h",
        ":config_h",
        ":gflags_completions_h",
        ":gflags_declare_h",
        ":gflags_h",
        ":includes",
    ],
    hdrs = ["gflags.h"],
    copts = [
        # The config.h gets generated to the package directory of
        # GENDIR, and we don't want to put it into the includes
        # otherwise the dependent may pull it in by accident.
        "-I$(GENDIR)/" + PACKAGE_NAME,
        "-Wno-sign-compare",
        "-DHAVE_STDINT_H",
        "-DHAVE_SYS_TYPES_H",
        "-DHAVE_INTTYPES_H",
        "-DHAVE_SYS_STAT_H",
        "-DHAVE_UNISTD_H",
        "-DHAVE_FNMATCH_H",
        "-DHAVE_STRTOLL",
        "-DHAVE_STRTOQ",
        "-DHAVE_PTHREAD",
        "-DHAVE_RWLOCK",
        "-DGFLAGS_INTTYPES_FORMAT_C99",
    ],
    includes = [
        "include",
    ],
    linkopts = ["-lpthread"],
    visibility = ["//visibility:public"],
)

genrule(
    name = "config_h",
    srcs = [
        "src/config.h.in",
    ],
    outs = [
        "config.h",
    ],
    cmd = "awk '{ gsub(/^#cmakedefine/, \"//cmakedefine\"); print; }' $(<) > $(@)",
)

genrule(
    name = "gflags_h",
    srcs = [
        "src/gflags.h.in",
    ],
    outs = [
        "gflags.h",
    ],
    cmd = "awk '{ gsub(/@(GFLAGS_ATTRIBUTE_UNUSED|INCLUDE_GFLAGS_NS_H)@/, \"\"); print; }' $(<) > $(@)",
)

genrule(
    name = "gflags_completions_h",
    srcs = [
        "src/gflags_completions.h.in",
    ],
    outs = [
        "gflags_completions.h",
    ],
    cmd = "awk '{ gsub(/@GFLAGS_NAMESPACE@/, \"gflags\"); print; }' $(<) > $(@)",
)

genrule(
    name = "gflags_declare_h",
    srcs = [
        "src/gflags_declare.h.in",
    ],
    outs = [
        "gflags_declare.h",
    ],
    cmd = ("awk '{ " +
           "gsub(/@GFLAGS_NAMESPACE@/, \"gflags\"); " +
           "gsub(/@(HAVE_STDINT_H|HAVE_SYS_TYPES_H|HAVE_INTTYPES_H|GFLAGS_INTTYPES_FORMAT_C99)@/, \"1\"); " +
           "gsub(/@([A-Z0-9_]+)@/, \"0\"); " +
           "print; }' $(<) > $(@)"),
)

genrule(
    name = "includes",
    srcs = [
        ":gflags_h",
        ":gflags_declare_h",
    ],
    outs = [
        "include/gflags/gflags.h",
        "include/gflags/gflags_declare.h",
    ],
    cmd = "mkdir -p $(@D)/include/gflags && cp $(SRCS) $(@D)/include/gflags",
)