-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_macos_slow.sh
126 lines (112 loc) · 3.4 KB
/
build_macos_slow.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
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
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="
-D SHARED_APPLE_PLATFORM
-ferror-limit=2
-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
############
SOURCE_FILES="
engine_src/shared/debigulator/src/inflate.c
engine_src/shared/debigulator/src/decode_png.c
engine_src/shared/debigulator/src/decode_bmp.c
engine_src/shared/decodedimage.c
engine_src/shared/wav.c
engine_src/shared/objparser.c
engine_src/shared/common.c
engine_src/shared/logger.c
engine_src/shared/collision.c
engine_src/shared/objectid.c
engine_src/shared/audio.c
engine_src/shared/window_size.c
engine_src/shared/triangle.c
engine_src/shared/lightsource.c
engine_src/shared/cpu_to_gpu_types.c
engine_src/shared_apple/apple_audio.m
engine_src/shared/common_platform_layer.c
engine_src/macos/macos_platform_layer.m
engine_src/shared_apple/apple_platform_layer.m
engine_src/shared_linux_apple/linux_apple_platform_layer.c
engine_src/shared/memorystore.c
engine_src/shared/objmodel.c
engine_src/shared/userinput.c
engine_src/shared/tok_random.c
engine_src/shared_apple/gpu.m
engine_src/shared/texture_array.c
engine_src/shared/lines.c
engine_src/shared/zpolygon.c
engine_src/shared/particle.c
engine_src/shared/scheduled_animations.c
engine_src/shared/text.c
engine_src/shared/uielement.c
sampleproject_src/clientlogic.c
engine_src/shared/terminal.c
engine_src/shared/renderer.c
engine_src/shared/gameloop.c
engine_src/shared/init_application.c
engine_src/macos/macos_main.m"
echo "Compiling & linking $APP_NAME..."
if
sudo time gcc $COMPILER_PATHS $COMPILER_ARGS $COMPILER_ARGS_EXTRA $MAC_FRAMEWORKS $SOURCE_FILES -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