-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·125 lines (105 loc) · 3.87 KB
/
build.sh
File metadata and controls
executable file
·125 lines (105 loc) · 3.87 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
#!/bin/bash
set -e
# Build TotalSegmentatorHorosPlugin for Horos and/or OsiriX
# Usage: ./build.sh [horos|osirix|both] [--sign]
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$SCRIPT_DIR/MyOsiriXPluginFolder-Swift"
PROJECT="$PROJECT_DIR/TotalSegmentatorHorosPlugin.xcodeproj"
SCHEME="TotalSegmentatorHorosPlugin"
BUILD_DIR="$PROJECT_DIR/build"
RELEASES_DIR="$SCRIPT_DIR/Releases"
DATE=$(date +"%Y %m %d")
# Parse arguments
PLATFORM="${1:-both}"
SIGN=false
if [[ "$1" == "--sign" ]]; then
PLATFORM="both"
SIGN=true
elif [[ "$2" == "--sign" ]]; then
SIGN=true
fi
# Validate platform argument
if [[ "$PLATFORM" != "horos" && "$PLATFORM" != "osirix" && "$PLATFORM" != "both" ]]; then
echo "Usage: ./build.sh [horos|osirix|both] [--sign]"
echo " horos - Build for Horos only"
echo " osirix - Build for OsiriX only"
echo " both - Build for both platforms (default)"
echo " --sign - Ad-hoc sign the plugins"
exit 1
fi
build_platform() {
local PLAT="$1"
local PLAT_UPPER=$(echo "$PLAT" | tr '[:lower:]' '[:upper:]')
# Capitalize first letter: horos -> Horos, osirix -> Osirix
local PLAT_CAPITALIZED="$(tr '[:lower:]' '[:upper:]' <<< ${PLAT:0:1})${PLAT:1}"
echo ""
echo "========================================"
echo "Building for $PLAT_UPPER"
echo "========================================"
# Switch to platform-specific configuration
echo "==> Switching to $PLAT configuration..."
cp "$PROJECT/project_${PLAT_CAPITALIZED}.pbxproj" "$PROJECT/project.pbxproj"
cp "$PROJECT_DIR/TotalSegmentatorHorosPlugin-Bridging-Header_${PLAT_CAPITALIZED}.h" \
"$PROJECT_DIR/TotalSegmentatorHorosPlugin-Bridging-Header.h"
# Clean previous build
echo "==> Cleaning previous build..."
rm -rf "$BUILD_DIR"
# Build
echo "==> Building $SCHEME (Release) for $PLAT_UPPER..."
xcodebuild \
-project "$PROJECT" \
-scheme "$SCHEME" \
-configuration Release \
CONFIGURATION_BUILD_DIR="$BUILD_DIR/Release" \
build
BUILT_PLUGIN="$BUILD_DIR/Release/TotalSegmentatorHorosPlugin.osirixplugin"
if [[ ! -d "$BUILT_PLUGIN" ]]; then
echo "ERROR: Build failed - plugin not found at $BUILT_PLUGIN"
exit 1
fi
echo "==> Build successful!"
# Create platform-specific releases directory
local PLAT_RELEASES_DIR="$RELEASES_DIR/$PLAT_CAPITALIZED"
mkdir -p "$PLAT_RELEASES_DIR"
# Copy plugin
local DEST="$PLAT_RELEASES_DIR/TotalSegmentatorPlugin $DATE.osirixplugin"
echo "==> Creating plugin: $DEST"
rm -rf "$DEST"
cp -R "$BUILT_PLUGIN" "$DEST"
# Sign if requested
if $SIGN; then
echo "==> Signing plugin..."
codesign --force --deep --sign - "$DEST"
echo "==> Plugin signed (ad-hoc)"
fi
echo "==> $PLAT_UPPER build complete: $DEST"
}
# Build for selected platform(s)
if [[ "$PLATFORM" == "horos" || "$PLATFORM" == "both" ]]; then
build_platform "horos"
fi
if [[ "$PLATFORM" == "osirix" || "$PLATFORM" == "both" ]]; then
build_platform "osirix"
fi
# Restore Horos as default configuration
echo ""
echo "==> Restoring Horos as default configuration..."
cp "$PROJECT/project_Horos.pbxproj" "$PROJECT/project.pbxproj"
cp "$PROJECT_DIR/TotalSegmentatorHorosPlugin-Bridging-Header_Horos.h" \
"$PROJECT_DIR/TotalSegmentatorHorosPlugin-Bridging-Header.h"
echo ""
echo "========================================"
echo "Build complete!"
echo "========================================"
echo ""
echo "Plugins created in:"
if [[ "$PLATFORM" == "horos" || "$PLATFORM" == "both" ]]; then
echo " Horos: $RELEASES_DIR/Horos/"
fi
if [[ "$PLATFORM" == "osirix" || "$PLATFORM" == "both" ]]; then
echo " OsiriX: $RELEASES_DIR/Osirix/"
fi
echo ""
echo "To install, copy the .osirixplugin to:"
echo " Horos: ~/Library/Application Support/Horos/Plugins/"
echo " OsiriX: ~/Library/Application Support/OsiriX/Plugins/"