Skip to content

Commit 39fed2d

Browse files
authored
Merge branch 'master' into reyang/maintainer
2 parents f15f880 + 2a516ad commit 39fed2d

File tree

89 files changed

+1480
-1089
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1480
-1089
lines changed

.bazelignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
third_party
2+
tools
3+
out

.gitattributes

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ LICENSE* text
3737
*.pdf binary
3838
*.rtf binary
3939

40-
## Self-reference =)
41-
.gitignore text
42-
.gitattributes text
40+
## git files
41+
.gitignore text eol=lf
42+
.gitattributes text eol=lf

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v2
15+
with:
16+
submodules: 'recursive'
1517
- name: setup
1618
run: |
1719
sudo ./ci/setup_cmake.sh
@@ -26,6 +28,8 @@ jobs:
2628
runs-on: ubuntu-18.04
2729
steps:
2830
- uses: actions/checkout@v2
31+
with:
32+
submodules: 'recursive'
2933
- name: setup
3034
run: |
3135
sudo ./ci/setup_ci_environment.sh
@@ -44,6 +48,8 @@ jobs:
4448
runs-on: ubuntu-20.04
4549
steps:
4650
- uses: actions/checkout@v2
51+
with:
52+
submodules: 'recursive'
4753
- name: setup
4854
run: |
4955
sudo ./ci/setup_ci_environment.sh
@@ -56,6 +62,8 @@ jobs:
5662
runs-on: ubuntu-latest
5763
steps:
5864
- uses: actions/checkout@v2
65+
with:
66+
submodules: 'recursive'
5967
- name: setup
6068
run: |
6169
sudo ./ci/setup_cmake.sh
@@ -68,6 +76,8 @@ jobs:
6876
runs-on: ubuntu-18.04
6977
steps:
7078
- uses: actions/checkout@v2
79+
with:
80+
submodules: 'recursive'
7181
- name: setup
7282
run: |
7383
sudo ./ci/setup_ci_environment.sh
@@ -83,6 +93,8 @@ jobs:
8393
runs-on: ubuntu-latest
8494
steps:
8595
- uses: actions/checkout@v2
96+
with:
97+
submodules: 'recursive'
8698
- name: setup
8799
run: |
88100
sudo ./ci/setup_cmake.sh
@@ -96,6 +108,8 @@ jobs:
96108
runs-on: ubuntu-latest
97109
steps:
98110
- uses: actions/checkout@v2
111+
with:
112+
submodules: 'recursive'
99113
- name: setup
100114
run: |
101115
sudo ./ci/setup_cmake.sh
@@ -109,6 +123,8 @@ jobs:
109123
runs-on: ubuntu-latest
110124
steps:
111125
- uses: actions/checkout@v2
126+
with:
127+
submodules: 'recursive'
112128
- name: setup
113129
run: |
114130
sudo ./ci/setup_cmake.sh
@@ -122,6 +138,8 @@ jobs:
122138
runs-on: ubuntu-latest
123139
steps:
124140
- uses: actions/checkout@v2
141+
with:
142+
submodules: 'recursive'
125143
- name: setup
126144
run: |
127145
sudo ./ci/setup_cmake.sh
@@ -135,6 +153,8 @@ jobs:
135153
runs-on: ubuntu-latest
136154
steps:
137155
- uses: actions/checkout@v2
156+
with:
157+
submodules: 'recursive'
138158
- name: setup
139159
run: |
140160
sudo ./ci/setup_cmake.sh
@@ -148,6 +168,8 @@ jobs:
148168
runs-on: ubuntu-latest
149169
steps:
150170
- uses: actions/checkout@v2
171+
with:
172+
submodules: 'recursive'
151173
- name: setup
152174
run: |
153175
sudo ./ci/setup_cmake.sh
@@ -178,6 +200,8 @@ jobs:
178200
runs-on: macos-latest
179201
steps:
180202
- uses: actions/checkout@v2
203+
with:
204+
submodules: 'recursive'
181205
- name: run tests
182206
run: ./ci/do_ci.sh bazel.test
183207

@@ -186,6 +210,8 @@ jobs:
186210
runs-on: windows-2019
187211
steps:
188212
- uses: actions/checkout@v2
213+
with:
214+
submodules: 'recursive'
189215
- name: setup
190216
run: |
191217
./ci/setup_windows_cmake.ps1
@@ -201,6 +227,8 @@ jobs:
201227
runs-on: windows-2019
202228
steps:
203229
- uses: actions/checkout@v2
230+
with:
231+
submodules: 'recursive'
204232
- name: setup
205233
run: ./ci/install_windows_bazelisk.ps1
206234
- name: run tests
@@ -211,6 +239,8 @@ jobs:
211239
runs-on: windows-2019
212240
steps:
213241
- uses: actions/checkout@v2
242+
with:
243+
submodules: 'recursive'
214244
- name: setup
215245
run: |
216246
./ci/setup_windows_cmake.ps1
@@ -223,6 +253,8 @@ jobs:
223253
runs-on: ubuntu-latest
224254
steps:
225255
- uses: actions/checkout@v2
256+
with:
257+
submodules: 'recursive'
226258
- name: setup
227259
run: |
228260
sudo ./ci/setup_cmake.sh

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,9 @@
3737

3838
# Mac
3939
.DS_Store
40+
41+
# Output directories
42+
/out
43+
/out.*
44+
# Indicator that the tools were deployed
45+
.buildtools

.gitmodules

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
11
[submodule "third_party/prometheus-cpp"]
22
path = third_party/prometheus-cpp
3-
url = https://github.com/jupp0r/prometheus-cpp.git
3+
url = https://github.com/jupp0r/prometheus-cpp
4+
branch = master
5+
6+
[submodule "tools/vcpkg"]
7+
path = tools/vcpkg
8+
url = https://github.com/Microsoft/vcpkg
9+
branch = master
10+
11+
[submodule "third_party/ms-gsl"]
12+
path = third_party/ms-gsl
13+
url = https://github.com/microsoft/GSL
14+
branch = master
15+
16+
[submodule "third_party/googletest"]
17+
path = third_party/googletest
18+
url = https://github.com/google/googletest
19+
branch = master
20+
21+
[submodule "third_party/benchmark"]
22+
path = third_party/benchmark
23+
url = https://github.com/google/benchmark
24+
branch = master
25+
26+
[submodule "third_party/opentelemetry-proto"]
27+
path = third_party/opentelemetry-proto
28+
url = https://github.com/open-telemetry/opentelemetry-proto
29+
branch = master

CMakeLists.txt

Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,44 +15,91 @@ option(WITH_OTLP "Whether to include the OpenTelemetry Protocol in the SDK" OFF)
1515
option(WITH_PROMETHEUS "Whether to include the Prometheus Client in the SDK"
1616
OFF)
1717

18-
option(WITH_TESTS "Whether to enable tests" ON)
18+
option(BUILD_TESTING "Whether to enable tests" ON)
1919
option(WITH_EXAMPLES "Whether to build examples" ON)
2020

2121
set(WITH_PROTOBUF OFF)
22-
if(WITH_OTLP)
23-
set(WITH_PROTOBUF ON)
24-
endif()
25-
26-
if(WITH_TESTS)
27-
include(CTest)
28-
endif()
2922

3023
find_package(Threads)
3124

25+
function(install_windows_deps)
26+
# Bootstrap vcpkg from CMake and auto-install deps in case if we are missing
27+
# deps on Windows
28+
message("Installing build tools and dependencies...")
29+
execute_process(
30+
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tools/setup-buildtools.cmd)
31+
set(CMAKE_TOOLCHAIN_FILE
32+
${CMAKE_CURRENT_SOURCE_DIR}/tools/vcpkg/scripts/buildsystems/vcpkg.cmake)
33+
endfunction()
34+
3235
if(MSVC)
3336
# Options for Visual C++ compiler: /Zc:__cplusplus - report an updated value
3437
# for recent C++ language standards. Without this option MSVC returns the
3538
# value of __cplusplus="199711L"
3639
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")
3740
endif()
3841

42+
if(WITH_OTLP)
43+
set(WITH_PROTOBUF ON)
44+
endif()
45+
3946
if(WITH_PROTOBUF)
4047
set(protobuf_MODULE_COMPATIBLE ON)
41-
find_package(Protobuf CONFIG NAMES protobuf)
42-
# Older versions of protobuf don't use cmake config files.
48+
find_package(Protobuf REQUIRED)
4349
if(NOT protobuf_FOUND)
50+
if(WIN32)
51+
install_windows_deps()
52+
endif()
4453
find_package(Protobuf REQUIRED)
54+
if(WIN32)
55+
# Always use x64 protoc.exe
56+
if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
57+
set(Protobuf_PROTOC_EXECUTABLE
58+
${CMAKE_CURRENT_SOURCE_DIR}/tools/vcpkg/packages/protobuf_x64-windows/tools/protobuf/protoc.exe
59+
)
60+
endif()
61+
endif()
62+
# Latest Protobuf uses mixed case instead of uppercase
63+
set(PROTOBUF_PROTOC_EXECUTABLE ${Protobuf_PROTOC_EXECUTABLE})
4564
endif()
65+
message("PROTOBUF_PROTOC_EXECUTABLE=${PROTOBUF_PROTOC_EXECUTABLE}")
4666
endif()
4767

4868
if(WITH_OTLP)
49-
include(third_party/opentelemetry-proto/Protobuf.cmake)
69+
include(cmake/opentelemetry-proto.cmake)
5070
endif()
5171

72+
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}")
73+
5274
if(BUILD_TESTING)
53-
find_package(GTest REQUIRED)
54-
find_package(benchmark REQUIRED)
75+
include(CTest)
76+
if(EXISTS ${CMAKE_BINARY_DIR}/lib/libgtest.a)
77+
# Prefer GTest from build tree. GTest is not always working with
78+
# CMAKE_PREFIX_PATH
79+
set(GTEST_INCLUDE_DIRS
80+
${CMAKE_CURRENT_SOURCE_DIR}/third_party/googletest/googletest/include
81+
${CMAKE_CURRENT_SOURCE_DIR}/third_party/googletest/googlemock/include)
82+
set(GTEST_BOTH_LIBRARIES
83+
${CMAKE_BINARY_DIR}/lib/libgtest.a
84+
${CMAKE_BINARY_DIR}/lib/libgtest_main.a
85+
${CMAKE_BINARY_DIR}/lib/libgmock.a)
86+
elseif(WIN32)
87+
# Make sure we are always bootsrapped with vcpkg on Windows
88+
find_package(GTest)
89+
if(NOT GTEST_FOUND)
90+
install_windows_deps()
91+
find_package(GTest REQUIRED)
92+
endif()
93+
else()
94+
# Prefer GTest installed by OS distro, brew or vcpkg package manager
95+
find_package(GTest REQUIRED)
96+
endif()
5597
include_directories(SYSTEM ${GTEST_INCLUDE_DIRS})
98+
message("GTEST_INCLUDE_DIRS = ${GTEST_INCLUDE_DIRS}")
99+
message("GTEST_BOTH_LIBRARIES = ${GTEST_BOTH_LIBRARIES}")
100+
enable_testing()
101+
# Benchmark respects the CMAKE_PREFIX_PATH
102+
find_package(benchmark CONFIG REQUIRED)
56103
endif()
57104

58105
include_directories(api/include)

