-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_macos.sh
77 lines (66 loc) · 2.1 KB
/
build_macos.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
APP_NAME="hello3dgfx"
COMPILER_PATHS="
-I engine_src/macos/
-I engine_src/shared/debigulator/src/
-I engine_src/shared/
-I engine_src/shared_apple/
-I engine_src/shared_linux_apple/
-I engine_src/shared_windows_macos/
-I sampleproject_src/
"
COMPILER_ARGS="-march=native -Wall -x objective-c -std=c99 -O0 -objC"
if [[ $1 = "DEBUG" ]]; then
COMPILER_ARGS_EXTRA="-g"
else
if [[ $1 = "RELEASE" ]]; then
COMPILER_ARGS_EXTRA=""
fi
fi
MAC_FRAMEWORKS="
-framework AppKit
-framework MetalKit
-framework Metal
-framework AudioToolbox"
echo "create build folder..>"
sudo mkdir -p build/macos/$APP_NAME.app
echo "deleting previous build..."
sudo rm -r -f build/macos/$APP_NAME.app/*.txt
sudo rm -r -f build/macos/$APP_NAME.app/$APP_NAME sudo rm -r -f build/macos/$APP_NAME.app/$APP_NAME.dsym
############
if test -f "build/macos/$APP_NAME.app/shaders.metallib"; then
echo "shaders.metallib already in build folder, skip metal compilation...."
else
echo "shaders.metallib not in build folder, compiling new metal library..."
sudo xcrun -sdk macosx metal -gline-tables-only -MO -g -c "engine_src/shared_apple/Shaders.metal" -o resources/Shaders.air
sudo xcrun -sdk macosx metal -c "engine_src/shared_apple/shaders.metal" -o Shaders.air
sudo xcrun -sdk macosx metallib resources/Shaders.air -o build/macos/$APP_NAME.app/Shaders.metallib
fi
############
############
echo "copy resources..."
pushd resources > /dev/null
for extension in png obj dat
do
for f in *.$extension;
do
if test -f "../build/macos/$APP_NAME.app/$f"; then
echo "$f was already in build folder...."
else
echo "copying resource file $f to build folder..."
sudo cp -r -f $f ../build/macos/$APP_NAME.app/$f
fi
done
done
popd > /dev/null
############
echo "Compiling & linking $APP_NAME..."
if
sudo time gcc $COMPILER_PATHS $COMPILER_ARGS $COMPILER_ARGS_EXTRA $MAC_FRAMEWORKS unitybuild_macos.c -o build/macos/$APP_NAME.app/$APP_NAME
then
echo "compilation succesful."
read -p "enter to run app, ctrl-c to quit"
open build/macos/$APP_NAME.app
else
echo "compilation failed"
exit 0
fi