-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
C++ SDK sanity checks now header/source version against rerun_c binar…
…y version (#4330) ### What * Fixes #3868 * Fixes left over to set generic package version from #4326 * Yes there's two levels of regex'ing existing files now, but I'm happy with it because it avoids etching the version into more places: The repo cmake setup first figures out the rerun version by taking a look at Cargo.toml and puts that into rerun.h which we commit. Then when doing an install (in repo or outside!) we check rerun.h's version and put that into the CMake Install shenanigans Tests erro'red correctly when I still had a longer string, looked like this: ``` ------------------------------------------------------------------------------- Scenario: RecordingStream can connect Given: a new RecordingStream ------------------------------------------------------------------------------- /Users/andreas/dev/rerun-io/rerun/rerun_cpp/tests/recording_stream.cpp:433 ............................................................................... /Users/andreas/dev/rerun-io/rerun/rerun_cpp/tests/recording_stream.cpp:433: FAILED: due to unexpected exception with message: Rerun_c SDK version and SDK header/source versions don't match match. Make sure to link against the correct version of the rerun_c library. Rerun_c version: re_sdk 0.11.0-alpha.1+dev [rustc 1.72.1 (d5c2e9c34 2023-09-13), LLVM 16.0.5] aarch64-apple-darwin SDK header/source version: 0.11.0-alpha.1+dev ``` ### 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 [demo.rerun.io](https://demo.rerun.io/pr/4330) (if applicable) * [x] The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG - [PR Build Summary](https://build.rerun.io/pr/4330) - [Docs preview](https://rerun.io/preview/72b1b7eedaa4934a8a34d1ab498c9b7752dd8125/docs) <!--DOCS-PREVIEW--> - [Examples preview](https://rerun.io/preview/72b1b7eedaa4934a8a34d1ab498c9b7752dd8125/examples) <!--EXAMPLES-PREVIEW--> - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
- Loading branch information
Showing
10 changed files
with
71 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 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 |
---|---|---|
@@ -1,8 +1,33 @@ | ||
#include "sdk_info.hpp" | ||
#include "c/rerun.h" | ||
|
||
#include <cstring> // strcmp | ||
#include <string> | ||
|
||
#include "c/rerun.h" | ||
|
||
namespace rerun { | ||
const char* version_string() { | ||
return rr_version_string(); | ||
} | ||
|
||
Error check_binary_and_header_version_match() { | ||
const char* binary_version = version_string(); | ||
|
||
if (strcmp(binary_version, RERUN_SDK_HEADER_VERSION) == 0) { | ||
return Error::ok(); | ||
} else { | ||
return Error( | ||
ErrorCode::SdkVersionMismatch, | ||
std::string( | ||
"Rerun_c SDK version and SDK header/source versions don't match. " | ||
"Make sure to link against the correct version of the rerun_c library.\n" | ||
"rerun_c binary version:\n" | ||
) | ||
.append(binary_version) | ||
.append("\nrerun_c header version:\n") | ||
.append(RERUN_SDK_HEADER_VERSION) | ||
); | ||
} | ||
} | ||
} // namespace rerun |
This file contains 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 |
---|---|---|
@@ -1,7 +1,16 @@ | ||
// General information about the SDK. | ||
#pragma once | ||
|
||
#include "error.hpp" | ||
|
||
namespace rerun { | ||
/// The Rerun C++ SDK version as a human-readable string. | ||
const char* version_string(); | ||
|
||
/// Internal check whether the version reported by the rerun_c binary matches `sdk_version_string`. | ||
/// | ||
/// This method is called on various C++ API entry points, calling `Error::handle` on the return value. | ||
/// There is no need to call this method yourself unless you want to ensure that rerun_c binary and | ||
/// rerun_c header versions match ahead of time. | ||
Error check_binary_and_header_version_match(); | ||
} // namespace rerun |
This file contains 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