-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·190 lines (171 loc) · 4.6 KB
/
build.sh
File metadata and controls
executable file
·190 lines (171 loc) · 4.6 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
#!/bin/bash
# Function to display menu
show_menu() {
echo "===================="
echo "DXcore Build Script"
echo "===================="
echo "1) Build Android library"
echo "2) Build iOS framework"
echo "3) Build Windows DLL"
echo "4) Build both Android and iOS"
echo "5) Exit"
echo "===================="
}
# Function to build Android library
build_android() {
echo "Cleaning Android build directory..."
rm -rf build/android
mkdir -p build/android
echo "Building Android library..."
gomobile bind -v \
-target=android \
-androidapi 23 \
-ldflags "-checklinkname=0" \
-o build/android/DXcore.aar \
./DXcore/Android
if [ $? -eq 0 ]; then
echo "✅ Android library built successfully at: build/android/DXcore.aar"
return 0
else
echo "❌ Failed to build Android library"
return 1
fi
}
# Function to build iOS framework
build_ios() {
echo "Cleaning iOS build directory..."
rm -rf build/ios
mkdir -p build/ios
echo "Building iOS framework..."
gomobile bind -v \
-target=ios \
-ldflags "-checklinkname=0" \
-o build/ios/IosDXcore.xcframework \
./DXcore/Ios
if [ $? -eq 0 ]; then
echo "✅ iOS framework built successfully at: build/ios/IosDXcore.xcframework"
return 0
else
echo "❌ Failed to build iOS framework"
return 1
fi
}
# Function to build Windows DLL
build_windows() {
echo "Cleaning Windows build directory..."
rm -rf build/windows
mkdir -p build/windows
echo "Building Windows DLL..."
go build -v \
-o build/windows/DXcore.dll \
-buildmode=c-shared \
./DXcore/windows
if [ $? -eq 0 ]; then
echo "✅ Windows DLL built successfully at: build/windows/DXcore.dll"
return 0
else
echo "❌ Failed to build Windows DLL"
return 1
fi
}
# Initialize mobile bind
init_mobile_bind() {
echo "Initializing mobile bind..."
go get golang.org/x/mobile/bind
}
# Main script
if [ "$GITHUB_ACTIONS" = "true" ]; then
# Auto mode for CI/CD: build both Android and iOS, then exit
echo "CI detected: running Android and iOS builds, then exiting."
init_mobile_bind
echo "Starting Android build..."
build_android
android_result=$?
echo ""
echo "Starting iOS build..."
build_ios
ios_result=$?
echo ""
echo "===================="
echo "Build Summary:"
if [ $android_result -eq 0 ]; then
echo "✅ Android: SUCCESS"
else
echo "❌ Android: FAILED"
fi
if [ $ios_result -eq 0 ]; then
echo "✅ iOS: SUCCESS"
else
echo "❌ iOS: FAILED"
fi
echo "===================="
if [ $android_result -ne 0 ] || [ $ios_result -ne 0 ]; then
exit 1
fi
exit 0
fi
while true; do
show_menu
read -p "Please select an option (1-5): " choice
case $choice in
1)
echo "Selected: Build Android library"
init_mobile_bind
build_android
if [ $? -ne 0 ]; then
exit 1
fi
echo ""
;;
2)
echo "Selected: Build iOS framework"
init_mobile_bind
build_ios
if [ $? -ne 0 ]; then
exit 1
fi
echo ""
;;
3)
echo "Selected: Build Windows DLL"
build_windows
if [ $? -ne 0 ]; then
exit 1
fi
echo ""
;;
4)
echo "Selected: Build both Android and iOS"
init_mobile_bind
echo "Starting Android build..."
build_android
android_result=$?
echo ""
echo "Starting iOS build..."
build_ios
ios_result=$?
echo ""
echo "===================="
echo "Build Summary:"
if [ $android_result -eq 0 ]; then
echo "✅ Android: SUCCESS"
else
echo "❌ Android: FAILED"
fi
if [ $ios_result -eq 0 ]; then
echo "✅ iOS: SUCCESS"
else
echo "❌ iOS: FAILED"
fi
echo "===================="
if [ $android_result -ne 0 ] || [ $ios_result -ne 0 ]; then
exit 1
fi
echo ""
;;
*)
echo "Exiting..."
exit 0
;;
esac
done