Skip to content

Commit

Permalink
Update Install doc for bazel build (#1046)
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb authored Nov 2, 2021
1 parent bf176f3 commit 52f6198
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 4 deletions.
53 changes: 50 additions & 3 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ build systems for opentelemetry-cpp.
exporter need nlohmann-json to build. This is covered in the build
instructions for each of these components.

### Building as Standalone CMake Project
### Building as standalone CMake Project

1. Getting the opentelementry-cpp source:

Expand Down Expand Up @@ -115,7 +115,7 @@ build systems for opentelemetry-cpp.
$
```

### Incorporating Into An Existing CMake Project
### Incorporating into an existing CMake Project

To use the library from a CMake project, you can locate it directly with
`find_package` and use the imported targets from generated package
Expand Down Expand Up @@ -151,7 +151,7 @@ SDK with their unittests. We use 3.7.2 in our build system.

To install Bazel, consult the [Installing Bazel](https://docs.bazel.build/versions/3.7.0/install.html) guide.

### Building as Standalone Bazel Project
### Building as standalone Bazel Project

1. Getting the opentelementry-cpp source:

Expand Down Expand Up @@ -189,3 +189,50 @@ To install Bazel, consult the [Installing Bazel](https://docs.bazel.build/versio
```

4. The build artifacts will be located under `bazel-bin`

### Incorporating into an existing Bazel Project

- WORKSPACE file:

```console
http_archive(
name = "io_opentelemetry_cpp",
sha256 = "<sha256>",
strip_prefix = "opentelemetry-cpp-1.0.1",
urls = [
"https://github.com/open-telemetry/opentelemetry-cpp/archive/refs/tags/v1.0.1.tar.gz"
],
)

# Load OpenTelemetry dependencies after load.
load("@io_opentelemetry_cpp//bazel:repository.bzl", "opentelemetry_cpp_deps")

opentelemetry_cpp_deps()

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

grpc_deps()

# Load extra gRPC dependencies due to https://github.com/grpc/grpc/issues/20511
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")

grpc_extra_deps()

```

- Component level BUILD file:

```console
cc_library(
name = "<name>"
...
deps = [
"@io_opentelemetry_cpp//api",
"@io_opentelemetry_cpp//exporters/otlp:otlp_exporter",
"@io_opentelemetry_cpp//sdk/src/trace",
...
],
...
)
```
2 changes: 1 addition & 1 deletion bazel/repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def opentelemetry_cpp_deps():
maybe(
http_archive,
name = "curl",
build_file = "@//bazel:curl.BUILD",
build_file = "@io_opentelemetry_cpp//bazel:curl.BUILD",
sha256 = "ba98332752257b47b9dea6d8c0ad25ec1745c20424f1dd3ff2c99ab59e97cf91",
strip_prefix = "curl-7.73.0",
urls = ["https://curl.haxx.se/download/curl-7.73.0.tar.gz"],
Expand Down

0 comments on commit 52f6198

Please sign in to comment.