Merge pull request #150 from LuminateWireless/fix-bazel-build
[platform/upstream/gflags.git] / BUILD
1 # Bazel build file for gflags
2 #
3 # See INSTALL.md for instructions for adding gflags to a Bazel workspace.
4
5 licenses(["notice"])
6
7 cc_library(
8     name = "gflags",
9     srcs = [
10         "src/gflags.cc",
11         "src/gflags_completions.cc",
12         "src/gflags_reporting.cc",
13         "src/mutex.h",
14         "src/util.h",
15         ":config_h",
16         ":gflags_completions_h",
17         ":gflags_declare_h",
18         ":gflags_h",
19         ":includes",
20     ],
21     hdrs = ["gflags.h"],
22     copts = [
23         # The config.h gets generated to the package directory of
24         # GENDIR, and we don't want to put it into the includes
25         # otherwise the dependent may pull it in by accident.
26         "-I$(GENDIR)/" + PACKAGE_NAME,
27         "-Wno-sign-compare",
28         "-DHAVE_STDINT_H",
29         "-DHAVE_SYS_TYPES_H",
30         "-DHAVE_INTTYPES_H",
31         "-DHAVE_SYS_STAT_H",
32         "-DHAVE_UNISTD_H",
33         "-DHAVE_FNMATCH_H",
34         "-DHAVE_STRTOLL",
35         "-DHAVE_STRTOQ",
36         "-DHAVE_PTHREAD",
37         "-DHAVE_RWLOCK",
38         "-DGFLAGS_INTTYPES_FORMAT_C99",
39     ],
40     includes = [
41         "include",
42     ],
43     visibility = ["//visibility:public"],
44 )
45
46 genrule(
47     name = "config_h",
48     srcs = [
49         "src/config.h.in",
50     ],
51     outs = [
52         "config.h",
53     ],
54     cmd = "awk '{ gsub(/^#cmakedefine/, \"//cmakedefine\"); print; }' $(<) > $(@)",
55 )
56
57 genrule(
58     name = "gflags_h",
59     srcs = [
60         "src/gflags.h.in",
61     ],
62     outs = [
63         "gflags.h",
64     ],
65     cmd = "awk '{ gsub(/@(GFLAGS_ATTRIBUTE_UNUSED|INCLUDE_GFLAGS_NS_H)@/, \"\"); print; }' $(<) > $(@)",
66 )
67
68 genrule(
69     name = "gflags_completions_h",
70     srcs = [
71         "src/gflags_completions.h.in",
72     ],
73     outs = [
74         "gflags_completions.h",
75     ],
76     cmd = "awk '{ gsub(/@GFLAGS_NAMESPACE@/, \"gflags\"); print; }' $(<) > $(@)",
77 )
78
79 genrule(
80     name = "gflags_declare_h",
81     srcs = [
82         "src/gflags_declare.h.in",
83     ],
84     outs = [
85         "gflags_declare.h",
86     ],
87     cmd = ("awk '{ " +
88            "gsub(/@GFLAGS_NAMESPACE@/, \"gflags\"); " +
89            "gsub(/@(HAVE_STDINT_H|HAVE_SYS_TYPES_H|HAVE_INTTYPES_H|GFLAGS_INTTYPES_FORMAT_C99)@/, \"1\"); " +
90            "gsub(/@([A-Z0-9_]+)@/, \"0\"); " +
91            "print; }' $(<) > $(@)"),
92 )
93
94 genrule(
95     name = "includes",
96     srcs = [
97         ":gflags_h",
98         ":gflags_declare_h",
99     ],
100     outs = [
101         "include/gflags/gflags.h",
102         "include/gflags/gflags_declare.h",
103     ],
104     cmd = "mkdir -p $(@D)/include/gflags && cp $(SRCS) $(@D)/include/gflags",
105 )