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 example of downloading rerun c++ lib via pixi #30

Merged
merged 4 commits into from
Aug 6, 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
5 changes: 4 additions & 1 deletion .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ jobs:
pixi-version: v0.25.0
cache: true

- run: pixi run build
- name: run build task on all environments
run: |
pixi run build-fetchcontent
pixi run build-findpackage
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build directory
build
# Build directories
build_*

# Pixi environment
.pixi
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ This is a minimal CMake project that shows how to use [Rerun](https://github.com
The easiest way to get started is to install [pixi](https://prefix.dev/docs/pixi/overview).

The pixi environment described in `pixi.toml` contains all of the dependencies, including the rerun viewer,
allowing you to run the example with a single command:
allowing you to run the example with a single command, while the rerun C++ SDK is downloaded via `FetchContent`
* `pixi run example`

If you want to also download rerun C++ SDK via pixi, you can run:
* `pixi run example-findpackage`

## Without `pixi`
If you choose not to use pixi, you will need to install a few things yourself before you get started.

Expand Down
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ignoreWords": [
"eigen",
"Eigen",
"findpackage",
"pixi",
"srcset"
]
Expand Down
3,402 changes: 2,914 additions & 488 deletions pixi.lock

Large diffs are not rendered by default.

82 changes: 67 additions & 15 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,73 @@ readme = "README.md"
repository = "https://github.com/rerun-io/cpp-example-opencv-eigen"
version = "0.1.0"

# The following activation scripts make the tasks portable cross-platform.
#
# They define:
# - CMAKE_GENERATOR
# - BUILD_FOLDER
# - EXE_PATH
#
# In particular, BUILD_FOLDER will be set to either:
# - build_fetchcontent
# - build_findpackage
# depending on the feature being used.
[activation]
scripts = ["pixi/env.sh"]

[target.win-64.activation]
scripts = ["pixi/env.bat"]

################################################################################
# Common Tasks
################################################################################

[tasks]
# Note: extra CLI argument after `pixi run TASK` are passed to the task cmd.
clean = { cmd = "rm -rf build bin CMakeFiles/" }

print-env = { cmd = "echo $PATH" }

[target.win-64.tasks]
prepare = "cmake -G 'Visual Studio 17 2022' -B build -S . -DCMAKE_BUILD_TYPE=RelWithDebInfo"
build = { cmd = "cmake --build build --config RelWithDebInfo", depends_on = [
"prepare",
] }
example = { cmd = "build/RelWithDebInfo/rerun_ext_example.exe", depends_on = [
"build",
[target.unix.tasks]
# This task only runs properly Unix systems.
format = { cmd = "clang-format -i src/*" }

################################################################################
# Building against Rerun using the default of FetchContent.
#
# The rerun-cpp source will be downloaded and built as part of the build.
################################################################################
[feature.fetchcontent.tasks]

prepare-fetchcontent = "cmake -B $BUILD_FOLDER -S . -DCMAKE_BUILD_TYPE=RelWithDebInfo"

build-fetchcontent = { cmd = "cmake --build $BUILD_FOLDER --config RelWithDebInfo", depends_on = [
"prepare-fetchcontent",
] }

[target.unix.tasks]
prepare = "cmake -G 'Ninja' -B build -S . -DCMAKE_BUILD_TYPE=RelWithDebInfo"
build = { cmd = "cmake --build build --config RelWithDebInfo --target all", depends_on = [
"prepare",
example = { cmd = "$EXE_PATH", depends_on = ["build-fetchcontent"] }

clean = { cmd = "rm -rf $BUILD_FOLDER bin CMakeFiles/" }

################################################################################
# Alternatively, build by locating Rerun via find_package
#
# In this case rerun is provided by the `librerun-sdk` package in the
# conda environment.
################################################################################
[feature.findpackage.tasks]

prepare-findpackage = "cmake -B $BUILD_FOLDER -S . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DRERUN_FIND_PACKAGE:BOOL=ON"

build-findpackage = { cmd = "cmake --build $BUILD_FOLDER --config RelWithDebInfo", depends_on = [
"prepare-findpackage",
] }
example = { cmd = "build/rerun_ext_example", depends_on = ["build"] }
format = { cmd = "clang-format -i src/*" }

example-findpackage = { cmd = "$EXE_PATH", depends_on = ["build-findpackage"] }

clean = { cmd = "rm -rf $BUILD_FOLDER bin CMakeFiles/" }

################################################################################
# Dependencies
################################################################################
[dependencies]
# Build tools:
clang-tools = ">=15,<16" # clang-format
Expand All @@ -63,3 +107,11 @@ ninja = "1.11.1"
[target.win-64.dependencies]
# Build tools:
vs2022_win-64 = "19.37.32822"

[feature.findpackage.dependencies]
librerun-sdk = "0.17.0.*"

[environments]
default = { solve-group = "defaultgroup" }
fetchcontent = { features = ["fetchcontent"], solve-group = "defaultgroup" }
findpackage = { features = ["findpackage"], solve-group = "defaultgroup" }
3 changes: 3 additions & 0 deletions pixi/env.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set CMAKE_GENERATOR="Visual Studio 17 2022"
set BUILD_FOLDER=build_%PIXI_ENVIRONMENT_NAME%
set EXE_PATH=%BUILD_FOLDER%/RelWithDebInfo/rerun_ext_example
3 changes: 3 additions & 0 deletions pixi/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export CMAKE_GENERATOR=Ninja
export BUILD_FOLDER=build_${PIXI_ENVIRONMENT_NAME}
export EXE_PATH=$BUILD_FOLDER/rerun_ext_example
Loading