-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
125 lines (111 loc) · 5.35 KB
/
Makefile
File metadata and controls
125 lines (111 loc) · 5.35 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Makefile for CleanCopy project
# Configuration (can be overridden: make CONFIG=Release)
CONFIG ?= Debug
APP_NAME=CleanCopy
BUNDLE_ID=interimSolutions.CleanCopyTest
BUILD_DIR=./build/Build/Products/$(CONFIG)# Build directory depends on CONFIG
APP_PATH=$(BUILD_DIR)/$(APP_NAME).app
DMG_NAME=$(APP_NAME)-$(CONFIG).dmg
RESOURCES_DIR=dmg-resources
BACKGROUND_IMG=$(RESOURCES_DIR)/background.png
LICENSE_FILE=$(RESOURCES_DIR)/LICENSE.txt
# Default target: build the default configuration
all: build
# Build the specified configuration (default: Debug)
build:
@echo "Building $(APP_NAME) ($(CONFIG))..."
@xcodebuild -project $(APP_NAME).xcodeproj \
-scheme $(APP_NAME) \
-configuration $(CONFIG) \
-derivedDataPath ./build
@echo "Build finished. App located in $(BUILD_DIR)/"
# Run the built application (uses default CONFIG unless specified: make run CONFIG=Release)
run: build
@echo "Attempting to close any existing $(APP_NAME) instances..."
@killall "$(APP_NAME)" || true # Kill existing process, ignore error if not running
@echo "Running $(APP_NAME) ($(CONFIG)) from $(APP_PATH)"
@open "$(APP_PATH)"
# Deploy the built application to /Applications (does NOT trigger a build)
deploy:
@echo "Deploying $(APP_NAME) ($(CONFIG)) to /Applications..."
@echo "Attempting to close any existing $(APP_NAME) instances..."
@killall "$(APP_NAME)" 2>/dev/null || true
@echo "Removing existing $(APP_NAME).app from /Applications..."
@rm -rf "/Applications/$(APP_NAME).app" || echo " -> Failed to remove /Applications/$(APP_NAME).app (permissions?)"
@echo "Copying $(APP_NAME).app to /Applications using ditto..."
@if [ -d "$(APP_PATH)" ]; then \
ditto "$(APP_PATH)" "/Applications/$(APP_NAME).app" || echo " -> Failed to copy to /Applications (permissions?)"; \
echo "Deployment complete."; \
else \
echo "Error: $(APP_PATH) not found. Did you forget to run 'make build'?"; \
exit 1; \
fi
# Package the application into a DMG (uses default CONFIG unless specified: make package CONFIG=Release)
package: build
@echo "Packaging $(APP_NAME) ($(CONFIG)) into _$(DMG_NAME)_"
@# Ensure resources directory exists (optional, create-dmg might handle it)
@mkdir -p $(RESOURCES_DIR)
@# Check if create-dmg exists before running
@command -v create-dmg >/dev/null 2>&1 || { echo >&2 "Error: create-dmg command not found. Install via Homebrew: brew install create-dmg"; exit 1; }
@# Check if resource files exist (optional but good practice)
@[ -f "$(BACKGROUND_IMG)" ] || { echo >&2 "Warning: Background image not found at $(BACKGROUND_IMG)"; }
@[ -f "$(LICENSE_FILE)" ] || { echo >&2 "Warning: License file not found at $(LICENSE_FILE)"; }
@# Remove existing DMG if it exists to avoid create-dmg issues
@rm -f "$(DMG_NAME)"
@create-dmg \
--volname "$(APP_NAME) $(CONFIG)" \
--background "$(BACKGROUND_IMG)" \
--window-pos 200 120 \
--window-size 600 280 \
--icon-size 100 \
--icon "$(APP_NAME).app" 175 120 \
--hide-extension "$(APP_NAME).app" \
--app-drop-link 425 120 \
--eula "$(LICENSE_FILE)" \
"$(DMG_NAME)" \
"$(APP_PATH)"
@echo "DMG created: $(DMG_NAME)"
# Clean the build directory and all generated DMGs
# Note: Does not remove the dmg-resources directory
clean:
@echo "Cleaning build directory and DMGs..."
@rm -rf ./build
@rm -f $(APP_NAME)-*.dmg # Remove all potential DMGs (Debug/Release)
@echo "Clean complete."
# Reset: Clean build, remove preferences, clear first-launch flags, clear DerivedData, and attempt to remove from /Applications
# WARNING: Removing from /Applications might require sudo if not copied by the current user.
# WARNING: This does NOT automatically unregister the Login Item from System Settings.
reset: clean
@echo "Resetting application settings, clearing DerivedData, and removing from /Applications..."
@echo "Attempting to remove preferences file: ~/Library/Preferences/$(BUNDLE_ID).plist"
@rm -f ~/Library/Preferences/$(BUNDLE_ID).plist
@echo "Attempting to remove first-launch flags from UserDefaults..."
@defaults delete $(BUNDLE_ID) moveToApplicationsPromptShown 2>/dev/null || true
@defaults delete $(BUNDLE_ID) loginItemPromptShown 2>/dev/null || true
@defaults delete $(BUNDLE_ID) notificationDisabledPromptShown 2>/dev/null || true
@defaults delete $(BUNDLE_ID) isOnboardingCompleted 2>/dev/null || true
@echo "Attempting to remove Xcode DerivedData..."
@rm -rf ~/Library/Developer/Xcode/DerivedData
@echo "Attempting to remove application: /Applications/$(APP_NAME).app (may require sudo)"
@rm -rf "/Applications/$(APP_NAME).app" || echo " -> Failed to remove /Applications/$(APP_NAME).app (permissions?)"
@echo "Reset complete. Note: Login Item may need manual removal from System Settings."
# Run unit tests
test: build
@echo "Running Unit Tests..."
@xcodebuild test -project $(APP_NAME).xcodeproj \
-scheme $(APP_NAME) \
-destination 'platform=macOS' \
-only-testing:$(APP_NAME)Tests \
-derivedDataPath ./build
# Run UI tests
test-ui: build
@echo "Running UI Tests..."
@xcodebuild test -project $(APP_NAME).xcodeproj \
-scheme $(APP_NAME) \
-destination 'platform=macOS' \
-only-testing:$(APP_NAME)UITests \
-derivedDataPath ./build
# Run all tests
test-all: test test-ui
# Phony targets are not files
.PHONY: all build run deploy package clean reset test test-ui test-all