Skip to content

Commit b3ff7c4

Browse files
authored
Add numeric SDK version macros to C/C++ (#7127)
### What * Fixes #6379 * Related to #7104 Allows finally to do `#if` preprocessor checks on Rerun versions. Uses the same up update version script introduced for Python and does away with cmake driven duplication of rerun.h ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested the web demo (if applicable): * Using examples from latest `main` build: [rerun.io/viewer](https://rerun.io/viewer/pr/7127?manifest_url=https://app.rerun.io/version/main/examples_manifest.json) * Using full set of examples from `nightly` build: [rerun.io/viewer](https://rerun.io/viewer/pr/7127?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json) * [x] The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG * [x] If applicable, add a new check to the [release checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)! * [x] If have noted any breaking changes to the log API in `CHANGELOG.md` and the migration guide - [PR Build Summary](https://build.rerun.io/pr/7127) - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html) To run all checks from `main`, comment on the PR with `@rerun-bot full-check`.
1 parent b20d107 commit b3ff7c4

File tree

12 files changed

+197
-678
lines changed

12 files changed

+197
-678
lines changed

.github/workflows/release.yml

+4-11
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ jobs:
137137
echo "current=$current" >> "$GITHUB_OUTPUT"
138138
echo "final=$final" >> "$GITHUB_OUTPUT"
139139
140-
- name: Update rerun_py version
140+
- name: Update rerun_py & rerun_c version
141141
run: |
142-
pixi run python scripts/ci/update_rerun_py_version.py "${{ steps.versioning.outputs.current }}"
142+
pixi run python scripts/ci/update_rerun_py_and_c_version.py "${{ steps.versioning.outputs.current }}"
143143
144144
- name: Update rerun_notebook package version
145145
run: |
@@ -149,12 +149,6 @@ jobs:
149149
run: |
150150
pixi run node rerun_js/scripts/version.mjs "${{ steps.versioning.outputs.current }}"
151151
152-
- name: Update rerun_c version
153-
154-
# Configuring CMake is enough to change the version on rerun.h!
155-
run: |
156-
cmake -B build -S .
157-
158152
- run: pixi run toml-fmt
159153

160154
- name: Commit new version
@@ -428,10 +422,9 @@ jobs:
428422
run: |
429423
pixi run node rerun_js/scripts/version.mjs "${{ steps.crates.outputs.version }}"
430424
431-
- name: Update rerun_c version
432-
# Configuring CMake is enough to change the version on rerun.h!
425+
- name: Update rerun_py & rerun_c version
433426
run: |
434-
cmake -B build -S .
427+
pixi run python scripts/ci/update_rerun_py_and_c_version.py "${{ steps.versioning.outputs.current }}"
435428
436429
- run: pixi run toml-fmt
437430

CMakeLists.txt

-7
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,6 @@ endif()
137137
# Signal to all our build scripts that we're inside the Rerun repository.
138138
set(RERUN_REPOSITORY YES)
139139

140-
# Set version number.
141-
# Read it from the Rust toml with a regex so we don't have another place to maintain!
142-
file(READ "Cargo.toml" CARGO_TOML)
143-
string(REGEX MATCH "\nversion = \"([a-z0-9\.\+-]+)\"\n" _ ${CARGO_TOML})
144-
set(RERUN_VERSION ${CMAKE_MATCH_1})
145-
message(STATUS "Rerun version ${RERUN_VERSION}")
146-
147140
# ------------------------------------------------------------------------------
148141
# Loguru logging library (https://github.com/emilk/loguru):
149142
set(CMAKE_DL_LIBS "dl") # Required by Loguru for backtraces

crates/top/rerun_c/CMakeLists.txt

-7
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,3 @@ add_custom_command(
2828
# 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.
2929
add_custom_target(rerun_c_build DEPENDS "${RERUN_C_BUILD_ARTIFACT}")
3030
add_dependencies(rerun_c rerun_c_build)
31-
32-
# Put `rerun.h` into the same place where it's on a user's machine and apply CMake variables like version number.
33-
configure_file(
34-
"${CMAKE_CURRENT_SOURCE_DIR}/src/rerun.h"
35-
"${PROJECT_SOURCE_DIR}/rerun_cpp/src/rerun/c/rerun.h"
36-
NEWLINE_STYLE LF # Specify line endings, otherwise CMake wants to change them on Windows.
37-
)

crates/top/rerun_c/src/lib.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! The Rerun C SDK.
22
//!
3-
//! The functions here must match `rerun.h`.
3+
//! The functions here must match `rerun_cpp/src/rerun/c/rerun.h`.
44
55
#![crate_type = "staticlib"]
66
#![allow(clippy::missing_safety_doc, clippy::undocumented_unsafe_blocks)] // Too much unsafe
@@ -305,7 +305,15 @@ pub struct CError {
305305
#[no_mangle]
306306
pub extern "C" fn rr_version_string() -> *const c_char {
307307
static VERSION: Lazy<CString> = Lazy::new(|| {
308-
CString::new(re_sdk::build_info().version.to_string()).expect("CString::new failed")
308+
CString::new(
309+
re_sdk::build_info()
310+
.version
311+
.to_string()
312+
// We use `+dev` as a marker for "this version is unreleased".
313+
// Ignore it here since we don't update the version macros either on that frequency.
314+
.trim_end_matches("+dev"),
315+
)
316+
.expect("CString::new failed")
309317
}); // unwrap: there won't be any NUL bytes in the string
310318

311319
VERSION.as_ptr()

0 commit comments

Comments
 (0)