-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathbuild-mac.sh
More file actions
executable file
·41 lines (33 loc) · 1.13 KB
/
build-mac.sh
File metadata and controls
executable file
·41 lines (33 loc) · 1.13 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
#!/bin/bash
#Modified from Avalonia's documentation: https://docs.avaloniaui.net/docs/0.10.x/distribution-publishing/macos
set -e
trap 'echo "Error packaging app"; exit 1' ERR
PROJECT_NAME="openlauncher"
OUTPUT_DIR="./src/openlauncher/bin/Release/net8.0"
FINAL_OUTPUT_DIR="./src/openlauncher/bin/Release/net8.0/macos-universal"
# Function to build for a specific architecture
build_for_arch() {
local arch=$1
echo "Building for $arch..."
dotnet publish -r osx-$arch -c Release
}
# Build for both architectures
build_for_arch "x64"
build_for_arch "arm64"
# Create the final output directory
mkdir -p "$FINAL_OUTPUT_DIR"
ARM_OUTPUT="$OUTPUT_DIR/osx-arm64/publish"
X64_OUTPUT="$OUTPUT_DIR/osx-x64/publish"
#Copy libraries into final output dir
for FILE in "$ARM_OUTPUT"/*; do
BASENAME=$(basename "$FILE")
if [ -f "$FILE" ] && [[ "$BASENAME" != "openlauncher" ]]; then
cp "$FILE" "$FINAL_OUTPUT_DIR"/.
fi
done
# Create universal binary
echo "Creating universal binary..."
lipo -create \
"$OUTPUT_DIR/osx-x64/publish/$PROJECT_NAME" \
"$OUTPUT_DIR/osx-arm64/publish/$PROJECT_NAME" \
-output "$FINAL_OUTPUT_DIR/$PROJECT_NAME"