-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·49 lines (40 loc) · 1.17 KB
/
build.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
#!/bin/bash
ScriptDirectory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
BuildConfig=$1
if [ -z ${BuildConfig} ]
then
echo "Missing argument, assuming release build"
BuildConfig=release
fi
InvalidBuildConfig=1
if [ "${BuildConfig}" == "release" -o "${BuildConfig}" == "debug" ]
then
InvalidBuildConfig=0
fi
if [ ${InvalidBuildConfig} == 1 ]
then
echo "Invalid build config '${BuildConfig}'. Assuming release build"
BuildConfig=release
fi
BuildFolder="${ScriptDirectory}/build_${BuildConfig}"
if [ ! -d "${BuildFolder}" ]
then
mkdir "${BuildFolder}"
fi
OutputFile="${BuildFolder}/osx_c_coca_api_generator"
InputCFile="${ScriptDirectory}/c_ocoa_generator_osx.c"
Libraries="-lobjc"
Frameworks="-framework Foundation -framework Cocoa -framework AppKit"
CompilerOptions="-ferror-limit=900 -fstrict-aliasing --output ${OutputFile} ${Libraries} ${Frameworks}"
if [ "${BuildConfig}" == "release" ]
then
echo "Build config = release"
CompilerOptions="${CompilerOptions} -O3"
fi
if [ "${BuildConfig}" == "debug" ]
then
echo "Build config = debug"
CompilerOptions="${CompilerOptions} --debug"
fi
BuildCommand="clang ${InputCFile} ${CompilerOptions}"
${BuildCommand}