1 # Implement a macro glog_library() that the BUILD file can load.
3 # By default, glog is built with gflags support. You can change this behavior
4 # by using glog_library(with_gflags=0)
6 # This file is inspired by the following sample BUILD files:
7 # https://github.com/google/glog/issues/61
8 # https://github.com/google/glog/files/393474/BUILD.txt
10 def glog_library(namespace='google', with_gflags=1):
11 if native.repository_name() != '@':
12 gendir = '$(GENDIR)/external/' + native.repository_name().lstrip('@')
18 visibility = [ '//visibility:public' ],
21 'src/base/commandlineflags.h',
22 'src/base/googleinit.h',
28 'src/signalhandler.cc',
30 'src/stacktrace_generic-inl.h',
31 'src/stacktrace_libunwind-inl.h',
32 'src/stacktrace_powerpc-inl.h',
33 'src/stacktrace_windows-inl.h',
34 'src/stacktrace_x86-inl.h',
35 'src/stacktrace_x86_64-inl.h',
47 'src/glog/log_severity.h',
51 strip_include_prefix = 'src',
53 # Disable warnings that exists in glog.
55 '-Wno-unused-function',
56 '-Wno-unused-local-typedefs',
57 '-Wno-unused-variable',
58 # Inject a C++ namespace.
59 "-D_START_GOOGLE_NAMESPACE_='namespace %s {'" % namespace,
60 "-D_END_GOOGLE_NAMESPACE_='}'",
61 "-DGOOGLE_NAMESPACE='%s'" % namespace,
62 # Allows src/base/mutex.h to include pthread.h.
64 # Allows src/logging.cc to determine the host name.
65 '-DHAVE_SYS_UTSNAME_H',
66 # For src/utilities.cc.
67 '-DHAVE_SYS_SYSCALL_H',
71 # Enable dumping stacktrace upon sigaction.
76 # Include generated header files.
77 '-I%s/glog_internal' % gendir,
79 # Use gflags to parse CLI arguments.
81 ] if with_gflags else [],
83 '@com_github_gflags_gflags//:gflags',
84 ] if with_gflags else [],
95 sed -e 's/@ac_cv_have_unistd_h@/1/g' \
96 -e 's/@ac_cv_have_stdint_h@/1/g' \
97 -e 's/@ac_cv_have_systypes_h@/1/g' \
98 -e 's/@ac_cv_have_libgflags_h@/1/g' \
99 -e 's/@ac_cv_have_uint16_t@/1/g' \
100 -e 's/@ac_cv_have___builtin_expect@/1/g' \
101 -e 's/@ac_cv_have_.*@/0/g' \
102 -e 's/@ac_google_start_namespace@/namespace google {/g' \
103 -e 's/@ac_google_end_namespace@/}/g' \
104 -e 's/@ac_google_namespace@/google/g' \
105 -e 's/@ac_cv___attribute___noinline@/__attribute__((noinline))/g' \
106 -e 's/@ac_cv___attribute___noreturn@/__attribute__((noreturn))/g' \
107 -e 's/@ac_cv___attribute___printf_4_5@/__attribute__((__format__ (__printf__, 4, 5)))/g'
115 'src/config.h.cmake.in',
118 'glog_internal/src/config.h',
120 cmd = "awk '{ gsub(/^#cmakedefine/, \"//cmakedefine\"); print; }' $< > $@",
126 'src/glog/%s.h.in' % f,
131 cmd = '$(location :gen_sh) < $< > $@',