@@ -115,14 +115,46 @@ clean() {
115115 print_success " Cleaned"
116116}
117117
118+ # Convert PNG to ICNS
119+ create_icns_from_png () {
120+ local PNG_PATH=$1
121+ local ICNS_PATH=$2
122+
123+ local ICONSET_DIR=$( mktemp -d) /AppIcon.iconset
124+ mkdir -p " $ICONSET_DIR "
125+
126+ # Generate all required sizes
127+ sips -z 16 16 " $PNG_PATH " --out " $ICONSET_DIR /icon_16x16.png" > /dev/null 2>&1
128+ sips -z 32 32 " $PNG_PATH " --out " $ICONSET_DIR /icon_16x16@2x.png" > /dev/null 2>&1
129+ sips -z 32 32 " $PNG_PATH " --out " $ICONSET_DIR /icon_32x32.png" > /dev/null 2>&1
130+ sips -z 64 64 " $PNG_PATH " --out " $ICONSET_DIR /icon_32x32@2x.png" > /dev/null 2>&1
131+ sips -z 128 128 " $PNG_PATH " --out " $ICONSET_DIR /icon_128x128.png" > /dev/null 2>&1
132+ sips -z 256 256 " $PNG_PATH " --out " $ICONSET_DIR /icon_128x128@2x.png" > /dev/null 2>&1
133+ sips -z 256 256 " $PNG_PATH " --out " $ICONSET_DIR /icon_256x256.png" > /dev/null 2>&1
134+ sips -z 512 512 " $PNG_PATH " --out " $ICONSET_DIR /icon_256x256@2x.png" > /dev/null 2>&1
135+ sips -z 512 512 " $PNG_PATH " --out " $ICONSET_DIR /icon_512x512.png" > /dev/null 2>&1
136+ sips -z 1024 1024 " $PNG_PATH " --out " $ICONSET_DIR /icon_512x512@2x.png" > /dev/null 2>&1
137+
138+ # Convert to icns
139+ iconutil -c icns " $ICONSET_DIR " -o " $ICNS_PATH "
140+
141+ # Cleanup
142+ rm -rf " $( dirname " $ICONSET_DIR " ) "
143+ }
144+
118145# Create macOS .app bundle
119146create_app_bundle () {
120147 local ARCH=$1
121148 local BINARY_PATH=$2
122- local APP_DIR=" $OUTPUT_DIR /$APP_NAME -$ARCH .app"
149+ local BUILD_DIR=" $OUTPUT_DIR /build-$ARCH "
150+ local APP_DIR=" $BUILD_DIR /$APP_NAME .app"
123151
124152 echo " Creating app bundle for $ARCH ..."
125153
154+ # Create build directory for this arch
155+ rm -rf " $BUILD_DIR "
156+ mkdir -p " $BUILD_DIR "
157+
126158 # Create bundle structure
127159 mkdir -p " $APP_DIR /Contents/MacOS"
128160 mkdir -p " $APP_DIR /Contents/Resources"
@@ -196,38 +228,13 @@ EOF
196228 print_success " Created: $APP_DIR "
197229}
198230
199- # Convert PNG to ICNS
200- create_icns_from_png () {
201- local PNG_PATH=$1
202- local ICNS_PATH=$2
203-
204- local ICONSET_DIR=$( mktemp -d) /AppIcon.iconset
205- mkdir -p " $ICONSET_DIR "
206-
207- # Generate all required sizes
208- sips -z 16 16 " $PNG_PATH " --out " $ICONSET_DIR /icon_16x16.png" > /dev/null 2>&1
209- sips -z 32 32 " $PNG_PATH " --out " $ICONSET_DIR /icon_16x16@2x.png" > /dev/null 2>&1
210- sips -z 32 32 " $PNG_PATH " --out " $ICONSET_DIR /icon_32x32.png" > /dev/null 2>&1
211- sips -z 64 64 " $PNG_PATH " --out " $ICONSET_DIR /icon_32x32@2x.png" > /dev/null 2>&1
212- sips -z 128 128 " $PNG_PATH " --out " $ICONSET_DIR /icon_128x128.png" > /dev/null 2>&1
213- sips -z 256 256 " $PNG_PATH " --out " $ICONSET_DIR /icon_128x128@2x.png" > /dev/null 2>&1
214- sips -z 256 256 " $PNG_PATH " --out " $ICONSET_DIR /icon_256x256.png" > /dev/null 2>&1
215- sips -z 512 512 " $PNG_PATH " --out " $ICONSET_DIR /icon_256x256@2x.png" > /dev/null 2>&1
216- sips -z 512 512 " $PNG_PATH " --out " $ICONSET_DIR /icon_512x512.png" > /dev/null 2>&1
217- sips -z 1024 1024 " $PNG_PATH " --out " $ICONSET_DIR /icon_512x512@2x.png" > /dev/null 2>&1
218-
219- # Convert to icns
220- iconutil -c icns " $ICONSET_DIR " -o " $ICNS_PATH "
221-
222- # Cleanup
223- rm -rf " $( dirname " $ICONSET_DIR " ) "
224- }
225-
226231# Create DMG
227232create_dmg_file () {
228233 local ARCH=$1
229- local APP_DIR=" $OUTPUT_DIR /$APP_NAME -$ARCH .app"
234+ local BUILD_DIR=" $OUTPUT_DIR /build-$ARCH "
235+ local APP_DIR=" $BUILD_DIR /$APP_NAME .app"
230236 local DMG_PATH=" $OUTPUT_DIR /$APP_NAME -$ARCH .dmg"
237+ local ICNS_PATH=" $APP_DIR /Contents/Resources/AppIcon.icns"
231238
232239 echo " Creating DMG for $ARCH ..."
233240
@@ -238,12 +245,12 @@ create_dmg_file() {
238245 # Use create-dmg for a nice DMG with background
239246 create-dmg \
240247 --volname " $APP_NAME " \
241- --volicon " $APP_DIR /Contents/Resources/AppIcon.icns " \
248+ --volicon " $ICNS_PATH " \
242249 --window-pos 200 120 \
243250 --window-size 600 400 \
244251 --icon-size 100 \
245- --icon " $APP_NAME - $ARCH .app" 150 190 \
246- --hide-extension " $APP_NAME - $ARCH .app" \
252+ --icon " $APP_NAME .app" 150 190 \
253+ --hide-extension " $APP_NAME .app" \
247254 --app-drop-link 450 190 \
248255 " $DMG_PATH " \
249256 " $APP_DIR " \
@@ -283,11 +290,11 @@ build_macos() {
283290 create_dmg_file " intel"
284291 create_dmg_file " arm64"
285292
286- # Also create tar.gz for GitHub releases
287- echo " Creating tar.gz archives... "
288- (cd " $OUTPUT_DIR " && tar -czvf " ultralog-macos-intel.tar.gz " " $APP_NAME -intel.app " )
289- (cd " $OUTPUT_DIR " && tar -czvf " ultralog-macos-arm64.tar.gz " " $APP_NAME -arm64.app " )
290- print_success " Created tar.gz archives "
293+ # Clean up build directories
294+ rm -rf " $OUTPUT_DIR /build-intel "
295+ rm -rf " $OUTPUT_DIR /build-arm64 "
296+
297+ print_success " macOS build complete "
291298}
292299
293300# Build Linux
@@ -343,13 +350,25 @@ install_local() {
343350 APP_ARCH=" intel"
344351 fi
345352
346- APP_SRC=" $OUTPUT_DIR /$APP_NAME -$APP_ARCH .app"
353+ BUILD_DIR=" $OUTPUT_DIR /build-$APP_ARCH "
354+ APP_SRC=" $BUILD_DIR /$APP_NAME .app"
347355 APP_DEST=" /Applications/$APP_NAME .app"
348356
349- # Check if app bundle exists
357+ # Check if app bundle exists, if not build it
350358 if [ ! -d " $APP_SRC " ]; then
351359 echo " App bundle not found. Building first..."
352- build_macos
360+
361+ mkdir -p " $OUTPUT_DIR "
362+
363+ if [ " $APP_ARCH " = " arm64" ]; then
364+ echo " Building aarch64-apple-darwin (Apple Silicon)..."
365+ cargo build --release --target aarch64-apple-darwin
366+ create_app_bundle " arm64" " $PROJECT_DIR /target/aarch64-apple-darwin/release/ultralog"
367+ else
368+ echo " Building x86_64-apple-darwin (Intel)..."
369+ cargo build --release --target x86_64-apple-darwin
370+ create_app_bundle " intel" " $PROJECT_DIR /target/x86_64-apple-darwin/release/ultralog"
371+ fi
353372 fi
354373
355374 # Remove old installation
0 commit comments