-
Notifications
You must be signed in to change notification settings - Fork 1
/
archive.sh
executable file
·56 lines (46 loc) · 1.6 KB
/
archive.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
# 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
if [ -z "$1" ]
then
echo "missing target name"
exit 1
fi
target_arg="-target $1"
#tput smul; # underline
tput bold; # bold
#tput setab 0; # bg = black
tput setaf 2; # fg = green
echo "target: $1"
tput sgr0; # reset text formatting
# 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-for-archive
"$chibi_bin" -g . chibi-build/cmake-files-for-archive $target_arg
# build all of the libraries and example and test app binaries. this will take a while
mkdir -p chibi-build/archive
cd chibi-build/archive && cmake -DCMAKE_BUILD_TYPE=Distribution ../cmake-files-for-archive && cmake --build . --config Distribution -- -j6
cd "$root"
# create a zip file from the app bundle for ease of destribution and archival purposes
if [ "$os" == "mac" ] && [ -e "chibi-build/archive/$1.app" ]; then
cwd=$PWD
cd "chibi-build/archive"
DATETIME=`date +%Y-%m-%d_%H-%M-%S`
zip -r "$1-$DATETIME-osx.zip" "$1.app"
cd $cwd
open -a Finder -R "chibi-build/archive/$1-$DATETIME-osx.zip"
fi