Commit 7f732529 authored by Luc Bertrand's avatar Luc Bertrand Committed by Rodrigo Queiro

apply buildifier on glog.bzl

parent 1863b422
...@@ -7,95 +7,95 @@ ...@@ -7,95 +7,95 @@
# https://github.com/google/glog/issues/61 # https://github.com/google/glog/issues/61
# https://github.com/google/glog/files/393474/BUILD.txt # https://github.com/google/glog/files/393474/BUILD.txt
def glog_library(namespace='google', with_gflags=1, **kwargs): def glog_library(namespace = "google", with_gflags = 1, **kwargs):
if native.repository_name() != '@': if native.repository_name() != "@":
gendir = '$(GENDIR)/external/' + native.repository_name().lstrip('@') gendir = "$(GENDIR)/external/" + native.repository_name().lstrip("@")
else: else:
gendir = '$(GENDIR)' gendir = "$(GENDIR)"
native.cc_library( native.cc_library(
name = 'glog', name = "glog",
visibility = [ '//visibility:public' ], visibility = ["//visibility:public"],
srcs = [ srcs = [
':config_h', ":config_h",
'src/base/commandlineflags.h', "src/base/commandlineflags.h",
'src/base/googleinit.h', "src/base/googleinit.h",
'src/base/mutex.h', "src/base/mutex.h",
'src/demangle.cc', "src/demangle.cc",
'src/demangle.h', "src/demangle.h",
'src/logging.cc', "src/logging.cc",
'src/raw_logging.cc', "src/raw_logging.cc",
'src/signalhandler.cc', "src/signalhandler.cc",
'src/stacktrace.h', "src/stacktrace.h",
'src/stacktrace_generic-inl.h', "src/stacktrace_generic-inl.h",
'src/stacktrace_libunwind-inl.h', "src/stacktrace_libunwind-inl.h",
'src/stacktrace_powerpc-inl.h', "src/stacktrace_powerpc-inl.h",
'src/stacktrace_windows-inl.h', "src/stacktrace_windows-inl.h",
'src/stacktrace_x86-inl.h', "src/stacktrace_x86-inl.h",
'src/stacktrace_x86_64-inl.h', "src/stacktrace_x86_64-inl.h",
'src/symbolize.cc', "src/symbolize.cc",
'src/symbolize.h', "src/symbolize.h",
'src/utilities.cc', "src/utilities.cc",
'src/utilities.h', "src/utilities.h",
'src/vlog_is_on.cc', "src/vlog_is_on.cc",
], ],
hdrs = [ hdrs = [
':logging_h', ":logging_h",
':raw_logging_h', ":raw_logging_h",
':stl_logging_h', ":stl_logging_h",
':vlog_is_on_h', ":vlog_is_on_h",
'src/glog/log_severity.h', "src/glog/log_severity.h",
], ],
strip_include_prefix = 'src', strip_include_prefix = "src",
copts = [ copts = [
# Disable warnings that exists in glog. # Disable warnings that exists in glog.
'-Wno-sign-compare', "-Wno-sign-compare",
'-Wno-unused-function', "-Wno-unused-function",
'-Wno-unused-local-typedefs', "-Wno-unused-local-typedefs",
'-Wno-unused-variable', "-Wno-unused-variable",
"-DGLOG_BAZEL_BUILD", "-DGLOG_BAZEL_BUILD",
# Inject a C++ namespace. # Inject a C++ namespace.
"-DGOOGLE_NAMESPACE='%s'" % namespace, "-DGOOGLE_NAMESPACE='%s'" % namespace,
# Allows src/base/mutex.h to include pthread.h. # Allows src/base/mutex.h to include pthread.h.
'-DHAVE_PTHREAD', "-DHAVE_PTHREAD",
# Allows src/logging.cc to determine the host name. # Allows src/logging.cc to determine the host name.
'-DHAVE_SYS_UTSNAME_H', "-DHAVE_SYS_UTSNAME_H",
# For src/utilities.cc. # For src/utilities.cc.
'-DHAVE_SYS_SYSCALL_H', "-DHAVE_SYS_SYSCALL_H",
'-DHAVE_SYS_TIME_H', "-DHAVE_SYS_TIME_H",
'-DHAVE_STDINT_H', "-DHAVE_STDINT_H",
'-DHAVE_STRING_H', "-DHAVE_STRING_H",
# Enable dumping stacktrace upon sigaction. # Enable dumping stacktrace upon sigaction.
'-DHAVE_SIGACTION', "-DHAVE_SIGACTION",
# For logging.cc. # For logging.cc.
'-DHAVE_PREAD', "-DHAVE_PREAD",
'-DHAVE___ATTRIBUTE__', "-DHAVE___ATTRIBUTE__",
# Include generated header files. # Include generated header files.
'-I%s/glog_internal' % gendir, "-I%s/glog_internal" % gendir,
] + select({ ] + select({
# For stacktrace. # For stacktrace.
'@bazel_tools//src/conditions:darwin': [ "@bazel_tools//src/conditions:darwin": [
'-DHAVE_UNWIND_H', "-DHAVE_UNWIND_H",
'-DHAVE_DLADDR', "-DHAVE_DLADDR",
], ],
'//conditions:default': [ "//conditions:default": [
'-DHAVE_UNWIND_H', "-DHAVE_UNWIND_H",
], ],
}) + ([ }) + ([
# Use gflags to parse CLI arguments. # Use gflags to parse CLI arguments.
'-DHAVE_LIB_GFLAGS', "-DHAVE_LIB_GFLAGS",
] if with_gflags else []), ] if with_gflags else []),
deps = [ deps = [
'@com_github_gflags_gflags//:gflags', "@com_github_gflags_gflags//:gflags",
] if with_gflags else [], ] if with_gflags else [],
**kwargs **kwargs
) )
native.genrule( native.genrule(
name = 'gen_sh', name = "gen_sh",
outs = [ outs = [
'gen.sh', "gen.sh",
], ],
cmd = r'''\ cmd = r'''\
#!/bin/sh #!/bin/sh
...@@ -119,30 +119,32 @@ EOF ...@@ -119,30 +119,32 @@ EOF
) )
native.genrule( native.genrule(
name = 'config_h', name = "config_h",
srcs = [ srcs = [
'src/config.h.cmake.in', "src/config.h.cmake.in",
], ],
outs = [ outs = [
'glog_internal/config.h', "glog_internal/config.h",
], ],
cmd = "awk '{ gsub(/^#cmakedefine/, \"//cmakedefine\"); print; }' $< > $@", cmd = "awk '{ gsub(/^#cmakedefine/, \"//cmakedefine\"); print; }' $< > $@",
) )
[native.genrule( [
name = '%s_h' % f, native.genrule(
srcs = [ name = "%s_h" % f,
'src/glog/%s.h.in' % f, srcs = [
], "src/glog/%s.h.in" % f,
outs = [ ],
'src/glog/%s.h' % f, outs = [
], "src/glog/%s.h" % f,
cmd = '$(location :gen_sh) < $< > $@', ],
tools = [':gen_sh'], cmd = "$(location :gen_sh) < $< > $@",
) for f in [ tools = [":gen_sh"],
'vlog_is_on', )
'stl_logging', for f in [
'raw_logging', "vlog_is_on",
'logging', "stl_logging",
"raw_logging",
"logging",
] ]
] ]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment