-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate.sh
executable file
·57 lines (47 loc) · 1.41 KB
/
generate.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# todo : verify all submodules are synced somehow
# git submodule update --init --recursive
root=$PWD
chibi_bin="./chibi-build/chibi/chibi"
# end the shell script when an error occurs
set -e
# detect operating system
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) os=linux;;
Darwin*) os=mac;;
*) os="unknown"
esac
# create "-filter <...>" command line arguments to be passed to chibi if this shell script received any arguments of its own
target_arg=""
for arg in "$@"
do
target_arg="$target_arg-target $arg "
done
if [ "$target_arg" != "" ]; then
#tput smul; # underline
tput bold; # bold
#tput setab 0; # bg = black
tput setaf 2; # fg = green
echo "using filter: $target_arg"
tput sgr0; # reset text formatting
fi
# build chibi binary
mkdir -p chibi-build/chibi
cd chibi-build/chibi && cmake -DCMAKE_BUILD_TYPE=Release ../../chibi && cmake --build . --config Release
cd "$root"
# generate cmake files using chibi
mkdir -p chibi-build/cmake-files
"$chibi_bin" -g . chibi-build/cmake-files $target_arg
if [ "$os" == "mac" ]; then
# generate Xcode project file
mkdir -p chibi-build/xcode
cd chibi-build/xcode && cmake -G "Xcode" ../cmake-files
cd "$root"
open -a Finder -R chibi-build/xcode/Project.xcodeproj
fi
if [ "$os" == "linux" ]; then
# generate Unix Makefiles
mkdir -p chibi-build/makefiles
cd chibi-build/makefiles && cmake -G "Unix Makefiles" ../cmake-files
cd "$root"
fi