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

Add numeric SDK version macros to C/C++ #7127

Merged
merged 6 commits into from
Aug 12, 2024
Merged
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
15 changes: 4 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ jobs:
echo "current=$current" >> "$GITHUB_OUTPUT"
echo "final=$final" >> "$GITHUB_OUTPUT"

- name: Update rerun_py version
- name: Update rerun_py & rerun_c version
run: |
pixi run python scripts/ci/update_rerun_py_version.py "${{ steps.versioning.outputs.current }}"
pixi run python scripts/ci/update_rerun_py_and_c_version.py "${{ steps.versioning.outputs.current }}"

- name: Update rerun_notebook package version
run: |
Expand All @@ -149,12 +149,6 @@ jobs:
run: |
pixi run node rerun_js/scripts/version.mjs "${{ steps.versioning.outputs.current }}"

- name: Update rerun_c version

# Configuring CMake is enough to change the version on rerun.h!
run: |
cmake -B build -S .

- run: pixi run toml-fmt

- name: Commit new version
Expand Down Expand Up @@ -428,10 +422,9 @@ jobs:
run: |
pixi run node rerun_js/scripts/version.mjs "${{ steps.crates.outputs.version }}"

- name: Update rerun_c version
# Configuring CMake is enough to change the version on rerun.h!
- name: Update rerun_py & rerun_c version
run: |
cmake -B build -S .
pixi run python scripts/ci/update_rerun_py_and_c_version.py "${{ steps.versioning.outputs.current }}"

- run: pixi run toml-fmt

Expand Down
7 changes: 0 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,6 @@ endif()
# Signal to all our build scripts that we're inside the Rerun repository.
set(RERUN_REPOSITORY YES)

# Set version number.
# Read it from the Rust toml with a regex so we don't have another place to maintain!
file(READ "Cargo.toml" CARGO_TOML)
string(REGEX MATCH "\nversion = \"([a-z0-9\.\+-]+)\"\n" _ ${CARGO_TOML})
set(RERUN_VERSION ${CMAKE_MATCH_1})
message(STATUS "Rerun version ${RERUN_VERSION}")

# ------------------------------------------------------------------------------
# Loguru logging library (https://github.com/emilk/loguru):
set(CMAKE_DL_LIBS "dl") # Required by Loguru for backtraces
Expand Down
7 changes: 0 additions & 7 deletions crates/top/rerun_c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,3 @@ add_custom_command(
# In CMake you can't depend on an output file directly. We have to wrap this in a target that rerun_c then depends on.
add_custom_target(rerun_c_build DEPENDS "${RERUN_C_BUILD_ARTIFACT}")
add_dependencies(rerun_c rerun_c_build)

# Put `rerun.h` into the same place where it's on a user's machine and apply CMake variables like version number.
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/src/rerun.h"
"${PROJECT_SOURCE_DIR}/rerun_cpp/src/rerun/c/rerun.h"
NEWLINE_STYLE LF # Specify line endings, otherwise CMake wants to change them on Windows.
)
12 changes: 10 additions & 2 deletions crates/top/rerun_c/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! The Rerun C SDK.
//!
//! The functions here must match `rerun.h`.
//! The functions here must match `rerun_cpp/src/rerun/c/rerun.h`.

#![crate_type = "staticlib"]
#![allow(clippy::missing_safety_doc, clippy::undocumented_unsafe_blocks)] // Too much unsafe
Expand Down Expand Up @@ -305,7 +305,15 @@ pub struct CError {
#[no_mangle]
pub extern "C" fn rr_version_string() -> *const c_char {
static VERSION: Lazy<CString> = Lazy::new(|| {
CString::new(re_sdk::build_info().version.to_string()).expect("CString::new failed")
CString::new(
re_sdk::build_info()
.version
.to_string()
// We use `+dev` as a marker for "this version is unreleased".
// Ignore it here since we don't update the version macros either on that frequency.
.trim_end_matches("+dev"),
)
.expect("CString::new failed")
}); // unwrap: there won't be any NUL bytes in the string

VERSION.as_ptr()
Expand Down
Loading
Loading