-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bundle C++ to SDK to artifact that can be used with CMake's fetch_con…
…tent (#3875) ### What * Fixes #3759 Change CMakeLists.txt in rerun_cpp to work standalone with add_directory. When used in this fashion it expects the `RERUN_C_LIB` variable to be set. The default for it points to a local `lib` folder with appropriately named libs. This in turn gives rise to a very trivial bundling strategy: * copy src * copy CMakeLists.txt * copy libs This is done in the new `build_and_upload_rerun_cpp` script which on top of the above also takes care of testing the resulting artifact by running the now also compatible minimal example outside of the repo. Another smaller necessary change is that the rerun.h C header is now copied into the rerun_cpp sdk with a patched version number in the comment. This is primarily so to keep the above process super simple and shave of an additional include directory. ~Draft until PR ci confirmed to be working.~ (PR checks only the linux artifact, main ci checks the full artifact and puts it on the Development Release notes) With this change, the minimal possible cmake script for a project using Rerun is: ```cmake project(hello_rerun) include(FetchContent) FetchContent_Declare(rerun_sdk URL https://build.rerun.io/commit/f4e5ad6/rerun_cpp.zip DOWNLOAD_EXTRACT_TIMESTAMP YES) FetchContent_MakeAvailable(rerun_sdk) add_executable(hello_rerun main.cpp) set_property(TARGET hello_rerun PROPERTY CXX_STANDARD 20) # Rerun requires C++17, but you can of course use an ever newer version. target_link_libraries(hello_rerun PRIVATE rerun_sdk) ```⚠️ **this STILL requires libarrow to be installed somewhere where cmake can find it**⚠️ ### 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/3875) (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/3875) - [Docs preview](https://rerun.io/preview/9ddbc213c8f4bd2ea288590f9ab2f2b9d48ae552/docs) <!--DOCS-PREVIEW--> - [Examples preview](https://rerun.io/preview/9ddbc213c8f4bd2ea288590f9ab2f2b9d48ae552/examples) <!--EXAMPLES-PREVIEW--> - [Recent benchmark results](https://ref.rerun.io/dev/bench/) - [Wasm size tracking](https://ref.rerun.io/dev/sizes/)
- Loading branch information
Showing
15 changed files
with
627 additions
and
58 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
61 changes: 61 additions & 0 deletions
61
.github/workflows/reusable_bundle_and_upload_rerun_cpp.yml
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Reusable C++ bundling and upload | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
PLATFORM_FILTER: | ||
required: false | ||
type: string | ||
UPLOAD_COMMIT_OVERRIDE: | ||
required: false | ||
type: string | ||
default: "" | ||
|
||
jobs: | ||
bundle-and-upload-rerun_cpp: | ||
name: C++ bundling and upload | ||
|
||
permissions: | ||
contents: "read" | ||
id-token: "write" | ||
pull-requests: "write" | ||
|
||
runs-on: ubuntu-latest | ||
# Need container for arrow dependency. | ||
container: | ||
image: rerunio/ci_docker:0.10.0 | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.sha }} | ||
|
||
- id: "auth" | ||
uses: google-github-actions/auth@v1 | ||
with: | ||
workload_identity_provider: ${{ secrets.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }} | ||
service_account: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }} | ||
|
||
- name: "Set up Cloud SDK" | ||
uses: "google-github-actions/setup-gcloud@v1" | ||
with: | ||
version: ">= 363.0.0" | ||
|
||
- name: Install python gcs library | ||
run: | | ||
python3 -m pip install google-cloud-storage | ||
- name: Add SHORT_SHA env property with commit short sha | ||
shell: bash | ||
id: "short-sha" | ||
run: | | ||
if [ -z "${{ inputs.UPLOAD_COMMIT_OVERRIDE }}" ]; then | ||
USED_SHA=${{ github.sha }} | ||
else | ||
USED_SHA=${{ inputs.UPLOAD_COMMIT_OVERRIDE }} | ||
fi | ||
echo "SHORT_SHA=$(echo $USED_SHA | cut -c1-7)" >> $GITHUB_OUTPUT | ||
- name: "Bundle & Upload rerun_cpp" | ||
run: python3 ./scripts/ci/bundle_and_upload_rerun_cpp.py --git-hash ${{ steps.short-sha.outputs.SHORT_SHA }} --platform-filter=${{ inputs.PLATFORM_FILTER }} |
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,6 +1,27 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
add_executable(example_minimal main.cpp) | ||
# If you use the example outside of the Rerun SDK you need to specify | ||
# where the rerun_c build is to be found by setting the `RERUN_CPP_URL` variable. | ||
# This can be done by passing `-DRERUN_CPP_URL=<path to rerun_sdk_cpp zip>` to cmake. | ||
if(DEFINED RERUN_REPOSITORY) | ||
add_executable(example_minimal main.cpp) | ||
set_default_warning_settings(example_minimal) | ||
else() | ||
project(example_minimal LANGUAGES CXX) | ||
|
||
set_default_warning_settings(example_minimal) | ||
add_executable(example_minimal main.cpp) | ||
|
||
# Set the path to the rerun_c build. | ||
set(RERUN_CPP_URL CACHE STRING "URL to the rerun_cpp zip.") | ||
|
||
# Download the rerun_sdk | ||
include(FetchContent) | ||
FetchContent_Declare(rerun_sdk DOWNLOAD_EXTRACT_TIMESTAMP YES URL ${RERUN_CPP_URL}) | ||
FetchContent_MakeAvailable(rerun_sdk) | ||
|
||
# Rerun requires at least C++17, but you can use an evern newer version. | ||
set_property(TARGET example_minimal PROPERTY CXX_STANDARD 17) | ||
endif() | ||
|
||
# Link against rerun_sdk. | ||
target_link_libraries(example_minimal PRIVATE rerun_sdk) |
Oops, something went wrong.