-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·56 lines (46 loc) · 1.49 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·56 lines (46 loc) · 1.49 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
#!/bin/bash
#
# Builds Clipsu and assembles a runnable Clipsu.app bundle (ad-hoc signed).
#
# Usage:
# ./build.sh # release build → ./build/Clipsu.app
# ./build.sh debug # debug build
# ./build.sh run # build (release) then launch the app
#
set -euo pipefail
cd "$(dirname "$0")"
CONFIG="release"
LAUNCH="no"
case "${1:-}" in
debug) CONFIG="debug" ;;
run) LAUNCH="yes" ;;
"") ;;
*) echo "Unknown argument: $1"; exit 1 ;;
esac
APP_NAME="Clipsu"
BUILD_DIR="build"
APP_DIR="${BUILD_DIR}/${APP_NAME}.app"
CONTENTS="${APP_DIR}/Contents"
MACOS_DIR="${CONTENTS}/MacOS"
RES_DIR="${CONTENTS}/Resources"
echo "▸ Compiling (${CONFIG})…"
swift build -c "${CONFIG}" --product "${APP_NAME}"
BIN_PATH="$(swift build -c "${CONFIG}" --product "${APP_NAME}" --show-bin-path)/${APP_NAME}"
echo "▸ Assembling ${APP_DIR}…"
rm -rf "${APP_DIR}"
mkdir -p "${MACOS_DIR}" "${RES_DIR}"
cp "${BIN_PATH}" "${MACOS_DIR}/${APP_NAME}"
cp "Resources/Info.plist" "${CONTENTS}/Info.plist"
if [ -f "Resources/AppIcon.icns" ]; then
cp "Resources/AppIcon.icns" "${RES_DIR}/AppIcon.icns"
/usr/libexec/PlistBuddy -c "Add :CFBundleIconFile string AppIcon" "${CONTENTS}/Info.plist" 2>/dev/null || true
fi
echo "▸ Ad-hoc signing…"
codesign --force --deep --sign - "${APP_DIR}"
echo "✓ Built ${APP_DIR}"
if [ "${LAUNCH}" = "yes" ]; then
echo "▸ Launching…"
# Kill any previous instance first.
pkill -x "${APP_NAME}" 2>/dev/null || true
open "${APP_DIR}"
fi