Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
122 lines (105 loc) · 5.23 KB
/
Copy pathMakefile
File metadata and controls
122 lines (105 loc) · 5.23 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
.PHONY: build build-ipad build-macos build-release-unsigned clean generate-appicons generate-build-info lint lint-fix-safe reset-all reset-defaults reset-perms test
# SwiftLint: https://github.com/realm/SwiftLint - `brew install swiftlint`
SWIFTLINT ?= $(shell command -v swiftlint 2>/dev/null)
PROJECT := Consolation.xcodeproj
SCHEME := Consolation
APP_NAME := Consolation
BUNDLE_ID ?= org.centennialoss.consolation
DERIVED_DATA := build/DerivedData
DIST_DERIVED_DATA := dist/DerivedData
APPICON_DIR := Consolation/Assets.xcassets/AppIcon.appiconset
APPICON_SRC := $(APPICON_DIR)/AppIcon_1024.png
APPICON_SIZES := 16 32 64 128 256 512
APPICON_BG := assets/app-icon-background-large.png
APPICON_TRANSPARENT_SRC := assets/app-icon-large-transparent.png
APPICON_LARGE := assets/app-icon-large.png
APPICON_PREVIEW := assets/app-icon.png
BUILD_INFO := Consolation/AppData/BuildInfo.generated.swift
COMMIT ?= $(shell git rev-parse HEAD 2>/dev/null || echo local)
DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%S.000Z")
CONFIG ?= Debug
ARCH ?= arm64
lint:
@if [ -z "$(SWIFTLINT)" ]; then \
echo "SwiftLint not found. Install with: brew install swiftlint" >&2; \
exit 1; \
fi
@"$(SWIFTLINT)" lint --strict $(FIX_PATHS)
# Autocorrect only low-risk rules (whitespace / file hygiene). Still review `git diff` and run tests.
# Optional: pass paths, e.g. `make lint-fix-safe FIX_PATHS="Consolation/ContentView.swift"`
FIX_PATHS ?= Consolation ConsolationTests ConsolationUITests
lint-fix-safe:
@if [ -z "$(SWIFTLINT)" ]; then \
echo "SwiftLint not found. Install with: brew install swiftlint" >&2; \
exit 1; \
fi
@"$(SWIFTLINT)" lint --fix \
--only-rule trailing_whitespace \
--only-rule trailing_newline \
--only-rule leading_whitespace \
--only-rule trailing_semicolon \
$(FIX_PATHS)
clean:
rm -rf build dist
build: test build-macos build-ipad
build-macos:
mkdir -p build
xcodebuild -project $(PROJECT) -scheme $(SCHEME) -configuration Debug -derivedDataPath $(DERIVED_DATA) -destination 'platform=macOS' build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
cp -R "$(DERIVED_DATA)/Build/Products/Debug/$(APP_NAME).app" build/
build-ipad:
mkdir -p build
xcodebuild -project $(PROJECT) -scheme $(SCHEME) -configuration Debug -derivedDataPath $(DERIVED_DATA) -destination 'generic/platform=iOS Simulator' build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
cp -R "$(DERIVED_DATA)/Build/Products/Debug-iphonesimulator/$(APP_NAME).app" "build/$(APP_NAME)-iPad.app"
build-release-unsigned:
mkdir -p dist
xcodebuild -project $(PROJECT) -scheme $(SCHEME) -configuration Release -derivedDataPath $(DIST_DERIVED_DATA) build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
cp -R "$(DIST_DERIVED_DATA)/Build/Products/Release/$(APP_NAME).app" dist/
generate-build-info:
@printf '%s\n' \
'// Generated by make generate-build-info.' \
'// Do not edit this file by hand.' \
'' \
'enum BuildInfoGenerated {' \
' static let buildCommit = "$(COMMIT)"' \
' static let buildDate = "$(DATE)"' \
' static let buildConfiguration = "$(CONFIG)"' \
' static let buildArch = "$(ARCH)"' \
'}' > $(BUILD_INFO)
# Run unit tests (lint first). UI tests are intentionally excluded because they
# launch and control the app on the active macOS desktop.
test: lint
mkdir -p build
xcodebuild -project $(PROJECT) -scheme $(SCHEME) -configuration Debug -derivedDataPath $(DERIVED_DATA) -destination 'platform=macOS' test -only-testing:ConsolationTests CODE_SIGN_IDENTITY="-" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=YES
# Generate app icon assets:
# 1. Composite assets/app-icon-large-transparent.png over assets/app-icon-background-large.png
# -> assets/app-icon-large.png
# 2. Resize the composite into the AppIcon asset catalog for macOS and iOS.
# 3. Copy the generated 128x128 icon to assets/app-icon.png for docs/branding use.
generate-appicons:
@test -f $(APPICON_BG) || (echo "Missing: $(APPICON_BG)" && exit 1)
@test -f $(APPICON_TRANSPARENT_SRC) || (echo "Missing: $(APPICON_TRANSPARENT_SRC)" && exit 1)
@echo "Compositing app-icon-large-transparent.png onto app-icon-background-large.png -> app-icon-large.png"
@swift scripts/composite-app-icon.swift $(APPICON_BG) $(APPICON_TRANSPARENT_SRC) $(APPICON_LARGE)
@cp $(APPICON_LARGE) $(APPICON_SRC)
@for size in $(APPICON_SIZES); do \
echo "Creating AppIcon_$$size.png from AppIcon_1024.png"; \
if [ "$$size" = "16" ]; then \
sips --cropToHeightWidth 780 780 $(APPICON_SRC) --out /tmp/AppIcon_crop.png && \
sips -z 16 16 /tmp/AppIcon_crop.png --out $(APPICON_DIR)/AppIcon_16.png; \
elif [ "$$size" = "32" ]; then \
sips --cropToHeightWidth 880 880 $(APPICON_SRC) --out /tmp/AppIcon_crop.png && \
sips -z 32 32 /tmp/AppIcon_crop.png --out $(APPICON_DIR)/AppIcon_32.png; \
else \
sips -z $$size $$size --out $(APPICON_DIR)/AppIcon_$$size.png $(APPICON_SRC); \
fi; \
done
@cp $(APPICON_DIR)/AppIcon_128.png $(APPICON_PREVIEW)
@rm -f /tmp/AppIcon_crop.png
@echo "Done writing AppIcons and $(APPICON_PREVIEW)"
reset-perms:
@tccutil reset Camera $(BUNDLE_ID)
@tccutil reset Microphone $(BUNDLE_ID)
reset-defaults:
@defaults delete $(BUNDLE_ID) 2>/dev/null || true
@echo "Reset UserDefaults for $(BUNDLE_ID)"
reset-all: reset-perms reset-defaults