Skip to content

Commit

Permalink
Add example of build system.
Browse files Browse the repository at this point in the history
  • Loading branch information
g-easy committed Oct 25, 2019
1 parent 362e095 commit 95bb0dd
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 0 deletions.
23 changes: 23 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2019, OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

workspace(name = "io_opentelemetry_cpp")

# GoogleTest framework.
# Only needed for tests, not to build the OpenTelemetry library.
http_archive(
name = "com_google_googletest",
strip_prefix = "googletest-master",
urls = ["https://github.com/google/googletest/archive/master.zip"],
)
22 changes: 22 additions & 0 deletions api/include/opentelemetry/trace/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2019, OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

package(default_visibility = ["//visibility:private"])

cc_library(
name = "trace",
hdrs = ["span_id.h"],
visibility = ["//visibility:public"],
includes = ["../.."],
)
22 changes: 22 additions & 0 deletions api/src/opentelemetry/trace/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2019, OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

package(default_visibility = ["//visibility:private"])

cc_library(
name = "trace",
srcs = ["span_id.cc"],
visibility = ["//visibility:public"],
deps = ["@io_opentelemetry_cpp//api/include/opentelemetry/trace"],
)
7 changes: 7 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
The examples/ directory is a separate bazel workspace, to show how
to build libraries and binaries that use the OpenTelemetry library.

```
cd examples/
bazel build //helloworld
```
21 changes: 21 additions & 0 deletions examples/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2019, OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

workspace(name = "io_opentelemetry_cpp_examples")

# OpenTelemetry should be imported via http_archive.
local_repository(
name = "io_opentelemetry_cpp",
path = "../",
)
22 changes: 22 additions & 0 deletions examples/helloworld/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2019, OpenTelemetry Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

cc_binary(
name = "helloworld",
srcs = ["helloworld.cc"],
deps = [
"@io_opentelemetry_cpp//api/include/opentelemetry/trace",
"@io_opentelemetry_cpp//api/src/opentelemetry/trace",
],
)
22 changes: 22 additions & 0 deletions examples/helloworld/helloworld.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2019, OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <opentelemetry/trace/span_id.h>

#include <iostream>

int main() {
opentelemetry::trace::SpanId span_id;
std::cout << "Span ID: " << span_id.ToHex() << "\n";
}

0 comments on commit 95bb0dd

Please sign in to comment.