CMakeSettings.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "nostd-x64-Debug",
5+
"generator": "Ninja",
6+
"configurationType": "Debug",
7+
"inheritEnvironments": [ "msvc_x64_x64" ],
8+
"buildRoot": "${projectDir}\\out\\vs2019\\${name}",
9+
"installRoot": "${projectDir}\\out\\vs2019\\${name}\\install",
10+
"cmakeCommandArgs": "",
11+
"buildCommandArgs": "",
12+
"ctestCommandArgs": "",
13+
"variables": [
14+
{
15+
"name": "WITH_OTLP",
16+
"value": "True",
17+
"type": "BOOL"
18+
},
19+
{
20+
"name": "WITH_EXAMPLES",
21+
"value": "true",
22+
"type": "BOOL"
23+
}
24+
]
25+
},
26+
{
27+
"name": "nostd-x64-Release",
28+
"generator": "Ninja",
29+
"configurationType": "RelWithDebInfo",
30+
"inheritEnvironments": [ "msvc_x64_x64" ],
31+
"buildRoot": "${projectDir}\\out\\vs2019\\${name}",
32+
"installRoot": "${projectDir}\\out\\vs2019\\${name}\\install",
33+
"cmakeCommandArgs": "",
34+
"buildCommandArgs": "",
35+
"ctestCommandArgs": "",
36+
"cmakeToolchain": "",
37+
"variables": [
38+
{
39+
"name": "WITH_OTLP",
40+
"value": "True",
41+
"type": "BOOL"
42+
},
43+
{
44+
"name": "WITH_EXAMPLES",
45+
"value": "true",
46+
"type": "BOOL"
47+
}
48+
]
49+
}
50+
]
51+
}

WORKSPACE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ http_archive(
8282

8383
http_archive(
8484
name = "github_nlohmann_json",
85-
build_file = "//third_party/json:nlohmann_json.BUILD",
85+
build_file = "//bazel:nlohmann_json.BUILD",
8686
sha256 = "69cc88207ce91347ea530b227ff0776db82dcb8de6704e1a3d74f4841bc651cf",
8787
urls = [
8888
"https://github.com/nlohmann/json/releases/download/v3.6.1/include.zip",
@@ -106,7 +106,7 @@ prometheus_cpp_repositories()
106106
# libcurl - An optional dependency we pull in for tests.
107107
http_archive(
108108
name = "curl",
109-
build_file = "@//third_party:curl.BUILD",
109+
build_file = "@//bazel:curl.BUILD",
110110
sha256 = "ba98332752257b47b9dea6d8c0ad25ec1745c20424f1dd3ff2c99ab59e97cf91",
111111
strip_prefix = "curl-7.73.0",
112112
urls = ["https://curl.haxx.se/download/curl-7.73.0.tar.gz"],

api/test/context/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@ foreach(testname context_test runtime_context_test)
44
add_executable(${testname} "${testname}.cc")
55
target_link_libraries(${testname} ${GTEST_BOTH_LIBRARIES}
66
${CMAKE_THREAD_LIBS_INIT} opentelemetry_api)
7-
gtest_add_tests(TARGET ${testname} TEST_PREFIX context. TEST_LIST ${testname})
7+
gtest_add_tests(
8+
TARGET ${testname}
9+
TEST_PREFIX context.
10+
TEST_LIST ${testname})
811
endforeach()

api/test/core/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ include(GoogleTest)
33
add_executable(timestamp_test timestamp_test.cc)
44
target_link_libraries(timestamp_test ${GTEST_BOTH_LIBRARIES}
55
${CMAKE_THREAD_LIBS_INIT} opentelemetry_api)
6-
gtest_add_tests(TARGET timestamp_test TEST_PREFIX trace. TEST_LIST
7-
timestamp_test)
6+
gtest_add_tests(
7+
TARGET timestamp_test
8+
TEST_PREFIX trace.
9+
TEST_LIST timestamp_test)

0 commit comments

Comments
 (0)