-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathrun.command
More file actions
executable file
·216 lines (168 loc) · 6.41 KB
/
Copy pathrun.command
File metadata and controls
executable file
·216 lines (168 loc) · 6.41 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#!/bin/bash
#example usages:
# build static lib, compile app, run app
# ./run.command examples/texture/TextureExample.mm
# run app only
# ./run.command -r examples/font/Text3D.mm
# skip building the static lib, compile app but don't run it
# ./run.command -sc examples/model/Model.mm
# force re-precompiling headers, build static lib, compile and run app
# ./run.command -p examples/stereo/Stereo.mm
# clean by removing aluminum.a, the precompiled headers, and the application binary (this last one is optional)
# ./run.command -z
# ./run.command -z examples/stereo/MyApp.mm
#INCLUDE_DIR="/opt/local/include/"
INCLUDE_DIR="/usr/include" #where your headers live, for instance the GLM headers
LIB_DIR="/usr/lib" #where your static libs live, for instance libfreeiamge.a
LINUX_VERSION="$(uname -r)";
echo -e "\n\nYou are running LINUX version $LINUX_VERSION\n\n"
#default builder flags, can be changed with -c, -r, -b, -s, -p. Use -? for help.
BUILD=1
COMPILE=1
RUN=1
PRE=0
CLEAN=0
INSTALL=0
while getopts "hcirbspz?" opt; do
case $opt in
c) echo "...compile only"
COMPILE=1
RUN=0
;;
r) echo "...run only"
PRE=0
BUILD=0
COMPILE=0
RUN=1
;;
b) echo "...build static lib"
BUILD=1
;;
i) echo "...install static lib"
COMPILE=0
RUN=0
CLEAN=0
PRE=1
BUILD=1
INSTALL=1
;;
s) echo "...skip building static lib"
BUILD=0
;;
p) echo "...precompile headers"
PRE=1
;;
z) echo "...clean"
CLEAN=1
;;
h) echo -e "\n\taluminum run.command help file"
echo -e "\n\tvalid flags are:"
echo -e "\t -c : compile only"
echo -e "\t -r : run only"
echo -e "\t -s : skip building static lib"
echo -e "\t -b : force building static lib"
echo -e "\t -i : install static lib (must be run as root)"
echo -e "\t -p : force precompiling headers"
echo -e "\t -z : clean"
echo -e "\n\tdefault flags are: -bcr\n"
exit ;;
\?) echo -e "\n\taluminum run.command help file"
echo -e "\n\tvalid flags are:"
echo -e "\t -c : compile only"
echo -e "\t -r : run only"
echo -e "\t -s : skip building static lib"
echo -e "\t -b : force building static lib"
echo -e "\t -i : install static lib (must be run as root)"
echo -e "\t -p : force precompiling headers"
echo -e "\t -z : clean"
echo -e "\n\tdefault flags are: -bcr\n"
exit ;;
esac
done
shift $(( OPTIND - 1 )) # shift past the last flag or argument
echo "PRECOMPILE=$PRE BUILD=$BUILD COMPILE=$COMPILE RUN=$RUN"
RUN_PATH=$( dirname "$0" )
APP_PATH=$( dirname "$1" )
APP_SRC=$( basename "$1" )
APP="${APP_SRC%.*}"
echo "RUN_PATH = $RUN_PATH"
echo "APP_PATH = $APP_PATH"
echo "APP_SRC = $APP_SRC"
echo "APP = $APP"
#CURRENT_DIR="$( cd "$( dirname "$0" )" && pwd )"
#CURRENT_DIR=$RUN_DIR
#cd $CURRENT_DIR
#echo "p w d = "
#pwd
BASE_DIR="$RUN_PATH/.."
BUILD_DIR="$BASE_DIR/build"
SRC_DIR="$BASE_DIR/src"
LINUX_DIR="$RUN_PATH"
#FFMPEG="-L/opt/local/lib -lavformat -lavcodec -lswscale -lavutil"
#ASSIMP="$LIB_DIR/libassimp.dylib"
#FREEIMAGE="$LIB_DIR/libfreeimage.dylib"
#COCOA="-isysroot /Applications/XCode.app/Contents/Developer/Platforms/MacLINUX.platform/Developer/SDKs/MacLINUX$LINUX_VERSION.sdk -mmacosx-version-min=$LINUX_VERSION -framework Cocoa -framework QuartzCore -framework OpenGL -framework AppKit -framework Foundation -framework AVFoundation -framework CoreMedia "
LINUX_LIBS=" -lglut -lGL -lm -lfreeimage -lSDL -lSDL_image"
OPTIONS="-O3 -Wreturn-type -Wformat -Wmissing-braces -Wparentheses -Wswitch -Wunused-variable -Wsign-compare -Wno-unknown-pragmas -Woverloaded-virtual"
#INCLUDE_FFMPEG="-I$INCLUDE_DIR/libswscale -I$INCLUDE_DIR/libavcodec -I$INCLUDE_DIR/libavformat"
#INCLUDE="-I./ -I$LINUX_DIR -I$SRC_DIR -I$INCLUDE_DIR $INCLUDE_FFMPEG -I./$APP_PATH"
#INCLUDE="-I./ -I$LINUX_DIR -I$SRC_DIR -I$INCLUDE_DIR -I$INCLUDE_GLM_DIR -I./$APP_PATH"
#INCLUDE="-I./ -I$LINUX_DIR -I$SRC_DIR -I$INCLUDE_DIR -I./$APP_PATH"
INCLUDE="-I./ -I$BUILD_DIR/include -I$INCLUDE_DIR -I./$APP_PATH"
LIBS="" #$ASSIMP $FREEIMAGE" #$FFMPEG"
#SRC=" -x objective-c++ $SRC_DIR/*.cpp $LINUX_DIR/*.mm $APP_SRC"
SRC=" $SRC_DIR/*.cpp $LINUX_DIR/*.cpp $APP_SRC"
if [ "$CLEAN" -eq 1 ]; then
### 1. REMOVE static lib, precomiled headers, includes
echo -e "removing aluminum.a, Include.hpp.gch, $APP...\n\n"
echo "rm $BASE_DIR/build/lib/aluminum.a"
rm $BASE_DIR/build/lib/aluminum.a
echo "rm $BASE_DIR/build/include/Aluminum/*.hpp"
rm $BASE_DIR/build/include/Aluminum/*.hpp
echo "rm $BASE_DIR/build/include/Aluminum/*.h"
rm $BASE_DIR/build/include/Aluminum/*.h
echo "rm $BASE_DIR/build/include/Includes.hpp.gch"
rm $BASE_DIR/build/include/Includes.hpp.gch
if [[ -n "$APP" ]]; then
echo "rm $APP_PATH/$APP"
rm $APP_PATH/$APP
fi
exit
fi
if [ ! -f $BUILD_DIR/include/Aluminum/Includes.hpp.gch ]; then
PRE=1
BUILD=1
COMPILE=1
fi
if [ "$PRE" -eq 1 ]; then
### 1. PRECOMPILE headers (should only need to if Include.hpp has changed)
echo -e "precomiling headers from Include.hpp into Include.hpp.gch...\n\n"
$LINUX_DIR/scripts/precompileHeaders.sh $INCLUDE_DIR
fi
if [ "$BUILD" -eq 1 ]; then
### 1. BUILD aluminum static lib (should only need to if changed aluminum files)
# assumes we've already pre-compiled Include.hpp
echo -e "\n\n\nBuilding static library using precompiled header Includes.hpp.gch...\n\n"
echo "LINUX_DIR = $LINUX_DIR"
$LINUX_DIR/scripts/makeStaticLibrary.sh $INCLUDE_DIR
fi
if [ "$INSTALL" -eq 1 ]; then
echo -e "installing static libs and headers...\n\n"
$LINUX_DIR/scripts/installAluminumLinux.sh $BASE_DIR
exit;
fi
if [ "$COMPILE" -eq 1 ]; then
###2a. remove existing binary if it exists - if the next compile fails then the user might not realize it if the old version starts to run...
if [[ -n "$APP" ]]; then
echo "rm $APP_PATH/$APP"
rm $APP_PATH/$APP
fi
### 2. COMPILE w/aluminum lib
echo -e "\n\n\nCOMPILING user code with aluminum static lib... \n\nc++ $LINUX_LIBS -std=c++11 $LIBS $INCLUDE $APP_PATH/*.cpp -o $APP_PATH/$APP $BASE_DIR/build/lib/libaluminum.a"
#time c++ $COCOA $OPTIONS -std=c++11 -stdlib=libc++ $BASE_DIR/build/lib/aluminum.a $LIBS $INCLUDE $APP_PATH/*.mm -o $APP_PATH/$APP
time c++ $LINUX_LIBS -std=c++11 $LIBS $INCLUDE $APP_PATH/*.cpp -o $APP_PATH/$APP $BASE_DIR/build/lib/libaluminum.a
fi
if [ "$RUN" -eq 1 ]; then
### 3. RUN the app
cd $APP_PATH && ./$APP
fi