Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
ce04d18a
Commit
ce04d18a
authored
Dec 28, 2017
by
donghuixu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bazel build support glog
parent
76982189
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
188 additions
and
6 deletions
+188
-6
BUILD
BUILD
+15
-6
workspace.bzl
bazel/workspace.bzl
+16
-0
glog.BUILD
glog.BUILD
+156
-0
logging.h
src/butil/logging.h
+1
-0
No files found.
BUILD
View file @
ce04d18a
...
...
@@ -4,6 +4,10 @@ exports_files(["LICENSE"])
load(":bazel/brpc.bzl", "brpc_proto_library")
config_setting(
name = "glog_mode",
define_values = {"with_glog": "1"}
)
COPTS = [
"-DBTHREAD_USE_FAST_PTHREAD_MUTEX",
...
...
@@ -14,9 +18,11 @@ COPTS = [
"-D__STDC_FORMAT_MACROS",
"-D__STDC_LIMIT_MACROS",
"-D__STDC_CONSTANT_MACROS",
"-DBRPC_WITH_GLOG=0",
"-DGFLAGS_NS=google",
]
] + select({
":glog_mode": ["-DBRPC_WITH_GLOG=1"],
"//conditions:default": ["-DBRPC_WITH_GLOG=0"],
})
LINKOPTS = [
"-lpthread",
...
...
@@ -32,7 +38,7 @@ genrule(
outs = [
"src/butil/config.h",
],
cmd = """cat << EOF >$@
cmd = """cat << EOF >$@
""" + """
// This file is auto-generated.
#ifndef BUTIL_CONFIG_H
#define BUTIL_CONFIG_H
...
...
@@ -40,14 +46,16 @@ genrule(
#ifdef BRPC_WITH_GLOG
#undef BRPC_WITH_GLOG
#endif
#define BRPC_WITH_GLOG 0
#define BRPC_WITH_GLOG """ + select({
":glog_mode": "1",
"//conditions:default": "0",
}) +
"""
#endif // BUTIL_CONFIG_H
EOF
"""
)
BUTIL_SRCS = [
"src/butil/third_party/dmg_fp/g_fmt.cc",
"src/butil/third_party/dmg_fp/dtoa_wrapper.cc",
...
...
@@ -183,6 +191,7 @@ cc_library(
deps = [
"@com_google_protobuf//:protobuf",
"@com_github_gflags_gflags//:gflags",
"@com_github_google_glog//:glog",
],
includes = [
"src/",
...
...
bazel/workspace.bzl
View file @
ce04d18a
...
...
@@ -14,6 +14,10 @@ def brpc_workspace():
url = "https://github.com/gflags/gflags/archive/46f73f88b18aee341538c0dfc22b1710a6abedef.tar.gz",
)
native.bind(
name = "gflags",
actual = "@com_github_gflags_gflags//:gflags",
)
native.new_http_archive(
name = "com_github_google_leveldb",
...
...
@@ -22,3 +26,15 @@ def brpc_workspace():
url = "https://github.com/google/leveldb/archive/a53934a3ae1244679f812d998a4f16f2c7f309a6.tar.gz"
)
native.new_http_archive(
name = "com_github_google_glog",
build_file = str(Label("//:glog.BUILD")),
strip_prefix = "glog-a6a166db069520dbbd653c97c2e5b12e08a8bb26",
url = "https://github.com/google/glog/archive/a6a166db069520dbbd653c97c2e5b12e08a8bb26.tar.gz"
)
native.http_archive(
name = "com_google_googletest",
strip_prefix = "googletest-0fe96607d85cf3a25ac40da369db62bbee2939a5",
url = "https://github.com/google/googletest/archive/0fe96607d85cf3a25ac40da369db62bbee2939a5.tar.gz",
)
glog.BUILD
0 → 100644
View file @
ce04d18a
licenses(["notice"])
cc_library(
name = "glog",
srcs = [
"src/base/commandlineflags.h",
"src/base/googleinit.h",
"src/demangle.cc",
"src/logging.cc",
"src/raw_logging.cc",
"src/symbolize.cc",
"src/utilities.cc",
"src/vlog_is_on.cc",
],
hdrs = [
"raw_logging_h",
"src/base/mutex.h",
"src/demangle.h",
"src/symbolize.h",
"src/utilities.h",
"src/glog/log_severity.h",
":config_h",
":logging_h",
":stl_logging_h",
":vlog_is_on_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",
"-DHAVE_FCNTL",
"-DHAVE_SYS_TYPES_H",
# Allows syslog support
"-DHAVE_SYSLOG_H",
# GFlags
"-isystem $(GENDIR)/external/com_github_gflags_gflags/",
"-DHAVE_LIB_GFLAGS",
# Necessary for creating soft links of log files
"-DHAVE_UNISTD_H",
],
includes = [
".",
"src",
],
visibility = ["//visibility:public"],
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"],
)
src/butil/logging.h
View file @
ce04d18a
...
...
@@ -22,6 +22,7 @@
#include <butil/config.h> // BRPC_WITH_GLOG
#include <inttypes.h>
#include <string>
#include <cstring>
#include <sstream>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment