Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building otlp exporter from the release tarball #1056

Merged
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")
endif()

if(EXISTS "${CMAKE_SOURCE_DIR}/third_party_release")
ThomsonTan marked this conversation as resolved.
Show resolved Hide resolved
file(STRINGS "${CMAKE_SOURCE_DIR}/third_party_release" third_party_tags)
foreach(third_party ${third_party_tags})
string(REGEX REPLACE "^[ ]+" "" third_party ${third_party})
string(REGEX MATCH "^[^=]+" third_party_name ${third_party})
string(REPLACE "${third_party_name}=" "" third_party_tag ${third_party})
set(${third_party_name} "${third_party_tag}")
endforeach()
endif()

Copy link
Member

@lalitb lalitb Nov 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to understand the logic here. We iterate the file and extract the name and version from each entry. In the end, third_party_name and third_party_tag contain name and version for last entry of file. What are we going to do with the last entry?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we are storing all the versions not just the last one. e.g. ${nlohmann-json} has v3.9.1, or ${opentelemetry-proto} has, v0.11.0.
In this PR I use ${opentelemetry-proto} to download it from github.
We can use the same technique for all the other dependencies when they are not available in the third_party folder.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah got it, I missed the set command.

if(DEFINED ENV{ARCH})
# Architecture may be specified via ARCH environment variable
set(ARCH $ENV{ARCH})
Expand Down
37 changes: 35 additions & 2 deletions cmake/opentelemetry-proto.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
include(${PROJECT_SOURCE_DIR}/cmake/proto-options-patch.cmake)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto/.git)
set(PROTO_PATH "${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto")
set(needs_proto_download FALSE)
else()
if("${opentelemetry-proto}" STREQUAL "")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how would this be defined to point to a specific version/branch?

set(opentelemetry-proto "main")
endif()
include(ExternalProject)
ExternalProject_Add(opentelemetry-proto
GIT_REPOSITORY https://github.com/open-telemetry/opentelemetry-proto.git
GIT_TAG
"${opentelemetry-proto}"
UPDATE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
CONFIGURE_COMMAND ""
TEST_AFTER_INSTALL
0
DOWNLOAD_NO_PROGRESS
1
LOG_CONFIGURE
1
LOG_BUILD
1
LOG_INSTALL
1
)
ExternalProject_Get_Property(opentelemetry-proto INSTALL_DIR)
set(PROTO_PATH "${INSTALL_DIR}/src/opentelemetry-proto")
set(needs_proto_download TRUE)
endif()

set(PROTO_PATH "${CMAKE_CURRENT_SOURCE_DIR}/third_party/opentelemetry-proto")
include(${PROJECT_SOURCE_DIR}/cmake/proto-options-patch.cmake)

set(COMMON_PROTO "${PROTO_PATH}/opentelemetry/proto/common/v1/common.proto")
set(RESOURCE_PROTO
Expand Down Expand Up @@ -138,6 +168,9 @@ add_library(
${METRICS_SERVICE_PB_CPP_FILE}
${METRICS_SERVICE_GRPC_PB_CPP_FILE})

if(needs_proto_download)
add_dependencies(opentelemetry_proto opentelemetry-proto)
endif()
set_target_properties(opentelemetry_proto PROPERTIES EXPORT_NAME proto)
patch_protobuf_targets(opentelemetry_proto)

Expand Down