Skip to content

Commit

Permalink
Merge pull request #32 from DataDog/cgilmour/bazel
Browse files Browse the repository at this point in the history
Add build files for bazel
  • Loading branch information
cgilmour authored Aug 1, 2018
2 parents bcba717 + a9083f0 commit 6f0713f
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@
*.exe
*.out
*.app

# Bazel
bazel-*
51 changes: 51 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
cc_library(
name = "dd_opentracing_cpp",
srcs = glob(["src/*.cpp", "src/*.h"]) + [
":version_number.h",
],
hdrs = [
"include/datadog/opentracing.h",
],
strip_include_prefix = "include",
visibility = ["//visibility:public"],
deps = [
"//:3rd_party_nlohmann",
"@io_opentracing_cpp//:opentracing",
"@com_github_msgpack_msgpack_c//:msgpack",
],
copts = ["-std=c++14"],
)

genrule(
name = "generate_version_number_h",
srcs = glob([
"CMakeLists.txt",
"src/*",
]),
outs = [
"version_number.h"
],
cmd = """
TEMP_DIR=$$(mktemp -d)
trap -- 'rm -r $$TEMP_DIR' EXIT
VERSION_NUMBER_H_OUT=$${PWD}/$(location :version_number.h)
CMAKE_ROOT=$$(dirname $${PWD}/$(location :CMakeLists.txt))
cd $$TEMP_DIR
cmake -DHEADERS_ONLY=ON -L $$CMAKE_ROOT
mv version_number.h $$VERSION_NUMBER_H_OUT
""",
)

cc_library(
name = "3rd_party_nlohmann",
hdrs = ["3rd_party/include/nlohmann/json.hpp"],
strip_include_prefix = "3rd_party/include",
visibility = ["//visibility:public"],
)

cc_library(
name = "3rd_party_catch2",
hdrs = ["3rd_party/include/catch2/catch.hpp"],
strip_include_prefix = "3rd_party/include",
visibility = ["//visibility:public"],
)
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ option(BUILD_SHARED "Builds shared library" ON)
option(BUILD_STATIC "Builds static library" OFF)
option(BUILD_PLUGIN "Builds plugin (requires gcc and not macos)" OFF)
option(BUILD_TESTING "Builds tests, also enables BUILD_SHARED" OFF)
option(HEADERS_ONLY "Only generate version_number.h" OFF)

if(BUILD_TESTING)
set(BUILD_SHARED ON)
Expand Down Expand Up @@ -37,6 +38,10 @@ configure_file(
"${PROJECT_BINARY_DIR}/version_number.h")
include_directories("${PROJECT_BINARY_DIR}")

if(HEADERS_ONLY)
return()
endif()

# Dependencies
find_path(OPENTRACING_INCLUDE_DIR NAMES opentracing/tracer.h)
find_library(OPENTRACING_LIB opentracing)
Expand Down
17 changes: 17 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
workspace(name = "com_github_datadog_dd_opentracing_cpp")

git_repository(
name = "io_opentracing_cpp",
remote = "https://github.com/opentracing/opentracing-cpp",
commit = "ac50154a7713877f877981c33c3375003b6ebfe1",
)

new_http_archive(
name = "com_github_msgpack_msgpack_c",
sha256 = "9859d44d336f9b023a79a3026bb6a558b2ea346107ab4eadba58236048650690",
strip_prefix = "msgpack-3.0.1",
urls = [
"https://github.com/msgpack/msgpack-c/releases/download/cpp-3.0.1/msgpack-3.0.1.tar.gz",
],
build_file = "bazel/external/msgpack.BUILD"
)
13 changes: 13 additions & 0 deletions bazel/external/msgpack.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cc_library(
name = "msgpack",
srcs = glob([
"src/*.c",
"include/**/*.h",
"include/**/*.hpp",
]),
includes = [
"include",
],
strip_include_prefix = "include",
visibility = ["//visibility:public"],
)

0 comments on commit 6f0713f

Please sign in to comment.