-
Notifications
You must be signed in to change notification settings - Fork 40
UniFFI C++ Bindging Integration #249
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
Draft
alan-george-lk
wants to merge
3
commits into
main
Choose a base branch
from
alan/feature-uniffi-cpp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule client-sdk-rust
updated
from 806641 to e7bc2c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| # Copyright 2026 LiveKit, Inc. | ||
| # | ||
| # 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. | ||
|
|
||
| set(LIVEKIT_UNIFFI_CPP_GENERATED_DIR "${LIVEKIT_BINARY_DIR}/generated/uniffi") | ||
| set(LIVEKIT_UNIFFI_CPP_SOURCE | ||
| "${LIVEKIT_UNIFFI_CPP_GENERATED_DIR}/livekit_ffi.cpp") | ||
| set(LIVEKIT_UNIFFI_CPP_HEADER | ||
| "${LIVEKIT_UNIFFI_CPP_GENERATED_DIR}/livekit_ffi.hpp") | ||
| set(LIVEKIT_UNIFFI_CPP_SCAFFOLDING_HEADER | ||
| "${LIVEKIT_UNIFFI_CPP_GENERATED_DIR}/livekit_ffi_scaffolding.hpp") | ||
|
|
||
| # Release Linux builds strip the UniFFI metadata symbols, so generate from a | ||
| # separate unstripped Debug library there. PE and Mach-O retain the metadata, | ||
| # allowing Windows and macOS to reuse the livekit-ffi library already built for | ||
| # the selected CMake configuration. | ||
| if(UNIX AND NOT APPLE) | ||
| set(LIVEKIT_UNIFFI_METADATA_TARGET_DIR | ||
| "${RUST_ROOT}/target/uniffi-cpp-metadata") | ||
| set(LIVEKIT_UNIFFI_METADATA_LIBRARY | ||
| "${LIVEKIT_UNIFFI_METADATA_TARGET_DIR}/debug/liblivekit_ffi.so") | ||
| endif() | ||
|
|
||
| file(GLOB_RECURSE LIVEKIT_UNIFFI_RUST_SOURCES CONFIGURE_DEPENDS | ||
| "${RUST_ROOT}/livekit-ffi/src/*.rs" | ||
| "${RUST_ROOT}/livekit-ffi/Cargo.toml" | ||
| ) | ||
| list(APPEND LIVEKIT_UNIFFI_RUST_SOURCES | ||
| "${RUST_ROOT}/Cargo.toml" | ||
| "${RUST_ROOT}/Cargo.lock" | ||
| "${RUST_ROOT}/rust-toolchain.toml" | ||
| ) | ||
|
|
||
| file(GLOB_RECURSE LIVEKIT_UNIFFI_BINDGEN_SOURCES CONFIGURE_DEPENDS | ||
| "${RUST_ROOT}/tools/bindgens/src/*.rs" | ||
| "${RUST_ROOT}/tools/bindgens/Cargo.toml" | ||
| ) | ||
|
|
||
| if(UNIX AND NOT APPLE) | ||
| add_custom_command( | ||
| OUTPUT "${LIVEKIT_UNIFFI_METADATA_LIBRARY}" | ||
| COMMAND "${CMAKE_COMMAND}" | ||
| -DCFG=Debug | ||
| -DRUST_ROOT=${RUST_ROOT} | ||
| -DCARGO=${CARGO_EXECUTABLE} | ||
| -DPROTOC_PATH=${Protobuf_PROTOC_EXECUTABLE} | ||
| -DGCC_LIB_DIR=${GCC_LIB_DIR} | ||
| -DCARGO_TARGET_DIR=${LIVEKIT_UNIFFI_METADATA_TARGET_DIR} | ||
| -P "${RUN_CARGO_SCRIPT}" | ||
| WORKING_DIRECTORY "${RUST_ROOT}" | ||
| DEPENDS ${LIVEKIT_UNIFFI_RUST_SOURCES} | ||
| COMMENT "Building unstripped livekit-ffi metadata library" | ||
| VERBATIM | ||
| ) | ||
| add_custom_target(build_livekit_ffi_metadata | ||
| DEPENDS "${LIVEKIT_UNIFFI_METADATA_LIBRARY}") | ||
| else() | ||
| set(LIVEKIT_UNIFFI_METADATA_LIBRARY "$<TARGET_FILE:livekit_ffi>") | ||
| add_custom_target(build_livekit_ffi_metadata) | ||
| endif() | ||
|
|
||
| # Keep Cargo invocations serialized on fresh runners, and ensure the selected | ||
| # livekit-ffi library exists before it is inspected on Windows and macOS. | ||
| add_dependencies(build_livekit_ffi_metadata build_rust_ffi) | ||
|
|
||
| add_custom_command( | ||
| OUTPUT | ||
| "${LIVEKIT_UNIFFI_CPP_SOURCE}" | ||
| "${LIVEKIT_UNIFFI_CPP_HEADER}" | ||
| "${LIVEKIT_UNIFFI_CPP_SCAFFOLDING_HEADER}" | ||
| COMMAND "${CMAKE_COMMAND}" -E make_directory | ||
| "${LIVEKIT_UNIFFI_CPP_GENERATED_DIR}" | ||
| COMMAND "${CMAKE_COMMAND}" -E env | ||
| "CARGO_TARGET_DIR=${RUST_ROOT}/target/bindgens" | ||
| "CARGO_ENCODED_RUSTFLAGS=" | ||
| "RUSTFLAGS=" | ||
| "${CARGO_EXECUTABLE}" run --locked | ||
| --package bindgens | ||
| --bin uniffi-bindgen-cpp | ||
| -- | ||
| --library "${LIVEKIT_UNIFFI_METADATA_LIBRARY}" | ||
| --out-dir "${LIVEKIT_UNIFFI_CPP_GENERATED_DIR}" | ||
| WORKING_DIRECTORY "${RUST_ROOT}" | ||
| DEPENDS | ||
| build_livekit_ffi_metadata | ||
| ${LIVEKIT_UNIFFI_RUST_SOURCES} | ||
| ${LIVEKIT_UNIFFI_BINDGEN_SOURCES} | ||
| COMMENT "Generating UniFFI C++ bindings" | ||
| VERBATIM | ||
| ) | ||
| add_custom_target(generate_livekit_ffi_uniffi_cpp | ||
| DEPENDS | ||
| "${LIVEKIT_UNIFFI_CPP_SOURCE}" | ||
| "${LIVEKIT_UNIFFI_CPP_HEADER}" | ||
| "${LIVEKIT_UNIFFI_CPP_SCAFFOLDING_HEADER}" | ||
| ) | ||
|
|
||
| set_source_files_properties( | ||
| "${LIVEKIT_UNIFFI_CPP_SOURCE}" | ||
| "${LIVEKIT_UNIFFI_CPP_HEADER}" | ||
| "${LIVEKIT_UNIFFI_CPP_SCAFFOLDING_HEADER}" | ||
| PROPERTIES GENERATED TRUE | ||
| ) | ||
|
|
||
| add_library(livekit_uniffi_cpp OBJECT | ||
| "${LIVEKIT_UNIFFI_CPP_SOURCE}" | ||
| ) | ||
| add_dependencies(livekit_uniffi_cpp generate_livekit_ffi_uniffi_cpp) | ||
| target_include_directories(livekit_uniffi_cpp | ||
| PUBLIC "${LIVEKIT_UNIFFI_CPP_GENERATED_DIR}" | ||
| ) | ||
| target_link_libraries(livekit_uniffi_cpp PRIVATE livekit_ffi) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /* | ||
| * Copyright 2026 LiveKit, Inc. | ||
| * | ||
| * 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 <gtest/gtest.h> | ||
|
|
||
| #include <livekit_ffi.hpp> | ||
|
|
||
| namespace livekit { | ||
| namespace { | ||
|
|
||
| TEST(UniFfiTest, BuildVersion) { | ||
| const auto version = livekit_ffi::build_version(); | ||
| std::cout << "build_version: " << version << std::endl; | ||
| EXPECT_FALSE(version.empty()); | ||
| EXPECT_NE(version, "unknown"); | ||
| } | ||
|
|
||
| } // namespace | ||
| } // namespace livekit |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
These are only needed until we actually get features through the SDK in UniFFI. I can add a comment for this