-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-them.sh
executable file
·179 lines (148 loc) · 5.19 KB
/
build-them.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
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
#!/bin/bash
# Define the project names and paths
desktop_project="OpenIPC_Config.Desktop"
android_project="OpenIPC_Config.Android"
ios_project="OpenIPC_Config.iOS"
# Build output directory
output_dir="build"
# Default verbosity level
verbosity="normal"
# Function to clean previous builds
clean_builds() {
echo "Cleaning previous builds in output directory..."
rm -rf "$output_dir"
echo "Running dotnet clean for each project..."
dotnet clean $desktop_project
dotnet clean $android_project
dotnet clean $ios_project
mkdir -p "$output_dir"
}
# Function to create macOS .app bundle
create_macos_app_bundle() {
app_name="OpenIPC_Config"
app_bundle="$output_dir/$desktop_project/osx-arm64/$app_name.app"
echo "Creating .app bundle structure for $app_name..."
mkdir -p "$app_bundle/Contents/MacOS"
mkdir -p "$app_bundle/Contents/Resources"
# Copy the icon file
echo "Copying icon file..."
cp "OpenIPC/OpenIPC_Config/Assets/Icons/OpenIPC.icns" "$app_bundle/Contents/Resources/$app_name.icns"
# Move the executable file
echo "Moving executable to .app bundle..."
cp -r $output_dir/$desktop_project/osx-arm64/* "$app_bundle/Contents/MacOS/"
echo "App bundl created at $app_bundle"
chmod +x "$app_bundle"
# Create Info.plist file
echo "Creating Info.plist..."
cat > "$app_bundle/Contents/Info.plist" <<EOL
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>$app_name</string>
<key>CFBundleExecutable</key>
<string>OpenIPC_Config.Desktop</string>
<key>CFBundleIdentifier</key>
<string>com.openipc.$app_name</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>LSMinimumSystemVersion</key>
<string>10.12</string>
<key>CFBundleIconFile</key>
<string>$app_name.icns</string>
</dict>
</plist>
EOL
echo "$app_name.app bundle created successfully at $app_bundle"
}
# Function to build for macOS with verbose output
build_macos() {
echo "Building $desktop_project for macOS (osx-arm64) as .app bundle..."
dotnet publish $desktop_project -c Release -r osx-arm64 --output "$output_dir/$desktop_project/osx-arm64" --self-contained -v $verbosity
if [ -f "$output_dir/$desktop_project/osx-arm64/OpenIPC_Config.Desktop.dll" ]; then
create_macos_app_bundle
else
echo "Error: macOS build failed or executable file not found."
fi
}
# Function to build for Windows
build_windows() {
echo "Building $desktop_project for win-arm64..."
dotnet publish $desktop_project -c Release -r win-arm64 --output "$output_dir/$desktop_project/win-arm64" --self-contained -v $verbosity
echo "Building $desktop_project for win-x64..."
dotnet publish $desktop_project -c Release -r win-x64 --output "$output_dir/$desktop_project/win-x64" --self-contained -v $verbosity
}
# Function to build for Linux
build_linux() {
echo "Building $desktop_project for linux-arm64..."
dotnet publish $desktop_project -c Release -r linux-arm64 --output "$output_dir/$desktop_project/linux-arm64" --self-contained -v $verbosity
echo "Building $desktop_project for linux-x64..."
dotnet publish $desktop_project -c Release -r linux-x64 --output "$output_dir/$desktop_project/linux-x64" --self-contained -v $verbosity
}
# Function to build for Android
build_android() {
echo "Building $android_project as APK..."
dotnet publish $android_project -c Release -r android-arm64 --output "$output_dir/$android_project" -v $verbosity
}
# Function to build for iOS
build_ios() {
echo "Building $ios_project as an IPA for iOS..."
dotnet publish $ios_project -c Release -r ios-arm64 --output "$output_dir/$ios_project" -v $verbosity
}
# Parse arguments
build_all=false
while [[ $# -gt 0 ]]; do
case $1 in
all)
build_all=true
;;
macos)
build_macos=true
;;
windows)
build_windows=true
;;
linux)
build_linux=true
;;
android)
build_android=true
;;
ios)
build_ios=true
;;
-v|--verbosity)
shift
verbosity="$1"
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 [all|macos|windows|linux|android|ios] [-v verbosity_level]"
echo "Verbosity levels: quiet, minimal, normal, detailed, diagnostic"
exit 1
;;
esac
shift
done
# Clean previous builds
clean_builds
# Execute builds based on the selected options
if [ "$build_all" = true ] || [ "$build_macos" = true ]; then
build_macos
fi
if [ "$build_all" = true ] || [ "$build_windows" = true ]; then
build_windows
fi
if [ "$build_all" = true ] || [ "$build_linux" = true ]; then
build_linux
fi
if [ "$build_all" = true ] || [ "$build_android" = true ]; then
build_android
fi
if [ "$build_all" = true ] || [ "$build_ios" = true ]; then
build_ios
fi
echo "Build process complete. Outputs are in the '$output_dir' directory."