Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (43 loc) · 1.65 KB
/
Copy pathMakefile
File metadata and controls
55 lines (43 loc) · 1.65 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
PROJECT_NAME := OpencodeUsage
APP_NAME := OpenCode Usage
BUNDLE_ID := com.wiscaksono.opencode-usage
VERSION ?= $(shell git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//')
ifeq ($(strip $(VERSION)),)
VERSION := 0.0.0
endif
BUILD_DIR := build
DEBUG_APP_BUNDLE := $(BUILD_DIR)/Debug/$(APP_NAME).app
RELEASE_APP_BUNDLE := $(BUILD_DIR)/Release/$(APP_NAME).app
.PHONY: build release bundle run clean test format logs dmg
build:
swift build
@$(MAKE) bundle CONFIG=debug BUNDLE_PATH="$(DEBUG_APP_BUNDLE)" VERSION="$(VERSION)"
release:
swift build -c release
@$(MAKE) bundle CONFIG=release BUNDLE_PATH="$(RELEASE_APP_BUNDLE)" VERSION="$(VERSION)"
bundle:
mkdir -p "$(BUNDLE_PATH)/Contents/MacOS" "$(BUNDLE_PATH)/Contents/Resources"
cp ".build/$(CONFIG)/$(PROJECT_NAME)" "$(BUNDLE_PATH)/Contents/MacOS/$(APP_NAME)"
cp Support/Info.plist "$(BUNDLE_PATH)/Contents/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $(VERSION)" "$(BUNDLE_PATH)/Contents/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $(VERSION)" "$(BUNDLE_PATH)/Contents/Info.plist"
cp Sources/OpencodeUsage/Resources/opencode-logo.png "$(BUNDLE_PATH)/Contents/Resources/opencode-logo.png"
codesign --force --sign - "$(BUNDLE_PATH)"
run: build
killall "$(APP_NAME)" 2>/dev/null || true
open "$(DEBUG_APP_BUNDLE)"
clean:
rm -rf .build $(BUILD_DIR) "$(APP_NAME).dmg"
test:
swift test
format:
swiftformat .
logs:
log stream --predicate 'subsystem == "$(BUNDLE_ID)"' --level info
dmg: release
@rm -f "$(APP_NAME).dmg"
@hdiutil create -volname "$(APP_NAME)" \
-srcfolder "$(RELEASE_APP_BUNDLE)" \
-ov -format UDZO \
"$(APP_NAME).dmg"
@echo "Created $(APP_NAME).dmg"