-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
94 lines (81 loc) · 4.54 KB
/
Copy pathMakefile
File metadata and controls
94 lines (81 loc) · 4.54 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# ──────────────────────────────────────────────────────────────
# Signal – macOS menu-bar status light
# ──────────────────────────────────────────────────────────────
APP_NAME := Signal
CLI_NAME := sgnl
BUILD_DIR := .build
RELEASE_DIR := $(BUILD_DIR)/release
APP_BUNDLE := $(BUILD_DIR)/$(APP_NAME).app
INSTALL_DIR := /Applications
CLI_INSTALL := $(HOME)/.local/bin
CODESIGN_IDENTITY ?= -
.PHONY: build run install uninstall clean dmg help
# ── Build ────────────────────────────────────────────────────
build:
@echo "⚙ Building $(APP_NAME) (release)…"
swift build -c release
@echo "📦 Assembling $(APP_NAME).app bundle…"
mkdir -p "$(APP_BUNDLE)/Contents/MacOS"
mkdir -p "$(APP_BUNDLE)/Contents/Resources"
cp "$(RELEASE_DIR)/$(APP_NAME)" "$(APP_BUNDLE)/Contents/MacOS/$(APP_NAME)"
cp "Resources/Info.plist" "$(APP_BUNDLE)/Contents/"
cp "Resources/AppIcon.icns" "$(APP_BUNDLE)/Contents/Resources/" 2>/dev/null || true
cp -R Resources/en.lproj "$(APP_BUNDLE)/Contents/Resources/"
cp -R Resources/zh-Hans.lproj "$(APP_BUNDLE)/Contents/Resources/"
cp "$(RELEASE_DIR)/$(CLI_NAME)" "$(APP_BUNDLE)/Contents/Resources/$(CLI_NAME)"
@echo "🔏 Code signing app bundle with identity '$(CODESIGN_IDENTITY)'…"
codesign --force --sign "$(CODESIGN_IDENTITY)" "$(APP_BUNDLE)"
@echo "✅ Build complete → $(APP_BUNDLE)"
# ── Run ──────────────────────────────────────────────────────
run: build
@echo "🚀 Launching $(APP_NAME)…"
open "$(APP_BUNDLE)"
# ── Install ──────────────────────────────────────────────────
install: build
@echo "📥 Installing $(APP_NAME).app → $(INSTALL_DIR)/"
cp -R "$(APP_BUNDLE)" "$(INSTALL_DIR)/"
@echo "📥 Installing $(CLI_NAME) → $(CLI_INSTALL)/"
mkdir -p "$(CLI_INSTALL)"
cp "$(RELEASE_DIR)/$(CLI_NAME)" "$(CLI_INSTALL)/$(CLI_NAME)"
@echo "✅ Installed. Run: open /Applications/$(APP_NAME).app"
@echo " CLI: $(CLI_NAME) <red|yellow|green>"
# ── Uninstall ────────────────────────────────────────────────
uninstall:
@echo "🗑 Removing $(APP_NAME)…"
rm -rf "$(INSTALL_DIR)/$(APP_NAME).app"
rm -f "$(CLI_INSTALL)/$(CLI_NAME)"
@echo "✅ Uninstalled."
# ── DMG Packaging ───────────────────────────────────────────
dmg: build
@echo "📦 Preparing DMG staging area…"
rm -rf "$(BUILD_DIR)/dmg_stage"
mkdir -p "$(BUILD_DIR)/dmg_stage"
cp -R "$(APP_BUNDLE)" "$(BUILD_DIR)/dmg_stage/"
ln -s /Applications "$(BUILD_DIR)/dmg_stage/Applications"
@echo "📦 Creating DMG volume…"
rm -f "$(BUILD_DIR)/$(APP_NAME).dmg"
hdiutil create -ov -volname "$(APP_NAME)" -srcfolder "$(BUILD_DIR)/dmg_stage" -format UDZO "$(BUILD_DIR)/$(APP_NAME).dmg"
rm -rf "$(BUILD_DIR)/dmg_stage"
@if [ "$(CODESIGN_IDENTITY)" != "-" ]; then \
echo "🔏 Signing DMG volume…"; \
codesign --force --sign "$(CODESIGN_IDENTITY)" "$(BUILD_DIR)/$(APP_NAME).dmg"; \
fi
@echo "✅ DMG packaging complete → $(BUILD_DIR)/$(APP_NAME).dmg"
# ── Clean ────────────────────────────────────────────────────
clean:
@echo "🧹 Cleaning…"
swift package clean
rm -rf "$(APP_BUNDLE)" "$(BUILD_DIR)/$(APP_NAME).dmg"
@echo "✅ Clean."
# ── Help ─────────────────────────────────────────────────────
help:
@echo ""
@echo "Signal Makefile targets:"
@echo " make build – Build release binary & .app bundle"
@echo " make run – Build and launch the app"
@echo " make install – Copy .app to /Applications, CLI to ~/.local/bin"
@echo " make dmg – Package .app and CLI into .dmg"
@echo " make uninstall – Remove installed files"
@echo " make clean – Remove build artifacts"
@echo " make help – Show this help"
@echo ""