From 2e8b4f603a7e4eb2b81bb2e4f3b74445f468630b Mon Sep 17 00:00:00 2001 From: John Millikin Date: Thu, 9 Nov 2017 10:25:13 -0800 Subject: [PATCH] Add a Bazel build file for opentracing-cpp. This lets projects that use the Bazel build system (http://bazel.build) more easily depend on OpenTracing. To generate `version.h`, the config shells out to `cmake` instead of duplicating the existing version definitions from `CMakeLists.txt`. --- BUILD.bazel | 30 ++++++++++++++++++++++++++++++ WORKSPACE | 1 + test/BUILD | 12 ++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 BUILD.bazel create mode 100644 WORKSPACE create mode 100644 test/BUILD diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 0000000..2420f7b --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,30 @@ +cc_library( + name = "opentracing", + srcs = glob(["src/*.cpp"]), + hdrs = glob(["include/opentracing/*.h"]) + [ + ":include/opentracing/version.h", + ], + strip_include_prefix = "include", + visibility = ["//visibility:public"], + deps = [":3rd_party_lib"], +) + +genrule( + name = "generate_version_h", + srcs = glob([ + "*", + "cmake/*", + "src/*", + ]), + outs = ["include/opentracing/version.h"], + cmd = """ + cmake -DBUILD_TESTING=OFF -L $$(dirname $(location :CMakeLists.txt)) + mv include/opentracing/version.h $@ + """, +) + +cc_library( + name = "3rd_party_lib", + hdrs = glob(["3rd_party/include/**/*.hpp"]), + strip_include_prefix = "3rd_party/include", +) diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 0000000..1b5eaf8 --- /dev/null +++ b/WORKSPACE @@ -0,0 +1 @@ +workspace(name = "io_opentracing_cpp") diff --git a/test/BUILD b/test/BUILD new file mode 100644 index 0000000..27927b4 --- /dev/null +++ b/test/BUILD @@ -0,0 +1,12 @@ +TEST_NAMES = [ + "string_view_test", + "tracer_test", + "util_test", + "value_test", +] + +[cc_test( + name = test_name, + srcs = [test_name + ".cpp"], + deps = ["//:opentracing"], +) for test_name in TEST_NAMES]