1 # Implement a macro glog_library() that the BUILD file can load.
2 # By default, glog is built with gflags support. You can change this behavior by using
3 # glog_library(with_gflags=0)
5 # This file is inspired by the following sample BUILD files:
6 # https://github.com/google/glog/issues/61
7 # https://github.com/google/glog/files/393474/BUILD.txt
9 def glog_library(with_gflags=1):
12 visibility = [ '//visibility:public' ],
14 'src/base/commandlineflags.h',
15 'src/base/googleinit.h',
19 'src/signalhandler.cc',
30 'src/glog/log_severity.h',
36 # Disable warnings that exists in glog
38 '-Wno-unused-local-typedefs',
39 ## Inject google namespace as 'google'
40 "-D_START_GOOGLE_NAMESPACE_='namespace google {'",
41 "-D_END_GOOGLE_NAMESPACE_='}'",
42 "-DGOOGLE_NAMESPACE='google'",
43 # Allows src/base/mutex.h to include pthread.h.
45 # Allows src/logging.cc to determine the host name.
46 '-DHAVE_SYS_UTSNAME_H',
47 # System header files enabler for src/utilities.cc
48 # Enable system calls from syscall.h
49 '-DHAVE_SYS_SYSCALL_H',
50 # Enable system calls from sys/time.h
58 ] if with_gflags else [],
59 deps = [ ':internal_headers' ] + \
60 [ '//external:gflags' ] if with_gflags else [],
73 name = 'internal_headers',
74 hdrs = internal_headers,
81 name = 'internal_headers',
82 hdrs = internal_headers,
93 sed -e 's/@ac_cv_have_unistd_h@/1/g' \
94 -e 's/@ac_cv_have_stdint_h@/1/g' \
95 -e 's/@ac_cv_have_systypes_h@/1/g' \
96 -e 's/@ac_cv_have_libgflags_h@/1/g' \
97 -e 's/@ac_cv_have_uint16_t@/1/g' \
98 -e 's/@ac_cv_have___builtin_expect@/1/g' \
99 -e 's/@ac_cv_have_.*@/0/g' \
100 -e 's/@ac_google_start_namespace@/namespace google {/g' \
101 -e 's/@ac_google_end_namespace@/}/g' \
102 -e 's/@ac_google_namespace@/google/g' \
103 -e 's/@ac_cv___attribute___noinline@/__attribute__((noinline))/g' \
104 -e 's/@ac_cv___attribute___noreturn@/__attribute__((noreturn))/g' \
105 -e 's/@ac_cv___attribute___printf_4_5@/__attribute__((__format__ (__printf__, 4, 5)))/g'
111 'src/config.h.cmake.in',
114 '/'.join([PACKAGE_NAME, 'config.h']) if PACKAGE_NAME else 'config.h',
116 cmd = "awk '{ gsub(/^#cmakedefine/, \"//cmakedefine\"); print; }' $(<) > $(@)",
122 'src/glog/logging.h.in',
125 '/'.join([PACKAGE_NAME, 'glog/logging.h']) if PACKAGE_NAME else 'glog/logging.h',
127 cmd = '$(location :gen_sh) < $(<) > $(@)',
132 name = 'raw_logging_h',
134 'src/glog/raw_logging.h.in',
137 '/'.join([PACKAGE_NAME, 'glog/raw_logging.h']) if PACKAGE_NAME else 'glog/raw_logging.h',
139 cmd = '$(location :gen_sh) < $(<) > $(@)',
144 name = 'stl_logging_h',
146 'src/glog/stl_logging.h.in',
149 '/'.join([PACKAGE_NAME, 'glog/stl_logging.h']) if PACKAGE_NAME else 'glog/stl_logging.h',
151 cmd = '$(location :gen_sh) < $(<) > $(@)',
156 name = 'vlog_is_on_h',
158 'src/glog/vlog_is_on.h.in',
161 '/'.join([PACKAGE_NAME, 'glog/vlog_is_on.h']) if PACKAGE_NAME else 'glog/vlog_is_on.h',
163 cmd = '$(location :gen_sh) < $(<) > $(@)',