-
Notifications
You must be signed in to change notification settings - Fork 27
proper reporting of rust version based on git commit hash - build-info #123
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,12 @@ if(NOT DEFINED LIVEKIT_VERSION OR LIVEKIT_VERSION STREQUAL "") | |
| set(LIVEKIT_VERSION "0.0.0") | ||
| endif() | ||
|
|
||
| project(livekit VERSION ${LIVEKIT_VERSION} LANGUAGES C CXX) | ||
| string(REGEX MATCH "^[0-9][0-9]*\\.[0-9][0-9]*\\.[0-9][0-9]*" LIVEKIT_PROJECT_VERSION "${LIVEKIT_VERSION}") | ||
| if(LIVEKIT_PROJECT_VERSION STREQUAL "") | ||
| message(FATAL_ERROR "LIVEKIT_VERSION must start with a numeric version, got '${LIVEKIT_VERSION}'") | ||
| endif() | ||
|
|
||
| project(livekit VERSION ${LIVEKIT_PROJECT_VERSION} LANGUAGES C CXX) | ||
|
|
||
| set(LIVEKIT_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) | ||
| set(LIVEKIT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
|
@@ -144,8 +149,11 @@ target_sources(livekit_proto PRIVATE ${PROTO_SRCS} ${PROTO_HDRS}) | |
|
|
||
| # Generate build.h directly into include/livekit/ for simpler include paths | ||
| set(GENERATED_BUILD_H "${LIVEKIT_ROOT_DIR}/include/livekit/build.h") | ||
| set(GENERATED_BUILD_INFO_JSON "${LIVEKIT_BINARY_DIR}/build-info.json") | ||
| set(RUST_ROOT ${LIVEKIT_ROOT_DIR}/client-sdk-rust) | ||
|
|
||
| set(GIT_COMMIT "unknown") | ||
| set(RUST_GIT_COMMIT "unknown") | ||
| find_package(Git QUIET) | ||
| if(GIT_FOUND AND EXISTS "${LIVEKIT_ROOT_DIR}/.git") | ||
| execute_process( | ||
|
|
@@ -156,6 +164,25 @@ if(GIT_FOUND AND EXISTS "${LIVEKIT_ROOT_DIR}/.git") | |
| ERROR_QUIET | ||
| ) | ||
| endif() | ||
| if(GIT_FOUND AND EXISTS "${RUST_ROOT}/.git") | ||
| execute_process( | ||
| COMMAND "${GIT_EXECUTABLE}" rev-parse --short HEAD | ||
| WORKING_DIRECTORY "${RUST_ROOT}" | ||
| OUTPUT_VARIABLE RUST_GIT_COMMIT | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| ERROR_QUIET | ||
| ) | ||
| endif() | ||
|
|
||
| set(LIVEKIT_FFI_VERSION "unknown") | ||
| set(LIVEKIT_FFI_CARGO_TOML "${RUST_ROOT}/livekit-ffi/Cargo.toml") | ||
| if(EXISTS "${LIVEKIT_FFI_CARGO_TOML}") | ||
| file(READ "${LIVEKIT_FFI_CARGO_TOML}" LIVEKIT_FFI_CARGO_TOML_CONTENTS) | ||
| string(REGEX MATCH "version[ \t]*=[ \t]*\"([^\"]+)\"" _LIVEKIT_FFI_VERSION_MATCH "${LIVEKIT_FFI_CARGO_TOML_CONTENTS}") | ||
| if(_LIVEKIT_FFI_VERSION_MATCH) | ||
| set(LIVEKIT_FFI_VERSION "${CMAKE_MATCH_1}") | ||
| endif() | ||
| endif() | ||
|
|
||
| string(TIMESTAMP BUILD_DATE "%Y-%m-%d %H:%M:%S") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nite, BUILD_DATE is local time ? maybe we can consider something like |
||
| set(GENERATED_COMMENT "This file was auto-generated by CMake on ${BUILD_DATE}. Do NOT edit manually.") | ||
|
|
@@ -165,11 +192,14 @@ configure_file( | |
| "${GENERATED_BUILD_H}" | ||
| @ONLY | ||
| ) | ||
| configure_file( | ||
| "${LIVEKIT_ROOT_DIR}/build-info.json.in" | ||
| "${GENERATED_BUILD_INFO_JSON}" | ||
| @ONLY | ||
| ) | ||
|
|
||
| find_program(CARGO_EXECUTABLE NAMES cargo REQUIRED) | ||
|
|
||
| set(RUST_ROOT ${LIVEKIT_ROOT_DIR}/client-sdk-rust) | ||
|
|
||
| # Determine Rust target triple for cross-compilation on macOS | ||
| set(RUST_TARGET_TRIPLE "") | ||
| if(APPLE AND CMAKE_OSX_ARCHITECTURES) | ||
|
|
@@ -583,6 +613,10 @@ include(CMakePackageConfigHelpers) | |
| set(LIVEKIT_PACKAGE_NAME "LiveKit") | ||
| set(LIVEKIT_EXPORT_NAMESPACE "LiveKit::") | ||
|
|
||
| install(FILES "${GENERATED_BUILD_INFO_JSON}" | ||
| DESTINATION "${CMAKE_INSTALL_DATADIR}/livekit" | ||
| ) | ||
|
|
||
| # Install the library target | ||
| install(TARGETS livekit | ||
| EXPORT LiveKitTargets | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very minor suggestion: since this is a build info/bundled version thing and isn't really user-facing, consider an alternative sub-folder (besides root) for it
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| "sdk": "cpp", | ||
| "sdk_version": "@LIVEKIT_VERSION@", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should you use the sanitized LIVEKIT_PROJECT_VERSION instead ? |
||
| "cpp_git_commit": "@GIT_COMMIT@", | ||
| "rust_submodule_commit": "@RUST_GIT_COMMIT@", | ||
| "livekit_ffi_version": "@LIVEKIT_FFI_VERSION@", | ||
| "build_date": "@BUILD_DATE@" | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Might not be worth doing here because of the dep on
jq, but this could be more robust: