-
Notifications
You must be signed in to change notification settings - Fork 7
/
compile
executable file
·61 lines (48 loc) · 1.62 KB
/
compile
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
#!/bin/sh
MARE_BUILD_DIR="build/Debug/mare"
MARE_OUTPUT_DIR="build/Debug/mare"
MARE_SOURCE_DIR="src"
MARE_SOURCE_FILES="mare/Generator.cpp mare/CMake.cpp mare/CodeBlocks.cpp mare/CodeLite.cpp mare/JsonDb.cpp mare/Main.cpp mare/Make.cpp mare/Mare.cpp mare/NetBeans.cpp mare/Vcproj.cpp mare/Vcxproj.cpp mare/Tools/md5.cpp libmare/Engine.cpp libmare/Namespace.cpp libmare/Parser.cpp libmare/Statement.cpp libmare/Tools/Directory.cpp libmare/Tools/Error.cpp libmare/Tools/File.cpp libmare/Tools/Process.cpp libmare/Tools/Scope.cpp libmare/Tools/String.cpp libmare/Tools/Word.cpp"
[ -z "$CXX" ] && CXX=g++
getArgs()
{
while [ ! -z "$1" ]; do
case $1 in
--buildDir=*)
MARE_BUILD_DIR="${1#--buildDir=}"
;;
--outputDir=*)
MARE_OUTPUT_DIR="${1#--outputDir=}"
;;
--sourceDir=*)
MARE_SOURCE_DIR="${1#--sourceDir=}"
;;
*)
echo "Usage: $0 [--buildDir=<dir>] [--outputDir=<dir>] [--sourceDir=<dir>]"
exit 1
;;
esac
shift
done
}
build()
{
if [ ! -f "$MARE_SOURCE_DIR/mare/Main.cpp" ]; then
echo "error: Could not find source files."
exit 1
fi
mkdir -p "$MARE_BUILD_DIR"
mkdir -p "$MARE_OUTPUT_DIR"
rm -f "$MARE_OUTPUT_DIR/mare"
MARE_OBJECTS=
for file in $MARE_SOURCE_FILES; do
OBJECT="$MARE_BUILD_DIR/$(basename ${file%.cpp}).o"
MARE_OBJECTS="$MARE_OBJECTS $OBJECT"
echo "$MARE_SOURCE_DIR/$file"
$CXX -Wall -g -I"$MARE_SOURCE_DIR/libmare" -o "$OBJECT" -c "$MARE_SOURCE_DIR/$file"
done
echo "-> $MARE_OUTPUT_DIR/mare"
$CXX -o "$MARE_OUTPUT_DIR/mare" $MARE_OBJECTS
}
getArgs $@ || exit 1
build || exit 1