-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
157 lines (130 loc) · 5.63 KB
/
Makefile
File metadata and controls
157 lines (130 loc) · 5.63 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# A6Cutter Makefile for Local Development
# This Makefile provides local build capabilities with proper version injection
# Configuration
APP_NAME = A6Cutter
SCHEME = A6Cutter
CONFIGURATION = Release
DESTINATION = "platform=macOS"
# Version information (mimics GitHub Actions format with -dev suffix)
VERSION ?= $(shell git describe --tags --abbrev=0 2>/dev/null || echo "v1.0.0")-dev
BUILD_NUMBER ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "dev")
GIT_HASH ?= $(shell git rev-parse HEAD 2>/dev/null || echo "dev")
# Directories
BUILD_DIR = build
DMG_DIR = $(BUILD_DIR)/dmg
APP_PATH = $(shell find /Users/$(USER)/Library/Developer/Xcode/DerivedData -name "$(APP_NAME).app" -path "*/Build/Products/$(CONFIGURATION)/*" 2>/dev/null | head -1)
.PHONY: help clean build run dmg version-info
# Default target
help:
@echo "A6Cutter Makefile - Local Development"
@echo ""
@echo "Available targets:"
@echo " help - Show this help message"
@echo " version-info- Show current version information"
@echo " clean - Clean build artifacts"
@echo " build - Build the application"
@echo " run - Build and run the application"
@echo " dmg - Create DMG for distribution"
@echo " install - Install to Applications folder"
@echo ""
@echo "Environment variables:"
@echo " VERSION - Version string (default: git tag or v1.0.0)"
@echo " BUILD_NUMBER- Build number (default: git short hash)"
@echo " GIT_HASH - Full git hash (default: git rev-parse HEAD)"
@echo ""
@echo "Examples:"
@echo " make run # Build and run with default version"
@echo " make run VERSION=v1.2.0 # Build and run with specific version"
@echo " make dmg # Create DMG for distribution"
version-info:
@echo "Current version information:"
@echo " Version: $(VERSION)"
@echo " Build: $(BUILD_NUMBER)"
@echo " Git Hash: $(GIT_HASH)"
@echo " Git Hash (short): $(shell echo $(GIT_HASH) | cut -c1-7)"
clean:
@echo "🧹 Cleaning build artifacts..."
rm -rf $(BUILD_DIR)
xcodebuild clean -scheme $(SCHEME) -configuration $(CONFIGURATION)
# Update Info.plist with version information
update-version:
@echo "📝 Updating version information..."
@echo " Version: $(VERSION)"
@echo " Build: $(BUILD_NUMBER)"
@echo " Git Hash: $(GIT_HASH)"
# Update Info.plist with version and build number
plutil -replace CFBundleShortVersionString -string "$(VERSION)" A6Cutter/Info.plist
plutil -replace CFBundleVersion -string "$(BUILD_NUMBER)" A6Cutter/Info.plist
# Add git hash to Info.plist
plutil -replace GitHash -string "$(GIT_HASH)" A6Cutter/Info.plist
@echo "✅ Version information updated in Info.plist"
build: update-version
@echo "🔨 Building $(APP_NAME)..."
xcodebuild -scheme $(SCHEME) -configuration $(CONFIGURATION) -destination $(DESTINATION) build
@echo "✅ Build completed successfully!"
@echo "📱 App location: $(APP_PATH)"
run: build
@echo "🚀 Running $(APP_NAME)..."
@if [ -z "$(APP_PATH)" ] || [ ! -d "$(APP_PATH)" ]; then \
echo "❌ App not found at expected location"; \
echo "📱 Searching for app..."; \
APP_PATH=$$(find /Users/$(USER)/Library/Developer/Xcode/DerivedData -name "$(APP_NAME).app" -path "*/Build/Products/$(CONFIGURATION)/*" 2>/dev/null | head -1); \
if [ -z "$$APP_PATH" ]; then \
echo "❌ App not found. Please run 'make build' first."; \
exit 1; \
fi; \
echo "📱 Found app at: $$APP_PATH"; \
open "$$APP_PATH"; \
else \
echo "📱 Opening app at: $(APP_PATH)"; \
open "$(APP_PATH)"; \
fi
install: build
@echo "📦 Installing $(APP_NAME) to Applications..."
@if [ -z "$(APP_PATH)" ] || [ ! -d "$(APP_PATH)" ]; then \
echo "❌ App not found at expected location"; \
echo "📱 Searching for app..."; \
APP_PATH=$$(find /Users/$(USER)/Library/Developer/Xcode/DerivedData -name "$(APP_NAME).app" -path "*/Build/Products/$(CONFIGURATION)/*" 2>/dev/null | head -1); \
if [ -z "$$APP_PATH" ]; then \
echo "❌ App not found. Please run 'make build' first."; \
exit 1; \
fi; \
fi
@echo "📱 Installing from: $(APP_PATH)"
cp -R "$(APP_PATH)" /Applications/
@echo "✅ $(APP_NAME) installed to /Applications/"
dmg: build
@echo "💿 Creating DMG..."
# Create DMG directory structure
mkdir -p $(DMG_DIR)
# Copy the built app
cp -R $(APP_PATH) $(DMG_DIR)/
# Create Applications shortcut (symlink)
ln -s /Applications $(DMG_DIR)/Applications
# Create installation instructions
echo "Drag $(APP_NAME).app to Applications folder" > $(DMG_DIR)/README.txt
# Create DMG
hdiutil create -volname "$(APP_NAME)" -srcfolder $(DMG_DIR) -ov -format UDZO $(BUILD_DIR)/$(APP_NAME).dmg
@echo "✅ DMG created: $(BUILD_DIR)/$(APP_NAME).dmg"
# Development helpers
dev-build: update-version
@echo "🔨 Development build..."
xcodebuild -scheme $(SCHEME) -configuration Debug -destination $(DESTINATION) build
@echo "✅ Development build completed!"
dev-run: dev-build
@echo "🚀 Running development build..."
open /Users/$(USER)/Library/Developer/Xcode/DerivedData/$(APP_NAME)-*/Build/Products/Debug/$(APP_NAME).app
# Quick version update without full build
quick-version: update-version
@echo "✅ Version information updated. Run 'make build' to rebuild with new version."
# Show current git status
git-status:
@echo "📊 Git status:"
@echo " Current branch: $(shell git branch --show-current)"
@echo " Latest commit: $(shell git log -1 --oneline)"
@echo " Uncommitted changes: $(shell git status --porcelain | wc -l | tr -d ' ') files"
# Create a release build with proper versioning
release: clean version-info build dmg
@echo "🎉 Release build completed!"
@echo "📦 DMG: $(BUILD_DIR)/$(APP_NAME).dmg"
@echo "📱 App: $(APP_PATH)"