Files
tmux/scripts/makescript.sh
2025-10-28 20:14:32 +01:00

72 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/zsh
# configure make tools
WAF=$(where waf)
CARGO=$(where cargo)
CMAKE=$(where cmake)
MAKE=$(where make)
WAITMSG="Press any key to continue..."
function find-up() {
curpath=$(pwd)
while [[ "$curpath" != "" && ! -e "$curpath/$1" ]]; do
curpath=${curpath%/*}
done
echo $curpath
}
function wait-for-keypress() {
echo $WAITMSG
read -k
}
# look for the make file for waf
MAKEPATH=$(find-up "wscript")
if [[ "$MAKEPATH" != "" ]]
then
echo "Found 'wscript' file. Building WAF project."
cd $MAKEPATH
$WAF configure build
wait-for-keypress
return 0
fi
# look for a cargo file for rust.
MAKEPATH=$(find-up "Cargo.toml")
if [[ "$MAKEPATH" != "" ]]
then
echo "Found 'Cargo.toml' file. Building rust project."
cd $MAKEPATH
$CARGO build
wait-for-keypress
return 0
fi
# look for a make file for CMAKE
MAKEPATH=$(find-up "CMakeList.txt")
if [[ "$MAKEPATH" != "" ]]
then
echo "Found 'CMakeList.txt' file. Building CMAKE project."
cd $MAKEPATH
$CMAKE -DCMAKE_BUILD_TYPE=Debug -S . -B ./build
$CMAKE --build ./build
wait-for-keypress
return 0
fi
# look for a classical make file
MAKEPATH=$(find-up "Makefile")
if [[ "$MAKEPATH" != "" ]]
then
cd $MAKEPATH
./configure
$MAKE
wait-for-keypress
return 0
fi
echo "No matching makefiles found"
wait-for-keypress
return 1