Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 390889d

Browse files
committedAug 2, 2024·
Simplify pixi through environments
1 parent aee3b0d commit 390889d

File tree

6 files changed

+1204
-40
lines changed

6 files changed

+1204
-40
lines changed
 

Diff for: ‎.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Build directories
2-
build
3-
buildrerunfindpackage
2+
build_*
43

54
# Pixi environment
65
.pixi

Diff for: ‎README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ The easiest way to get started is to install [pixi](https://prefix.dev/docs/pixi
1717

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

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

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

Diff for: ‎pixi.lock

+1,141-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: ‎pixi.toml

+54-35
Original file line numberDiff line numberDiff line change
@@ -21,49 +21,69 @@
2121
repository = "https://github.com/rerun-io/cpp-example-opencv-eigen"
2222
version = "0.1.0"
2323

24+
# The following activation scripts make the tasks portable cross-platform.
25+
#
26+
# They define:
27+
# - CMAKE_GENERATOR
28+
# - BUILD_FOLDER
29+
# - EXE_PATH
30+
#
31+
# In particular, BUILD_FOLDER will be set to either:
32+
# - build_source
33+
# - build_findpackage
34+
# depending on the feature being used.
35+
[activation]
36+
scripts = ["pixi/env.sh"]
37+
38+
[target.win-64.activation]
39+
scripts = ["pixi/env.bat"]
40+
41+
################################################################################
42+
# Common Tasks
43+
################################################################################
2444

2545
[tasks]
26-
# Note: extra CLI argument after `pixi run TASK` are passed to the task cmd.
27-
clean = { cmd = "rm -rf build bin CMakeFiles/" }
28-
print-env = { cmd = "echo $PATH" }
2946

30-
[target.win-64.tasks]
31-
prepare = "cmake -G 'Visual Studio 17 2022' -B build -S . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DRERUN_FIND_PACKAGE:BOOL=OFF"
32-
build = { cmd = "cmake --build build --config RelWithDebInfo", depends_on = [
33-
"prepare",
34-
] }
35-
example = { cmd = "build/RelWithDebInfo/rerun_ext_example.exe", depends_on = [
36-
"build",
37-
] }
47+
print-env = { cmd = "echo $PATH" }
3848

3949
[target.unix.tasks]
40-
prepare = "cmake -G 'Ninja' -B build -S . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DRERUN_FIND_PACKAGE:BOOL=OFF"
41-
build = { cmd = "cmake --build build --config RelWithDebInfo --target all", depends_on = [
42-
"prepare",
43-
] }
44-
example = { cmd = "build/rerun_ext_example", depends_on = ["build"] }
50+
# This task only runs propertly Unix systems.
4551
format = { cmd = "clang-format -i src/*" }
4652

47-
[feature.rerunfindpackage.target.win-64.tasks]
48-
prepare = "cmake -G 'Visual Studio 17 2022' -B buildrerunfindpackage -S . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DRERUN_FIND_PACKAGE:BOOL=ON"
49-
build = { cmd = "cmake --build buildrerunfindpackage --config RelWithDebInfo", depends_on = [
50-
"prepare",
51-
] }
52-
example = { cmd = "buildrerunfindpackage/RelWithDebInfo/rerun_ext_example.exe", depends_on = [
53-
"build",
54-
] }
53+
################################################################################
54+
# Building Rerun from source via the released bundle.
55+
################################################################################
56+
[feature.source.tasks]
57+
58+
# The default behavior will cause rerun to be build from source
59+
prepare-source = "cmake -B $BUILD_FOLDER -S . -DCMAKE_BUILD_TYPE=RelWithDebInfo"
5560

56-
[feature.rerunfindpackage.target.unix.tasks]
57-
prepare = "cmake -G 'Ninja' -B buildrerunfindpackage -S . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DRERUN_FIND_PACKAGE:BOOL=ON"
58-
build = { cmd = "cmake --build buildrerunfindpackage --config RelWithDebInfo --target all", depends_on = [
59-
"prepare",
61+
build-source = { cmd = "cmake --build $BUILD_FOLDER --config RelWithDebInfo", depends_on = [
62+
"prepare-source",
6063
] }
61-
example = { cmd = "buildrerunfindpackage/rerun_ext_example", depends_on = [
62-
"build",
64+
65+
example = { cmd = "$EXE_PATH", depends_on = ["build-source"] }
66+
67+
clean = { cmd = "rm -rf $BUILD_FOLDER bin CMakeFiles/" }
68+
69+
################################################################################
70+
# Using Rerun via find_package
71+
################################################################################
72+
[feature.findpackage.tasks]
73+
74+
prepare-findpackage = "cmake -B $BUILD_FOLDER -S . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DRERUN_FIND_PACKAGE:BOOL=ON"
75+
76+
build-findpackage = { cmd = "cmake --build $BUILD_FOLDER --config RelWithDebInfo", depends_on = [
77+
"prepare-findpackage",
6378
] }
64-
format = { cmd = "clang-format -i src/*" }
6579

80+
example-findpackage = { cmd = "$EXE_PATH", depends_on = ["build-findpackage"] }
81+
82+
clean = { cmd = "rm -rf $BUILD_FOLDER bin CMakeFiles/" }
6683

84+
################################################################################
85+
# Depencencies
86+
################################################################################
6787
[dependencies]
6888
# Build tools:
6989
clang-tools = ">=15,<16" # clang-format
@@ -84,11 +104,10 @@
84104
# Build tools:
85105
vs2022_win-64 = "19.37.32822"
86106

87-
[feature.rerunfindpackage.dependencies]
107+
[feature.findpackage.dependencies]
88108
librerun-sdk = "0.17.0.*"
89109

90110
[environments]
91111
default = { solve-group = "defaultgroup" }
92-
rerunfindpackage = { features = [
93-
"rerunfindpackage",
94-
], solve-group = "defaultgroup" }
112+
source = { features = ["source"], solve-group = "defaultgroup" }
113+
findpackage = { features = ["findpackage"], solve-group = "defaultgroup" }

Diff for: ‎pixi/env.bat

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
set CMAKE_GENERATOR="Visual Studio 17 2022"
2+
set BUILD_FOLDER=build_${PIXI_ENVIRONMENT_NAME}
3+
set EXE_PATH=$BUILD_FOLDER/RelWithDebInfo/rerun_ext_example

Diff for: ‎pixi/env.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export CMAKE_GENERATOR=Ninja
2+
export BUILD_FOLDER=build_${PIXI_ENVIRONMENT_NAME}
3+
export EXE_PATH=$BUILD_FOLDER/rerun_ext_example

0 commit comments

Comments
 (0)
Please sign in to comment.