Skip to content

Commit

Permalink
Simplify pixi through environments
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs committed Aug 2, 2024
1 parent aee3b0d commit c6e9292
Show file tree
Hide file tree
Showing 7 changed files with 1,210 additions and 42 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ jobs:

- name: run build task on all environments
run: |
pixi run -e default build
pixi run -e rerunfindpackage build
pixi run build-fetchcontent
pixi run build-findpackage
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Build directories
build
buildrerunfindpackage
build_*

# Pixi environment
.pixi
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ The easiest way to get started is to install [pixi](https://prefix.dev/docs/pixi

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, while the rerun C++ SDK is downloaded via `FetchContent`
* `pixi run -e default example`
* `pixi run example`

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

Check warning on line 23 in README.md

View workflow job for this annotation

GitHub Actions / Spellcheck

Unknown word (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,142 changes: 1,141 additions & 1 deletion pixi.lock

Large diffs are not rendered by default.

93 changes: 58 additions & 35 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,49 +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 -DRERUN_FIND_PACKAGE:BOOL=OFF"
build = { cmd = "cmake --build build --config RelWithDebInfo", depends_on = [
"prepare",
] }
example = { cmd = "build/RelWithDebInfo/rerun_ext_example.exe", depends_on = [
"build",
] }
print-env = { cmd = "echo $PATH" }

[target.unix.tasks]
prepare = "cmake -G 'Ninja' -B build -S . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DRERUN_FIND_PACKAGE:BOOL=OFF"
build = { cmd = "cmake --build build --config RelWithDebInfo --target all", depends_on = [
"prepare",
] }
example = { cmd = "build/rerun_ext_example", depends_on = ["build"] }
# This task only runs propertly Unix systems.

Check warning on line 50 in pixi.toml

View workflow job for this annotation

GitHub Actions / typos

"propertly" should be "property" or "properly".
format = { cmd = "clang-format -i src/*" }

[feature.rerunfindpackage.target.win-64.tasks]
prepare = "cmake -G 'Visual Studio 17 2022' -B buildrerunfindpackage -S . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DRERUN_FIND_PACKAGE:BOOL=ON"
build = { cmd = "cmake --build buildrerunfindpackage --config RelWithDebInfo", depends_on = [
"prepare",
] }
example = { cmd = "buildrerunfindpackage/RelWithDebInfo/rerun_ext_example.exe", depends_on = [
"build",
] }
################################################################################
# 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"

[feature.rerunfindpackage.target.unix.tasks]
prepare = "cmake -G 'Ninja' -B buildrerunfindpackage -S . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DRERUN_FIND_PACKAGE:BOOL=ON"
build = { cmd = "cmake --build buildrerunfindpackage --config RelWithDebInfo --target all", depends_on = [
"prepare",
build-fetchcontent = { cmd = "cmake --build $BUILD_FOLDER --config RelWithDebInfo", depends_on = [
"prepare-fetchcontent",
] }
example = { cmd = "buildrerunfindpackage/rerun_ext_example", depends_on = [
"build",

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

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

################################################################################
# Alternatively, build by rinding 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",
] }
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 @@ -84,11 +108,10 @@ ninja = "1.11.1"
# Build tools:
vs2022_win-64 = "19.37.32822"

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

[environments]
default = { solve-group = "defaultgroup" }
rerunfindpackage = { features = [
"rerunfindpackage",
], 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

0 comments on commit c6e9292

Please sign in to comment.