From 6a9891703c76328eb33e5754d98a1bcafc80f39d Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Tue, 13 Dec 2016 15:01:42 -0800 Subject: [PATCH] Fix all building errors --- WORKSPACE | 29 ++++++++++++++--------------- third_party/gflags.BUILD | 12 ++++++++++++ third_party/glog.BUILD | 13 ------------- third_party/glog_test/BUILD | 11 +++++++++++ third_party/glog_test/glog_test.cc | 9 +++++++++ third_party/protobuf_test/BUILD | 8 ++++---- 6 files changed, 50 insertions(+), 32 deletions(-) create mode 100644 third_party/gflags.BUILD create mode 100644 third_party/glog_test/BUILD create mode 100644 third_party/glog_test/glog_test.cc diff --git a/WORKSPACE b/WORKSPACE index f4358f0195a..4581b89aaf0 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -8,26 +8,25 @@ http_archive( # External dependency to gtest 1.7.0. This method comes from # https://www.bazel.io/versions/master/docs/tutorial/cpp.html. new_http_archive( - name = "gtest", - url = "https://github.com/google/googletest/archive/release-1.7.0.zip", - sha256 = "b58cb7547a28b2c718d1e38aee18a3659c9e3ff52440297e965f5edffe34b6d0", - build_file = "third_party/gtest.BUILD", - strip_prefix = "googletest-release-1.7.0", -) + name="gtest", + url="https://github.com/google/googletest/archive/release-1.7.0.zip", + sha256="b58cb7547a28b2c718d1e38aee18a3659c9e3ff52440297e965f5edffe34b6d0", + build_file="third_party/gtest.BUILD", + strip_prefix="googletest-release-1.7.0", ) # External dependency to gflags. This method comes from # https://github.com/gflags/example/blob/master/WORKSPACE. -git_repository( - name = "gflags", - tag = "v2.2.0", - remote = "https://github.com/gflags/gflags.git" +new_git_repository( + name="gflags", + tag="v2.2.0", + remote="https://github.com/gflags/gflags.git", + build_file="third_party/gflags.BUILD", ) # External dependency to glog. This method comes from # https://github.com/reyoung/bazel_playground/blob/master/WORKSPACE new_git_repository( - name = "glog", - remote = "https://github.com/google/glog.git", - commit = "b6a5e0524c28178985f0d228e9eaa43808dbec3c", - build_file = "third_party/glog.BUILD" -) + name="glog", + remote="https://github.com/google/glog.git", + commit="b6a5e0524c28178985f0d228e9eaa43808dbec3c", + build_file="third_party/glog.BUILD") diff --git a/third_party/gflags.BUILD b/third_party/gflags.BUILD new file mode 100644 index 00000000000..85e8bd0bd74 --- /dev/null +++ b/third_party/gflags.BUILD @@ -0,0 +1,12 @@ +# Bazel (http://bazel.io/) BUILD file for gflags. +# +# See INSTALL.md for instructions for adding gflags to a Bazel workspace. + +licenses(["notice"]) + +exports_files(["src/gflags_complections.sh", "COPYING.txt"]) + +load(":bazel/gflags.bzl", "gflags_sources", "gflags_library") +(hdrs, srcs) = gflags_sources(namespace=["google", "gflags"]) +gflags_library(hdrs=hdrs, srcs=srcs, threads=0) +gflags_library(hdrs=hdrs, srcs=srcs, threads=1) diff --git a/third_party/glog.BUILD b/third_party/glog.BUILD index 560c82d8d30..52fe12a716c 100644 --- a/third_party/glog.BUILD +++ b/third_party/glog.BUILD @@ -3,10 +3,6 @@ licenses(["notice"]) cc_library( visibility = ["//visibility:public"], name = "glog", - deps = [ - #"//third_party/libunwind:libunwind-k8", - "@gflags//:gflags", - ], includes = [ ".", "src", @@ -24,9 +20,6 @@ cc_library( "-DHAVE_INTTYPES_H", "-DHAVE_LIBPTHREAD", "-DHAVE_SYS_SYSCALL_H", - #"-DHAVE_LIBUNWIND_H", - "-DHAVE_LIB_GFLAGS", - #"-DHAVE_LIB_UNWIND", "-DHAVE_MEMORY_H", "-DHAVE_NAMESPACES", "-DHAVE_PREAD", @@ -51,7 +44,6 @@ cc_library( #"-fno-sanitize=thread", #"-fno-sanitize=address", "-Iexternal/glog/src", - #"-I/usr/local/include", # XXX import libunwind ], srcs = [ "src/demangle.cc", @@ -71,7 +63,6 @@ cc_library( "src/demangle.h", "src/mock-log.h", "src/stacktrace.h", - #"src/stacktrace_libunwind-inl.h", "src/symbolize.h", "src/utilities.h", "src/base/commandlineflags.h", @@ -79,10 +70,6 @@ cc_library( "src/base/mutex.h", "src/glog/log_severity.h", ], - linkopts = [ - #"-pthread", - #"-L/usr/local/lib -lunwind", - ], ) genrule( diff --git a/third_party/glog_test/BUILD b/third_party/glog_test/BUILD new file mode 100644 index 00000000000..b0d790f6ae8 --- /dev/null +++ b/third_party/glog_test/BUILD @@ -0,0 +1,11 @@ +licenses(["notice"]) # Apache 2.0 + +cc_test( + name = "glog_test", + srcs = ["glog_test.cc"], + copts = ["-Iexternal/gtest/include"], + deps =[ + "@gtest//:gtest", + "@glog//:glog", + ], +) diff --git a/third_party/glog_test/glog_test.cc b/third_party/glog_test/glog_test.cc new file mode 100644 index 00000000000..a1e3fd71e4b --- /dev/null +++ b/third_party/glog_test/glog_test.cc @@ -0,0 +1,9 @@ +#include +#include + +#include "glog/logging.h" +#include "gtest/gtest.h" + +TEST(GlogTest, Logging) { + LOG(INFO) << "Hello world"; +} diff --git a/third_party/protobuf_test/BUILD b/third_party/protobuf_test/BUILD index e972ca8b3aa..67d4293c70e 100644 --- a/third_party/protobuf_test/BUILD +++ b/third_party/protobuf_test/BUILD @@ -15,10 +15,10 @@ cc_library( deps=[":example_proto"], ) cc_test( - name = "example_lib_test", - srcs = ["example_lib_test.cc"], - copts = ["-Iexternal/gtest/include"], - deps =[ + name="example_lib_test", + srcs=["example_lib_test.cc"], + copts=["-Iexternal/gtest/include"], + deps=[ "@gtest//:gtest", ":example_lib", ], ) -- GitLab