Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
- CMakeLists.txt
- build.sh
- build.cmd
- build-info.json.in
- vcpkg.json
- CMakePresets.json
- docker/Dockerfile.base
Expand All @@ -34,6 +35,7 @@ on:
- CMakeLists.txt
- build.sh
- build.cmd
- build-info.json.in
- vcpkg.json
- CMakePresets.json
- docker/Dockerfile.base
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- build.sh
- build.cmd
- build.h.in
- build-info.json.in
- CMakePresets.json
- cmake/**
- data/**
Expand Down Expand Up @@ -89,7 +90,7 @@ jobs:
fi
case "${path}" in
docker/Dockerfile.sdk|src/*|include/*|bridge/*|client-sdk-rust/*|cmake/*|data/*|CMakeLists.txt|build.sh|build.cmd|build.h.in|CMakePresets.json)
docker/Dockerfile.sdk|src/*|include/*|bridge/*|client-sdk-rust/*|cmake/*|data/*|CMakeLists.txt|build.sh|build.cmd|build.h.in|build-info.json.in|CMakePresets.json)
sdk_changed=true
;;
esac
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/make-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,27 @@ jobs:
echo "Bundle contents:"
find "$bundleDir" -type f | head -120

- name: Validate bundle version metadata (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
set -euo pipefail
version="${{ steps.version.outputs.version }}"
bundleDir="sdk-out/livekit-sdk-${{ matrix.name }}-${version}"
header="${bundleDir}/include/livekit/build.h"
buildInfo="${bundleDir}/share/livekit/build-info.json"

test -f "$header"
test -f "$buildInfo"
grep -F "#define LIVEKIT_BUILD_VERSION \"${version}\"" "$header"
if grep -F '#define LIVEKIT_BUILD_VERSION "0.0.0"' "$header"; then
echo "ERROR: bundle reports fallback SDK version"
exit 1
fi
grep -F "\"sdk_version\": \"${version}\"" "$buildInfo"
grep -Eq '"rust_submodule_commit": "[0-9a-f]{7,}"' "$buildInfo"
grep -Eq '"livekit_ffi_version": "[0-9]+\.[0-9]+\.[0-9]+' "$buildInfo"

# ---------- Build + Bundle (Windows) ----------
- name: Build and Bundle (Windows)
if: runner.os == 'Windows'
Expand Down Expand Up @@ -243,6 +264,39 @@ jobs:
}
python .github/scripts/check_no_private_symbols.py "$lib"

- name: Validate bundle version metadata (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$version = "${{ steps.version.outputs.version }}"
$bundleDir = "sdk-out/livekit-sdk-${{ matrix.name }}-$version"
$header = Join-Path $bundleDir "include/livekit/build.h"
$buildInfo = Join-Path $bundleDir "share/livekit/build-info.json"

if (!(Test-Path $header)) { throw "Missing $header" }
if (!(Test-Path $buildInfo)) { throw "Missing $buildInfo" }

$headerText = Get-Content -Raw $header
$expectedHeaderVersion = "#define LIVEKIT_BUILD_VERSION `"$version`""
if (!$headerText.Contains($expectedHeaderVersion)) {
throw "Header does not report expected SDK version $version"
}
if ($headerText.Contains('#define LIVEKIT_BUILD_VERSION "0.0.0"')) {
throw "Bundle reports fallback SDK version"
}

$buildInfoText = Get-Content -Raw $buildInfo
$expectedBuildInfoVersion = "`"sdk_version`": `"$version`""
if (!$buildInfoText.Contains($expectedBuildInfoVersion)) {
throw "Build info does not report expected SDK version $version"
}
if ($buildInfoText -match '"rust_submodule_commit": "unknown"') {
throw "Build info is missing Rust submodule commit"
}
if ($buildInfoText -match '"livekit_ffi_version": "unknown"') {
throw "Build info is missing livekit-ffi version"
}

# ---------- Upload artifact (raw directory, no pre-compression) ----------
- name: Upload build artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
Expand Down
40 changes: 37 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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(
Expand All @@ -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}")
Copy link
Copy Markdown
Contributor

@ladvoc ladvoc May 12, 2026

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:

cargo metadata --format-version 1 | jq -r '.packages[] | select(.name=="livekit-ffi").version'

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")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nite, BUILD_DATE is local time ?

maybe we can consider something like
string(TIMESTAMP BUILD_DATE "%Y-%m-%dT%H:%M:%SZ" UTC)

set(GENERATED_COMMENT "This file was auto-generated by CMake on ${BUILD_DATE}. Do NOT edit manually.")
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions build-info.json.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

.build-info.json.in ?

"sdk": "cpp",
"sdk_version": "@LIVEKIT_VERSION@",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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@"
}
2 changes: 1 addition & 1 deletion client-sdk-rust
4 changes: 3 additions & 1 deletion docker/Dockerfile.sdk
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
ARG BASE_IMAGE=livekit-cpp-sdk-base
FROM ${BASE_IMAGE}

ARG LIVEKIT_VERSION=0.0.0
ENV SDK_INSTALL_PREFIX=/opt/livekit-sdk

# Copy project source (build context = repo root)
Expand All @@ -36,6 +37,7 @@ COPY data /client-sdk-cpp/data
COPY cmake /client-sdk-cpp/cmake
COPY CMakeLists.txt /client-sdk-cpp/CMakeLists.txt
COPY build.h.in /client-sdk-cpp/build.h.in
COPY build-info.json.in /client-sdk-cpp/build-info.json.in

# Configure Rust linker: use full GCC path so liblto_plugin.so is found (not /home/installs/ which has no plugin)
RUN mkdir -p /client-sdk-cpp/client-sdk-rust/.cargo \
Expand All @@ -50,5 +52,5 @@ RUN LLVM_VERSION="$(llvm-config --version | cut -d. -f1)" \
&& export CFLAGS="-Wno-deprecated-declarations" \
&& chmod +x /client-sdk-cpp/build.sh \
&& cd /client-sdk-cpp \
&& ./build.sh release --bundle --prefix "${SDK_INSTALL_PREFIX}" \
&& ./build.sh release --version "${LIVEKIT_VERSION}" --bundle --prefix "${SDK_INSTALL_PREFIX}" \
&& test -f "${SDK_INSTALL_PREFIX}/lib/cmake/LiveKit/LiveKitConfig.cmake"
2 changes: 1 addition & 1 deletion src/ffi_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ bool FfiClient::initialize(bool capture_logs) {
return false;
}
initialized_.store(true, std::memory_order_release);
livekit_ffi_initialize(&LivekitFfiCallback, capture_logs, LIVEKIT_BUILD_FLAVOR, LIVEKIT_BUILD_VERSION_FULL);
livekit_ffi_initialize(&LivekitFfiCallback, capture_logs, LIVEKIT_BUILD_FLAVOR, LIVEKIT_BUILD_VERSION);
return true;
}

Expand Down
10 changes: 10 additions & 0 deletions src/tests/unit/test_sdk_initialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <gtest/gtest.h>
#include <livekit/livekit.h>

#include <string>

namespace livekit::test {

class SDKInitializationTest : public ::testing::Test {
Expand Down Expand Up @@ -65,4 +67,12 @@ TEST_F(SDKInitializationTest, MultipleShutdowns) {
EXPECT_NO_THROW(livekit::shutdown());
}

TEST(SDKBuildInfoTest, ServerFacingVersionDoesNotIncludeBuildFlavorSuffix) {
const std::string version = LIVEKIT_BUILD_VERSION;

EXPECT_FALSE(version.empty());
EXPECT_EQ(version.find("-debug"), std::string::npos);
EXPECT_EQ(version.find("-release"), std::string::npos);
}

} // namespace livekit::test
Loading