diff --git a/env_vars b/env_vars index 8d4cae3..018a564 100644 --- a/env_vars +++ b/env_vars @@ -13,6 +13,7 @@ readonly VM_LIN_X86="vm-linux" readonly VM_LIN_ARM="vm-linux-arm" readonly VM_MAC_X86="vm-macos" readonly VM_MAC_ARM="vm-macos-arm" +readonly VM_MAC="vm-macos-unified" readonly VM_WIN_X86="vm-win" readonly VM_WIN_ARM="vm-win-arm" diff --git a/helpers_bundles.sh b/helpers_bundles.sh index 1021b81..a5bc267 100644 --- a/helpers_bundles.sh +++ b/helpers_bundles.sh @@ -139,3 +139,77 @@ copy_resources() { cp -R "${TMP_PATH}/ExampleEtoys" "${target}/" fi } + +# Make a fat binary from a pair of VMs in +# build.macos64{x64,ARMv8}/virtend.cog.spur/Virtend*.app +# To choose the oldest nib the oldest deployment target (x86_64) should be last +create_unified_vm_macOS() { + local MISMATCHINGNIBS= + local MISMATCHINGPLISTS= + + readonly O="$1" + readonly A="$2" + readonly B="$3" + + if [ ! -d "$A" ]; then + echo "$A does not exist; aborting" + exit 44 + fi + + if [ ! -d "$B" ]; then + echo "$B does not exist; aborting" + exit 45 + fi + + echo "merging $A \& $B into $O..." + mkdir -p $O + + for f in `cd $A >/dev/null; find . | sed 's|^\.\/||'`; do + if [ -d "$A/$f" ]; then + mkdir -p $O/$f + # elif [ -L "$A/$f" ]; then + # echo ln -s `readlink "$A/$f"` "$O/$f" + elif [ ! -f "$A/$f" ]; then + echo "$A/$f does not exist; how come?" + elif [ ! -f "$B/$f" ]; then + echo "$B/$f does not exist; how come?" + else + case `file -b "$A/$f"` in + Mach-O*) + lipo -create -output "$O/$f" "$A/$f" "$B/$f";; + *) + if cmp -s "$A/$f" "$B/$f"; then + cp "$A/$f" "$O/$f" + else + echo "EXCLUDING $f because it differs" + case "$f" in + *.plist) + MISMATCHINGPLISTS="$MISMATCHINGPLISTS $f" + ;; + *.nib) + MISMATCHINGNIBS="$MISMATCHINGNIBS $f" + echo "using $B version" + cp "$B/$f" "$O/$f" + ;; + esac + fi + esac + fi + done + + if [ -n "$MISMATCHINGPLISTS" ]; then + echo "Builds $A \& $B are NOT in perfect sync. Rebuild one or other to resolve" + for f in $MISMATCHINGPLISTS; do + echo "$f" + diff $A/$f $B/$f + done + exit 46 + fi + + if [ -n "$MISMATCHINGNIBS" ]; then + echo "Builds $A \& $B are NOT in perfect sync. ui nibs differ. Took $B\'s" + for f in $MISMATCHINGNIBS; do + echo $f + done + fi +} \ No newline at end of file diff --git a/prepare_bundle_macos.sh b/prepare_bundle_macos.sh new file mode 100644 index 0000000..f4d30ce --- /dev/null +++ b/prepare_bundle_macos.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +################################################################################ +# PROJECT: Squeak Bundle Generation +# FILE: prepare_bundle_macos_arm.sh +# CONTENT: Generate bundle for macOS (unified, arm64 and x64). +# +# AUTHORS: Fabio Niephaus, Hasso Plattner Institute, Potsdam, Germany +# Marcel Taeumel, Hasso Plattner Institute, Potsdam, Germany +################################################################################ + +begin_group "Creating macOS bundle for ${SMALLTALK_VERSION}..." +BUNDLE_NAME_MAC="${IMAGE_NAME}-${VERSION_VM_MACOS}" +export_variable "BUNDLE_NAME_MAC" "${BUNDLE_NAME_MAC}" +BUNDLE_ID_MAC="org.squeak.$(echo ${SQUEAK_VERSION} | tr '[:upper:]' '[:lower:]')-${IMAGE_BITS}bit" +APP_NAME="${IMAGE_NAME}.app" +APP_PATH="${BUILD_PATH}/${APP_NAME}" +CONTENTS_PATH="${APP_PATH}/Contents" +RESOURCES_PATH="${CONTENTS_PATH}/Resources" +VM_MAC_TARGET="${CONTENTS_PATH}/MacOS" + +echo "...copying macOS VM (unified)..." +if is_dir "${TMP_PATH}/${VM_MAC}/Squeak.app"; then + cp -R "${TMP_PATH}/${VM_MAC}/Squeak.app" "${APP_PATH}" +else + echo "Unable to locate macOS VM." && exit 1 +fi + +copy_resources "${RESOURCES_PATH}" + +echo "...merging template..." +cp "${MAC_TEMPLATE_PATH}/Squeak.app/Contents/Info.plist" "${CONTENTS_PATH}/" +cp "${ICONS_PATH}/${SMALLTALK_NAME}"*.icns "${RESOURCES_PATH}/" +ENGLISH_PATH="${MAC_TEMPLATE_PATH}/Squeak.app/Contents/Resources/English.lproj" +cp "${ENGLISH_PATH}/Credits.rtf" "${RESOURCES_PATH}/English.lproj/" + +echo "...setting permissions..." +chmod +x "${VM_MAC_TARGET}/Squeak" + +echo "...patching Info.plist..." +# Info.plist +sed -i".bak" "s/%SmalltalkName%/${SMALLTALK_NAME}/g" "${CONTENTS_PATH}/Info.plist" +sed -i".bak" "s/%CFBundleGetInfoString%/${BUNDLE_NAME_MAC}/g" "${CONTENTS_PATH}/Info.plist" +sed -i".bak" "s/%CFBundleIdentifier%/${BUNDLE_ID_MAC}/g" "${CONTENTS_PATH}/Info.plist" +sed -i".bak" "s/%CFBundleName%/${SMALLTALK_NAME}/g" "${CONTENTS_PATH}/Info.plist" +sed -i".bak" "s/%CFBundleShortVersionString%/${SQUEAK_VERSION_NUMBER}/g" "${CONTENTS_PATH}/Info.plist" +sed -i".bak" "s/%CFBundleVersion%/${IMAGE_BITS} bit/g" "${CONTENTS_PATH}/Info.plist" +sed -i".bak" "s/%SqueakImageName%/${IMAGE_NAME}.image/g" "${CONTENTS_PATH}/Info.plist" +rm -f "${CONTENTS_PATH}/Info.plist.bak" + +if should_codesign; then + do_codesign "${APP_PATH}" # *.app +fi + +compress_into_product_macOS "${APP_PATH}" "${BUNDLE_NAME_MAC}" +reset_build_dir + +end_group diff --git a/prepare_bundles.sh b/prepare_bundles.sh index 5971213..38040b1 100755 --- a/prepare_bundles.sh +++ b/prepare_bundles.sh @@ -67,6 +67,7 @@ if should_use_rc_vm; then else download_and_extract_all_vms fi +create_unified_vm_macOS "${TMP_PATH}/${VM_MAC}" "${TMP_PATH}/${VM_MAC_ARM}" "${TMP_PATH}/${VM_MAC_X86}" if should_codesign; then source "helpers_codesign.sh" @@ -75,12 +76,12 @@ fi prepare_image_bundle # Just .image and .changes in an archive if is_64bit; then -# source "prepare_bundle_aio.sh" -# source "prepare_bundle_macos.sh" # Unified binary x86+ARM + source "prepare_bundle_macos.sh" # Unified binary arm64+x64 source "prepare_bundle_macos_x86.sh" source "prepare_bundle_macos_arm.sh" fi +source "prepare_bundle_aio.sh" source "prepare_bundle_linux_x86.sh" source "prepare_bundle_linux_arm.sh" source "prepare_bundle_windows_x86.sh"