hop
Hop: a small native macOS launcher. Clipboard history, find, on-device dictation and your coding agent behind one key.
Brought by drakestapleton
hop / build.sh
| 1 | #!/bin/sh |
| 2 | # Builds Hop.app and Hop Omega.app (no Xcode project, no outside libraries). Usage: ./build.sh [install | install-omega] |
| 3 | # HOP_SIGN=adhoc signs without any local identity (this is what a public release uses). |
| 4 | set -e |
| 5 | cd "$(dirname "$0")" |
| 6 | if [ "$(uname -s)" = Linux ]; then |
| 7 | mkdir -p build/linux-toolchain |
| 8 | OMEGA_STORE=${OMEGA_STORE:-"$HOME/git/omega-mv.git"} |
| 9 | OMEGA_HEAD=$(git --git-dir="$OMEGA_STORE" rev-parse refs/heads/main) |
| 10 | git --git-dir="$OMEGA_STORE" archive --output=build/linux-toolchain.tar "$OMEGA_HEAD" seed/ng seed/out |
| 11 | tar -xf build/linux-toolchain.tar -C build/linux-toolchain |
| 12 | git --git-dir="$OMEGA_STORE" rev-parse "$OMEGA_HEAD" > build/linux-toolchain/source-commit |
| 13 | (cd build/linux-toolchain && sha256sum -c seed/out/omc.sha256) |
| 14 | build/linux-toolchain/seed/out/omc < Linux/build.om > build/linux-build |
| 15 | chmod +x build/linux-build |
| 16 | exec build/linux-build "$PWD/build/linux-toolchain" "$@" |
| 17 | fi |
| 18 | export LC_ALL=C # the same source file order on every Mac |
| 19 | if [ "${1:-}" = "install" ] && pgrep -u "$(id -u)" -x Hop >/dev/null; then |
| 20 | echo "Quit Hop before installing. Running chats are not silently terminated." >&2 |
| 21 | exit 2 |
| 22 | fi |
| 23 | APP=build/Hop.app |
| 24 | rm -rf "$APP" |
| 25 | mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources" |
| 26 | # Work around a broken Command Line Tools install (two module maps both define SwiftBridging). |
| 27 | EXTRA="" |
| 28 | if [ -f /Library/Developer/CommandLineTools/usr/include/swift/module.modulemap ] && \ |
| 29 | [ -f /Library/Developer/CommandLineTools/usr/include/swift/bridging.modulemap ]; then |
| 30 | sed "s#HOP_DIR#$PWD#" toolchain/overlay.yaml > build/overlay.yaml |
| 31 | EXTRA="-vfsoverlay $PWD/build/overlay.yaml -Xcc -ivfsoverlay -Xcc $PWD/build/overlay.yaml" |
| 32 | fi |
| 33 | # The generated wrapper contains the exact seeded Omega machine code; fail on changed pins. |
| 34 | shasum -a 256 -c Generated/SHA256SUMS |
| 35 | clang -std=gnu11 -O2 -Wall -Wextra -Werror -target arm64-apple-macos26.0 \ |
| 36 | -include Generated/omega_native.h -c Generated/omega_native.c -o build/omega_native.o |
| 37 | # shellcheck disable=SC2086 |
| 38 | swiftc -O -swift-version 5 -target arm64-apple-macos26.0 $EXTRA \ |
| 39 | -framework AppKit -framework SwiftUI -framework Carbon -framework ServiceManagement -framework Speech -framework AVFoundation -framework CoreAudio \ |
| 40 | -import-objc-header Generated/omega_native.h build/omega_native.o \ |
| 41 | Sources/*.swift -o "$APP/Contents/MacOS/Hop" |
| 42 | # The matching core: an Omega program built by the seeded Omega NG compiler (Omega/README.md). Its bytes are pinned. |
| 43 | shasum -a 256 -c Generated/CORE-SHA256SUMS |
| 44 | cp Generated/hopcore "$APP/Contents/MacOS/hopcore" |
| 45 | chmod 755 "$APP/Contents/MacOS/hopcore" |
| 46 | # The launcher panel as an Omega program (Omega/ui/hoppanel.om; `hop panel` opens it). Its bytes are pinned too. |
| 47 | shasum -a 256 -c Generated/UI-SHA256SUMS |
| 48 | cp Generated/hoppanel "$APP/Contents/MacOS/hoppanel" |
| 49 | chmod 755 "$APP/Contents/MacOS/hoppanel" |
| 50 | cp Resources/Info.plist "$APP/Contents/Info.plist" |
| 51 | cp Resources/Hop.icns "$APP/Contents/Resources/Hop.icns" # drawn by tools/make-icon.swift |
| 52 | cp LICENSE "$APP/Contents/Resources/LICENSE" # the licence travels with the app |
| 53 | # Sign with the fixed local identity (tools/signing-setup.sh) so macOS keeps Hop's clipboard and paste |
| 54 | # permission across updates. An ad-hoc signature changes every build and macOS then forgets both. |
| 55 | SIGN_ID="-" |
| 56 | SIGN_KC="$HOME/Library/Keychains/hop-signing.keychain-db" |
| 57 | SIGN_PW="$HOME/.config/hop-signing/keychain-password" |
| 58 | if [ "${HOP_SIGN:-}" = "adhoc" ]; then |
| 59 | echo "signing ad-hoc (HOP_SIGN=adhoc)" |
| 60 | elif [ -f "$SIGN_KC" ] && [ -f "$SIGN_PW" ] && security unlock-keychain -p "$(cat "$SIGN_PW")" "$SIGN_KC" 2>/dev/null; then |
| 61 | SIGN_ID="Hop Local Signing" |
| 62 | else |
| 63 | echo "warning: no local signing identity (run tools/signing-setup.sh); macOS will ask for Hop's permissions again after each update" >&2 |
| 64 | fi |
| 65 | codesign --force --sign "$SIGN_ID" --timestamp=none "$APP/Contents/MacOS/hopcore" # arm64 macOS runs signed code only |
| 66 | codesign --force --sign "$SIGN_ID" --timestamp=none "$APP/Contents/MacOS/hoppanel" |
| 67 | codesign --force --sign "$SIGN_ID" --timestamp=none "$APP" |
| 68 | codesign -d -r- "$APP" 2>&1 | grep designated |
| 69 | echo "built $APP" |
| 70 | # Hop Omega.app: the Omega launcher panel as an app of its own. Nothing in it is Swift or C: its one executable is |
| 71 | # Generated/hoppanel, built by the seeded Omega NG compiler from Omega/ui/hoppanel.om (Omega/README.md). |
| 72 | OAPP=build/HopOmega.app |
| 73 | rm -rf "$OAPP" |
| 74 | mkdir -p "$OAPP/Contents/MacOS" "$OAPP/Contents/Resources" |
| 75 | cp Generated/hoppanel "$OAPP/Contents/MacOS/hoppanel" |
| 76 | chmod 755 "$OAPP/Contents/MacOS/hoppanel" |
| 77 | cp Resources/HopOmega-Info.plist "$OAPP/Contents/Info.plist" |
| 78 | cp Resources/Hop.icns "$OAPP/Contents/Resources/Hop.icns" |
| 79 | cp LICENSE "$OAPP/Contents/Resources/LICENSE" |
| 80 | codesign --force --sign "$SIGN_ID" --timestamp=none "$OAPP" |
| 81 | echo "built $OAPP" |
| 82 | # Focused storage and headless model-routing checks. Temporary profile, no windows or real agent calls. |
| 83 | sh tools/check-parking-lot.sh "$APP" |
| 84 | if [ "${1:-}" = "install-omega" ]; then # beside Hop, never over it: Hop.app is not touched |
| 85 | ODEST="$HOME/Applications/Hop Omega.app" |
| 86 | mkdir -p "$HOME/Applications" |
| 87 | rm -rf "$HOME/Applications/.HopOmega-install-$$.app" |
| 88 | ditto "$OAPP" "$HOME/Applications/.HopOmega-install-$$.app" |
| 89 | rm -rf "$ODEST" |
| 90 | mv "$HOME/Applications/.HopOmega-install-$$.app" "$ODEST" |
| 91 | echo "installed $ODEST" |
| 92 | fi |
| 93 | if [ "${1:-}" = "install" ]; then |
| 94 | DEST="$HOME/Applications/Hop.app" |
| 95 | STAGED="$HOME/Applications/.Hop-install-$$.app" |
| 96 | BACKUP="" |
| 97 | mkdir -p "$HOME/Applications/.Hop-backups" |
| 98 | ditto "$APP" "$STAGED" |
| 99 | if [ -d "$DEST" ]; then |
| 100 | BACKUP="$HOME/Applications/.Hop-backups/Hop-$(date -u +%Y%m%dT%H%M%SZ)-$$.app" |
| 101 | mv "$DEST" "$BACKUP" |
| 102 | fi |
| 103 | if ! mv "$STAGED" "$DEST"; then |
| 104 | if [ -n "$BACKUP" ]; then mv "$BACKUP" "$DEST"; fi |
| 105 | exit 1 |
| 106 | fi |
| 107 | echo "installed $DEST" |
| 108 | if [ -n "$BACKUP" ]; then echo "rollback app: $BACKUP"; fi |
| 109 | # The hop command for a terminal (README, "Hop in a terminal"); a file or another program's link is left alone. |
| 110 | [ "${HOP_NO_CLI:-}" = "1" ] || "$DEST/Contents/MacOS/Hop" link || true |
| 111 | open "$DEST" |
| 112 | fi |