Last active
October 31, 2022 15:06
-
-
Save boki1/abb0e7a6ab78b15dcaa95d41821ad721 to your computer and use it in GitHub Desktop.
Automated Build sCript: See (https://github.com/boki1/equilibrium.git)[https://github.com/boki1/equilibrium.git] for example usage.
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
#!/bin/sh | |
project_name="project_name" | |
out_dir=build/out | |
usage() { | |
echo "Bad usage: ./build/abc.sh [build|test|clean|format]" | |
} | |
make_build() { | |
mkdir -p $out_dir | |
[ -f conanfile.txt ] && conan install . -if $out_dir --build=missing | |
cmake -S . -B $out_dir -G Ninja | |
ninja -j $(nproc) -C $out_dir | |
} | |
make_test() { | |
ctest --test-dir $out_dir | |
} | |
make_clean() { | |
rm -rf $out_dir | |
} | |
make_format() { | |
./build/apply-format > /dev/null 2>&1 | |
} | |
main() { | |
for arg in "$@" | |
do | |
case $arg in | |
"build") make_build;; | |
"test") make_test;; | |
"clean") make_clean;; | |
"format") make_format;; | |
*) usage && exit;; | |
esac | |
done | |
} | |
if [ $# -eq 0 ]; then | |
usage | |
else | |
main $@ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment