-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglog.BUILD
150 lines (143 loc) · 4.01 KB
/
glog.BUILD
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# Derived from https://github.com/google/glog/files/393474/BUILD.txt
#
# Currently gflags is included, since having deps
# of ["//external:gflags"] does not seem to let it find
# "gflags/gflags.h".
#
# Currently we need to do
# expoert GLOG_logtostderr=1
#
# To allow logging to stderr.
cc_library(
visibility = ["//visibility:public"],
name = "glog",
includes = ["src"],
srcs = ["src/base/commandlineflags.h",
"src/base/googleinit.h",
"src/demangle.cc",
"src/logging.cc",
"src/symbolize.cc",
"src/vlog_is_on.cc",
"src/raw_logging.cc",
"src/utilities.cc"],
hdrs = ["src/base/mutex.h",
"src/utilities.h",
"src/demangle.h",
"src/symbolize.h",
"src/glog/log_severity.h",
":stl_logging_h",
":config_h",
":logging_h",
":vlog_is_on_h",
"raw_logging_h"],
copts = [
# Disable warnings that exists in glog
"-Wno-sign-compare",
"-Wno-unused-local-typedefs",
# Inject google namespace as "google"
"-D_START_GOOGLE_NAMESPACE_='namespace google {'",
"-D_END_GOOGLE_NAMESPACE_='}'",
"-DGOOGLE_NAMESPACE='google'",
# Allows src/base/mutex.h to include pthread.h.
"-DHAVE_PTHREAD",
# Allows src/logging.cc to determine the host name.
"-DHAVE_SYS_UTSNAME_H",
# System header files enabler for src/utilities.cc
# Enable system calls from syscall.h
"-DHAVE_SYS_SYSCALL_H",
# Enable system calls from sys/time.h
"-DHAVE_SYS_TIME_H",
"-DHAVE_STDINT_H",
"-DHAVE_STRING_H",
# For logging.cc
"-DHAVE_PREAD",
# Include gflags
"-DHAVE_LIB_GFLAGS",
],
deps = [
"//external:gflags",
],
)
# Below are the generation rules that generates the necessary header
# files for glog. Originally they are generated by CMAKE
# configure_file() command, which replaces certain template
# placeholders in the .in files with provided values.
# gen_sh is a bash script that provides the values for generated
# header files. Under the hood it is just a wrapper over sed.
genrule(
name = "gen_sh",
outs = [
"gen.sh",
],
cmd = """
cat > $@ <<"EOF"
#! /bin/sh
sed -e 's/@ac_cv_have_unistd_h@/1/g' \
-e 's/@ac_cv_have_stdint_h@/1/g' \
-e 's/@ac_cv_have_systypes_h@/1/g' \
-e 's/@ac_cv_have_libgflags_h@/1/g' \
-e 's/@ac_cv_have_uint16_t@/1/g' \
-e 's/@ac_cv_have___builtin_expect@/1/g' \
-e 's/@ac_cv_have_.*@/0/g' \
-e 's/@ac_google_start_namespace@/namespace google {/g' \
-e 's/@ac_google_end_namespace@/}/g' \
-e 's/@ac_google_namespace@/google/g' \
-e 's/@ac_cv___attribute___noinline@/__attribute__((noinline))/g' \
-e 's/@ac_cv___attribute___noreturn@/__attribute__((noreturn))/g' \
-e 's/@ac_cv___attribute___printf_4_5@/__attribute__((__format__ (__printf__, 4, 5)))/g'
EOF"""
)
genrule(
name = "config_h",
srcs = [
"src/config.h.cmake.in",
],
outs = [
"config.h",
],
cmd = "awk '{ gsub(/^#cmakedefine/, \"//cmakedefine\"); print; }' $(<) > $(@)",
)
genrule(
name = "logging_h",
srcs = [
"src/glog/logging.h.in",
],
outs = [
"glog/logging.h",
],
cmd = "$(location :gen_sh) < $(<) > $(@)",
tools = [":gen_sh"],
)
genrule(
name = "raw_logging_h",
srcs = [
"src/glog/raw_logging.h.in",
],
outs = [
"glog/raw_logging.h",
],
cmd = "$(location :gen_sh) < $(<) > $(@)",
tools = [":gen_sh"],
)
genrule(
name = "stl_logging_h",
srcs = [
"src/glog/stl_logging.h.in",
],
outs = [
"glog/stl_logging.h",
],
cmd = "$(location :gen_sh) < $(<) > $(@)",
tools = [":gen_sh"],
)
genrule(
name = "vlog_is_on_h",
srcs = [
"src/glog/vlog_is_on.h.in",
],
outs = [
"glog/vlog_is_on.h",
],
cmd = "$(location :gen_sh) < $(<) > $(@)",
tools = [":gen_sh"],
)