Skip to content

Commit

Permalink
Bazel Build alterations (open-telemetry#416)
Browse files Browse the repository at this point in the history
Bazel Build alterations
  • Loading branch information
jsuereth authored Dec 7, 2020
1 parent 11cc6cd commit a4a88dd
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 73 deletions.
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ Add your fork as a remote:
git remote add fork https://github.com/YOUR_GITHUB_USERNAME/opentelemetry-cpp.git
```

If you haven't, make sure you are loading the submodules required to build OpenTelemetry

```sh
git submodule init
git submodule update
```

Check out a new branch, make modifications and push the branch to your fork:

```sh
Expand Down
79 changes: 6 additions & 73 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,12 @@

workspace(name = "io_opentelemetry_cpp")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("//bazel:repository.bzl", "opentelemetry_cpp_deps")

# Load gRPC dependency
# Note that this dependency needs to be loaded first due to
# https://github.com/bazelbuild/bazel/issues/6664
http_archive(
name = "com_github_grpc_grpc",
sha256 = "d6277f77e0bb922d3f6f56c0f93292bb4cfabfc3c92b31ee5ccea0e100303612",
strip_prefix = "grpc-1.28.0",
urls = [
"https://github.com/grpc/grpc/archive/v1.28.0.tar.gz",
],
)
# Load our direct dependencies.
opentelemetry_cpp_deps()

# Load gRPC dependencies after load.
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")

grpc_deps()
Expand All @@ -41,73 +33,14 @@ load("@upb//bazel:repository_defs.bzl", "bazel_version_repository")

bazel_version_repository(name = "upb_bazel_version")

# Uses older protobuf version because of
# https://github.com/protocolbuffers/protobuf/issues/7179
http_archive(
name = "com_google_protobuf",
sha256 = "b679cef31102ed8beddc39ecfd6368ee311cbee6f50742f13f21be7278781821",
strip_prefix = "protobuf-3.11.2",
urls = [
"https://github.com/protocolbuffers/protobuf/releases/download/v3.11.2/protobuf-all-3.11.2.tar.gz",
],
)
# Load protobuf deps

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

new_local_repository(
name = "com_github_opentelemetry_proto",
build_file = "//bazel:opentelemetry_proto.BUILD",
path = "third_party/opentelemetry-proto",
)

# GoogleTest framework.
# Only needed for tests, not to build the OpenTelemetry library.
http_archive(
name = "com_google_googletest",
sha256 = "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb",
strip_prefix = "googletest-release-1.10.0",
urls = ["https://github.com/google/googletest/archive/release-1.10.0.tar.gz"],
)

# Google Benchmark library.
# Only needed for benchmarks, not to build the OpenTelemetry library.
http_archive(
name = "com_github_google_benchmark",
sha256 = "3c6a165b6ecc948967a1ead710d4a181d7b0fbcaa183ef7ea84604994966221a",
strip_prefix = "benchmark-1.5.0",
urls = ["https://github.com/google/benchmark/archive/v1.5.0.tar.gz"],
)

http_archive(
name = "github_nlohmann_json",
build_file = "//bazel:nlohmann_json.BUILD",
sha256 = "69cc88207ce91347ea530b227ff0776db82dcb8de6704e1a3d74f4841bc651cf",
urls = [
"https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip",
],
)

# C++ Prometheus Client library.
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")

http_archive(
name = "com_github_jupp0r_prometheus_cpp",
sha256 = "85ad6fea0f0dcb413104366b7d6109acdb015aff8767945511c5cad8202a28a6",
strip_prefix = "prometheus-cpp-0.9.0",
urls = ["https://github.com/jupp0r/prometheus-cpp/archive/v0.9.0.tar.gz"],
)
# Load prometheus C++ dependencies.

load("@com_github_jupp0r_prometheus_cpp//bazel:repositories.bzl", "prometheus_cpp_repositories")

prometheus_cpp_repositories()

# libcurl - An optional dependency we pull in for tests.
http_archive(
name = "curl",
build_file = "@//bazel:curl.BUILD",
sha256 = "ba98332752257b47b9dea6d8c0ad25ec1745c20424f1dd3ff2c99ab59e97cf91",
strip_prefix = "curl-7.73.0",
urls = ["https://curl.haxx.se/download/curl-7.73.0.tar.gz"],
)
80 changes: 80 additions & 0 deletions bazel/repository.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

def opentelemetry_cpp_deps():
"""Loads dependencies need to compile the opentelemetry-cpp library."""

# Google Benchmark library.
# Only needed for benchmarks, not to build the OpenTelemetry library.
maybe(
native.local_repository,
name = "com_github_google_benchmark",
path = "third_party/benchmark",
)

# GoogleTest framework.
# Only needed for tests, not to build the OpenTelemetry library.
maybe(
native.local_repository,
name = "com_google_googletest",
path = "third_party/googletest",
)

# Load gRPC dependency
maybe(
http_archive,
name = "com_github_grpc_grpc",
sha256 = "d6277f77e0bb922d3f6f56c0f93292bb4cfabfc3c92b31ee5ccea0e100303612",
strip_prefix = "grpc-1.28.0",
urls = [
"https://github.com/grpc/grpc/archive/v1.28.0.tar.gz",
],
)

# Uses older protobuf version because of
# https://github.com/protocolbuffers/protobuf/issues/7179
maybe(
http_archive,
name = "com_google_protobuf",
sha256 = "b679cef31102ed8beddc39ecfd6368ee311cbee6f50742f13f21be7278781821",
strip_prefix = "protobuf-3.11.2",
urls = [
"https://github.com/protocolbuffers/protobuf/releases/download/v3.11.2/protobuf-all-3.11.2.tar.gz",
],
)

# OTLP Protocol definition
maybe(
native.new_local_repository,
name = "com_github_opentelemetry_proto",
build_file = "//bazel:opentelemetry_proto.BUILD",
path = "third_party/opentelemetry-proto",
)

# JSON library
maybe(
http_archive,
name = "github_nlohmann_json",
build_file = "//bazel:nlohmann_json.BUILD",
sha256 = "69cc88207ce91347ea530b227ff0776db82dcb8de6704e1a3d74f4841bc651cf",
urls = [
"https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip",
],
)

# C++ Prometheus Client library.
maybe(
native.local_repository,
name = "com_github_jupp0r_prometheus_cpp",
path = "third_party/prometheus-cpp",
)

# libcurl (optional)
maybe(
http_archive,
name = "curl",
build_file = "@//bazel:curl.BUILD",
sha256 = "ba98332752257b47b9dea6d8c0ad25ec1745c20424f1dd3ff2c99ab59e97cf91",
strip_prefix = "curl-7.73.0",
urls = ["https://curl.haxx.se/download/curl-7.73.0.tar.gz"],
)

0 comments on commit a4a88dd

Please sign in to comment.