interplane.Get Omega
Read in your language

hop

Hop: a small native macOS launcher. Clipboard history, find, on-device dictation and your coding agent behind one key.

Brought by drakestapleton

branch main Branches Tags History

hop / build.sh

112 lines · 6045 bytes Raw Blame History
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).
4set -e
5cd "$(dirname "$0")"
6if [ "$(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" "$@"
17fi
18export LC_ALL=C # the same source file order on every Mac
19if [ "${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
22fi
23APP=build/Hop.app
24rm -rf "$APP"
25mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
26# Work around a broken Command Line Tools install (two module maps both define SwiftBridging).
27EXTRA=""
28if [ -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"
32fi
33# The generated wrapper contains the exact seeded Omega machine code; fail on changed pins.
34shasum -a 256 -c Generated/SHA256SUMS
35clang -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
38swiftc -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.
43shasum -a 256 -c Generated/CORE-SHA256SUMS
44cp Generated/hopcore "$APP/Contents/MacOS/hopcore"
45chmod 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.
47shasum -a 256 -c Generated/UI-SHA256SUMS
48cp Generated/hoppanel "$APP/Contents/MacOS/hoppanel"
49chmod 755 "$APP/Contents/MacOS/hoppanel"
50cp Resources/Info.plist "$APP/Contents/Info.plist"
51cp Resources/Hop.icns "$APP/Contents/Resources/Hop.icns" # drawn by tools/make-icon.swift
52cp 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.
55SIGN_ID="-"
56SIGN_KC="$HOME/Library/Keychains/hop-signing.keychain-db"
57SIGN_PW="$HOME/.config/hop-signing/keychain-password"
58if [ "${HOP_SIGN:-}" = "adhoc" ]; then
59 echo "signing ad-hoc (HOP_SIGN=adhoc)"
60elif [ -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"
62else
63 echo "warning: no local signing identity (run tools/signing-setup.sh); macOS will ask for Hop's permissions again after each update" >&2
64fi
65codesign --force --sign "$SIGN_ID" --timestamp=none "$APP/Contents/MacOS/hopcore" # arm64 macOS runs signed code only
66codesign --force --sign "$SIGN_ID" --timestamp=none "$APP/Contents/MacOS/hoppanel"
67codesign --force --sign "$SIGN_ID" --timestamp=none "$APP"
68codesign -d -r- "$APP" 2>&1 | grep designated
69echo "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).
72OAPP=build/HopOmega.app
73rm -rf "$OAPP"
74mkdir -p "$OAPP/Contents/MacOS" "$OAPP/Contents/Resources"
75cp Generated/hoppanel "$OAPP/Contents/MacOS/hoppanel"
76chmod 755 "$OAPP/Contents/MacOS/hoppanel"
77cp Resources/HopOmega-Info.plist "$OAPP/Contents/Info.plist"
78cp Resources/Hop.icns "$OAPP/Contents/Resources/Hop.icns"
79cp LICENSE "$OAPP/Contents/Resources/LICENSE"
80codesign --force --sign "$SIGN_ID" --timestamp=none "$OAPP"
81echo "built $OAPP"
82# Focused storage and headless model-routing checks. Temporary profile, no windows or real agent calls.
83sh tools/check-parking-lot.sh "$APP"
84if [ "${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"
92fi
93if [ "${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"
112fi