Created
July 12, 2025 21:15
-
-
Save MicrogamerCz/273c93dad47801ed76950298eb36f62a to your computer and use it in GitHub Desktop.
Simple automated build function for CMake projects (with -GNinja)
This file contains hidden or 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
| function koi | |
| if [ -z "$argv[1]" -o "$argv[1]" = "build" ] | |
| # Checks for CMakeLists.txt and navigates accordingly | |
| if contains CMakeLists.txt $(ls) | |
| if not test -e build/ | |
| mkdir build/ | |
| end | |
| build/ | |
| end | |
| # Runs cmake only when build files don't exist | |
| if not contains build.ninja $(ls) | |
| cmake .. -GNinja | |
| if test $status -gt 0 | |
| echo "Failed CMake project setup" | |
| .. | |
| return | |
| end | |
| end | |
| ninja | |
| if test $status -gt 0 | |
| echo "Failed Ninja build" | |
| .. | |
| return | |
| end | |
| # Executes the first binary found in build root directory or bin/ subdirectory (typical for KDE apps) | |
| set bin "" | |
| for b in $(ls); | |
| if test -x $b | |
| set bin $b | |
| break | |
| end | |
| end | |
| if contains bin $(ls); and test -d bin/ | |
| bin/ | |
| for b in $(ls); | |
| if test -x $b | |
| set bin "./bin/$b" | |
| break | |
| end | |
| end | |
| .. | |
| end | |
| if [ -n "$HYPRLAND_INSTANCE_SIGNATURE" ] | |
| # hyprctl dispatch movetoworkspace $(math $(hyprctl workspaces -j | jq '.[-1]["id"]') + 1) | |
| # hyprctl dispatch workspace +1 | |
| hyprctl dispatch workspace $(math $(hyprctl workspaces -j | jq '[.[] | select(.id > 0) | .id ] | last') + 1) | |
| end | |
| $bin | |
| .. | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment