-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
408 lines (369 loc) · 14.9 KB
/
Makefile
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
SHELL := /bin/zsh
# Text colors
BLACK := \033[30m
RED := \033[31m
GREEN := \033[32m
YELLOW := \033[33m
BLUE := \033[34m
MAGENTA := \033[35m
CYAN := \033[36m
WHITE := \033[37m
GRAY := \033[90m
# Background colors
BG_BLACK := \033[40m
BG_RED := \033[41m
BG_GREEN := \033[42m
BG_YELLOW := \033[43m
BG_BLUE := \033[44m
BG_MAGENTA := \033[45m
BG_CYAN := \033[46m
BG_WHITE := \033[47m
# Text styles
BOLD := \033[1m
DIM := \033[2m
ITALIC := \033[3m
UNDERLINE := \033[4m
# Reset
NC := \033[0m
CHECK := $(GREEN)✓$(NC)
CROSS := $(RED)✗$(NC)
DASH := $(GRAY)-$(NC)
.PHONY: help check-os install-all install-flutter install-android install-ios check-deps setup-web doctor check-arch check-shell check-environment check-base-environment check-rosetta check-status install-zsh install-rosetta install-xcode install-homebrew install-cocoapods install-git install-android-studio install-vscode setup-flutter-path install-java
.DEFAULT_GOAL := help
# Add this helper function
define execute
@if [ "$(DRY_RUN)" = "true" ]; then \
echo "$(1)"; \
else \
$(1); \
fi
endef
# Print help options and examples
define print-help
@echo "Options:"
@echo " DRY_RUN=true # Dry run (prints commands without executing)"
@echo " FORCE=true # Force installation (reinstalls even if already present)"
@echo " FLUTTER_HOME=$(HOME)/flutter # Set the Flutter home directory"
@echo ""
@echo "Examples:"
@echo " # Force installation (reinstalls even if already present)"
@echo -e " ${BLUE}make install-vscode FORCE=true${NC}"
@echo ""
@echo " # Install all dependencies (skips existing installations)"
@echo -e " ${BLUE}make install-all${NC}"
@echo ""
@echo " # Force install all dependencies"
@echo -e " ${BLUE}make install-all FORCE=true${NC}"
@echo ""
@echo " # Combine with DRY_RUN to see what would happen"
@echo -e " ${BLUE}make install-all FORCE=true DRY_RUN=true${NC}"
endef
help: ## Display this help screen
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "$(CYAN)%-30s$(NC) %s\n", $$1, $$2}'
@echo ""
@$(call print-help)
@echo ""
@echo -e "Main Target:"
@echo -e " ${BLUE}make check-status${NC}"
@echo -e " ${GRAY}Check if all required components are installed${NC}"
@echo -e " ${BLUE}make install-all${NC}"
@echo -e " ${GRAY}Install all dependencies${NC}"
# Add this near the top with your other variable definitions
DRY_RUN ?= false
FORCE ?= false
check-os: ## Verify this is running on macOS
@if [ "$$(uname)" != "Darwin" ]; then \
echo "This Makefile is intended for macOS only"; \
exit 1; \
fi
check-arch: ## Check if running on Apple Silicon
@if [ "$$(uname -m)" = "arm64" ]; then \
echo "Running on Apple Silicon"; \
else \
echo "Running on Intel Mac"; \
fi
check-shell: ## Check if using ZSH shell
@echo "SHELL: $$SHELL"
@shell_process=$$(ps -p $$$$ -o comm=); \
if [ "$$SHELL" = "/bin/zsh" ] && { [ "$$shell_process" = "/bin/zsh" ] || [ "$$shell_process" = "zsh" ]; }; then \
echo -e "[$(CHECK)] Using ZSH shell"; \
else \
echo -e "[$(CROSS)] Not using ZSH shell (required to switch to ZSH)"; \
echo "Current shell ($$SHELL): $$shell_process"; \
exit 1; \
fi
check-base-environment: check-os check-shell ## Check complete environment (OS, Shell)
@echo "Environment check complete"
check-rosetta: ## Check Rosetta 2 installation status on Apple Silicon
@if [ "$$(uname -m)" = "arm64" ]; then \
if pkgutil --pkg-info com.apple.pkg.RosettaUpdateAuto > /dev/null 2>&1; then \
echo "Rosetta 2 is installed"; \
else \
echo "Rosetta 2 is not installed"; \
exit 1; \
fi \
else \
echo "Rosetta 2 check skipped - not running on Apple Silicon"; \
fi
check-environment: check-os check-arch check-shell check-rosetta ## Check complete environment (OS, Architecture, Shell, Rosetta)
@echo "Environment check complete"
# Define check_command macro - checks if a command exists
define check_command
@if which $(1) > /dev/null 2>&1; then \
printf "[$(CHECK)] $(2)\n"; \
else \
printf "[$(CROSS)] $(2) ($(GREEN)make $(3)$(NC))\n"; \
fi
endef
# Define check_app macro - checks if an app exists in /Applications
define check_app
@if [ -d "/Applications/$(1)" ] || [ -d "/Applications/$(1).app" ]; then \
printf "[$(CHECK)] $(2)\n"; \
else \
printf "[$(CROSS)] $(2) ($(GREEN)make $(3)$(NC))\n"; \
fi
endef
# Define check_command_or_app macro - checks if either command exists or app is installed
define check_command_or_app
@if which $(1) > /dev/null 2>&1 || [ -d "/Applications/$(2)" ] || [ -d "/Applications/$(2).app" ]; then \
printf "[$(CHECK)] $(3)\n"; \
else \
printf "[$(CROSS)] $(3) ($(GREEN)make $(4)$(NC))\n"; \
fi
endef
define check_flutter_doctor
@if which flutter > /dev/null 2>&1; then \
printf "[$(CHECK)] Flutter\n"; \
echo "Running Flutter doctor..."; \
flutter doctor -v; \
else \
if [ "$(1)" != "PASS" ]; then \
printf "[$(CROSS)] Flutter ($(GREEN)make install-flutter$(NC))\n"; \
echo "Cannot run Flutter doctor - Flutter is not installed."; \
fi; \
fi
endef
#
check-status: check-shell ## Display status of all required components with checkmarks
@echo "=== System Requirements Status ==="
@# Check macOS
@if [ "$$(uname)" = "Darwin" ]; then \
printf "[$(CHECK)] macOS\n"; \
else \
printf "[$(CROSS)] macOS ($(GREEN)System requirement - must use macOS$(NC))\n"; \
fi
$(call check_command,zsh,ZSH Shell,install-zsh)
$(call check_command,brew,Homebrew,install-homebrew)
@if [ "$$(uname -m)" = "arm64" ]; then \
if pkgutil --pkg-info com.apple.pkg.RosettaUpdateAuto > /dev/null 2>&1; then \
printf "[$(CHECK)] Rosetta 2\n"; \
else \
printf "[$(CROSS)] Rosetta 2 ($(GREEN)make install-rosetta$(NC))\n"; \
fi; \
else \
printf "[$(DASH)] Rosetta 2 (Not Required - Intel Mac)\n"; \
fi
$(call check_command,xcode-select,Xcode Command Line Tools,install-xcode)
$(call check_command,pod,CocoaPods,install-cocoapods)
$(call check_command,git,git,install-git)
$(call check_app,Android Studio.app,Android Studio,install-android-studio)
$(call check_command_or_app,code,Visual Studio Code,Visual Studio Code,install-vscode)
$(call check_command,flutter,Flutter,install-flutter)
$(call check_flutter_doctor,PASS)
@echo ""
@echo "${RED}Run manual steps recommended by flutter doctor${NC}"
@echo ""
@echo "Example:"
@echo -e " ${BLUE}make install-git FORCE=true DRY_RUN=true${NC}"
install-zsh: ## Set ZSH as the default shell
@echo "Setting ZSH as default shell..."
$(call execute,if [ "$$SHELL" != "/bin/zsh" ]; then \
chsh -s /bin/zsh; \
echo "ZSH set as default shell. Please restart your terminal."; \
else \
echo "ZSH is already the default shell."; \
fi)
install-rosetta: check-os ## Install Rosetta 2 for Apple Silicon Macs
@echo "Installing Rosetta 2..."
$(call execute,if [ "$$(uname -m)" = "arm64" ]; then \
if ! pkgutil --pkg-info com.apple.pkg.RosettaUpdateAuto > /dev/null 2>\&1; then \
softwareupdate --install-rosetta --agree-to-license; \
echo "Rosetta 2 installed successfully."; \
else \
echo "Rosetta 2 is already installed."; \
fi; \
else \
echo "Rosetta 2 is not needed on Intel Macs."; \
fi)
install-xcode: check-os ## Install Xcode Command Line Tools
@echo "Installing Xcode Command Line Tools..."
$(call execute,if ! xcode-select -p > /dev/null 2>&1; then \
xcode-select --install; \
echo "Please wait for the Xcode Command Line Tools installation to complete."; \
echo "A system dialog may have opened requesting permission."; \
else \
echo "Xcode Command Line Tools are already installed."; \
fi)
install-homebrew: check-base-environment ## Install Homebrew
@echo "Checking Homebrew installation..."
$(call execute,if [ "$(FORCE)" = "true" ] || ! which brew > /dev/null 2>&1; then \
echo "Installing Homebrew..."; \
/bin/bash -c "$$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; \
echo >> $(HOME)/.zprofile; \
echo 'eval "$$(/opt/homebrew/bin/brew shellenv)"' >> /Users/smorin/.zprofile ; \
eval "$$(/opt/homebrew/bin/brew shellenv)"; \
brew update; \
else \
echo "Homebrew is already installed. Use FORCE=true to reinstall."; \
fi)
install-cocoapods: install-homebrew ## Install CocoaPods
@echo "Checking CocoaPods installation..."
$(call execute,if [ "$(FORCE)" = "true" ] || ! which pod > /dev/null 2>&1; then \
echo "Installing CocoaPods..."; \
brew install cocoapods; \
else \
echo "CocoaPods is already installed. Use FORCE=true to reinstall."; \
fi)
install-git: install-homebrew ## Install homebrew
@echo "Checking git installation..."
$(call execute,if [ "$(FORCE)" = "true" ] || ! which git > /dev/null 2>&1; then \
echo "Installing git..."; \
brew install git; \
else \
echo "git is already installed. Use FORCE=true to reinstall."; \
fi)
install-android-studio: install-homebrew install-java## Install Android Studio
@echo "Checking Android Studio installation..."
$(call execute,if [ "$(FORCE)" = "true" ] || ! ls "/Applications/Android Studio.app" > /dev/null 2>&1; then \
echo "Installing Android Studio..."; \
echo ""; \
brew install --cask android-studio; \
echo ""; \
echo -e "${RED}1. MANUAL STEP NEXT - 1st${NC}"; \
echo ""; \
echo "Summary: install Android SDK"; \
echo "1. Open Android Studio."; \
echo "2. In Android Studio: click Configure > SDK Manager."; \
echo "3. In SDK Tools: check Show Package Details."; \
echo "4. Expand Android SDK Location and click Install Packages."; \
echo "5. Check Include Android SDK."; \
echo "6. Click Next and Install."; \
echo "7. Click Finish."; \
echo ""; \
open /Applications/Android\ Studio.app; \
echo ""; \
echo -e "${RED}2. MANUAL STEP NEXT - 2nd${NC}"; \
echo ""; \
echo "Summary: install command-line tools manually:"; \
echo "1. Open Android Studio"; \
echo "2. Click 'More Actions' > 'SDK Manager'"; \
echo "3. Select 'SDK Tools' tab"; \
echo "4. Check 'Android SDK Command-line Tools (latest)'"; \
echo "5. Click 'Apply' and accept the license"; \
echo -e "6. Run ${RED}make setup-java-path JAVA_HOME=\"/REPLACE/FLUTTER/PATH\"${NC}"; \
echo " Default:"; \
echo " ${YELLOW}/Applications/Android Studio.app/Contents/jbr/Contents/Home${NC}"; \
echo -e "7. Run ${RED}path/to/sdkmanager --install \"cmdline-tools;latest\"${NC}"; \
echo " Default:"; \
echo " ${YELLOW}/Users/$(USER)/Library/Android/sdk/cmdline-tools/latest/bin/sdkmanager${NC}"; \
echo "See https://developer.android.com/studio/command-line for more details."; \
echo -e "Run ${RED}flutter doctor --android-licenses${NC} to accept the SDK licenses."; \
else \
echo "Android Studio is already installed. Use FORCE=true to reinstall."; \
echo "To install command-line tools manually:"; \
echo "1. Open Android Studio"; \
echo "2. Click 'More Actions' > 'SDK Manager'"; \
echo "3. Select 'SDK Tools' tab"; \
echo "4. Check 'Android SDK Command-line Tools (latest)'"; \
echo "5. Click 'Apply' and accept the license"; \
fi)
setup-java-path: ## Setup Java PATH in .zshenv
@if [ -z "$(JAVA_HOME)" ]; then \
echo "JAVA_HOME is not set. Please set JAVA_HOME to the Java installation directory."; \
exit 1; \
fi
@echo "Setting up Java PATH... in file: $(HOME).zshenv"
@echo " Using JAVA_HOME: $(JAVA_HOME)"
$(call execute,if [ ! -f "$(HOME)/.zshenv" ]; then \
touch "$(HOME)/.zshenv"; \
fi)
$(call execute,if ! grep -q "export PATH=\$$PATH:\$$JAVA_HOME/bin" "$(HOME)/.zshenv"; then \
echo "export JAVA_HOME=\"$(JAVA_HOME)\"" >> "$(HOME)/.zshenv"; \
echo 'export PATH=$$PATH:$$JAVA_HOME/bin' >> "$(HOME)/.zshenv"; \
echo "Java PATH added to $(HOME)/.zshenv"; \
echo "Please restart your terminal or run: source $(HOME)/.zshenv"; \
else \
echo "Java PATH already exists in .zshenv"; \
fi)
install-vscode: ## Install Visual Studio Code
@echo "Checking Visual Studio Code installation..."
@echo "Installing Visual Studio Code..."
@echo "Please install Visual Studio Code manually:"
$(call execute,open "https://code.visualstudio.com/")
@echo "Please install the Flutter extension manually:"
$(call execute,open "https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter")
install-flutter: ## Instructions to prompt VS Code to install Flutter shoudl be run manually and use very clear language
@echo ""
@echo -e "${RED}Run manual steps${NC}"
@echo ""
@echo "Summary: You'll prompt VS Code to install Flutter and add to path."
@echo ""
@echo "1. Open VS Code."
@echo "2. Open the Command Palette, press Command + Shift + P."
@echo "3. Type flutter in the Command Palette."
@echo "4. Select Flutter: New Project."
@echo "5. VS Code prompts you to locate the Flutter SDK on your computer."
@echo " If you have the Flutter SDK installed, click Locate SDK."
@echo " If you do not have the Flutter SDK installed, click Download"
@echo " SDK. VS Code will download the Flutter SDK and add it "
@echo " to your PATH."
@echo " You can verify the Flutter SDK is in your PATH "
@echo " by running 'flutter' in your terminal."
@echo ""
@echo "For more information, see https://flutter.dev/docs/get-started/install/macos"
@echo ""
@echo "6. Copy the path. VS Code will present a button to copy the "
@echo " Flutter PATH to the clipboard."
@echo -e "7. ${BLUE}make setup-flutter-path FLUTTER_HOME=/REPLACE/FLUTTER/PATH${NC}"
# TODO: Need to validate if this is needed
#install-ios: check-os ## Setup iOS development environment and Xcode
# @echo "Setting up iOS development environment..."
# @xcode-select --install || true
# @sudo xcodebuild -license accept || true
# @pod setup
# Main installation target that depends on all other installations
install-all: check-os install-zsh install-rosetta install-xcode install-homebrew install-cocoapods install-git install-android-studio install-vscode install-flutter ## Install all dependencies
@echo "All dependencies installed successfully!"
setup-web: ## Enable Flutter web development support
@echo "Setting up web development..."
@flutter config --enable-web
setup-flutter-path: ## Setup Flutter PATH in .zshenv
@if [ -z "$(FLUTTER_HOME)" ]; then \
echo "FLUTTER_HOME is not set. Please set FLUTTER_HOME to the Flutter installation directory."; \
exit 1; \
fi
@echo "Setting up Flutter PATH... in file: $(HOME).zshenv"
@echo " Using FLUTTER_HOME: $(FLUTTER_HOME)"
$(call execute,if [ ! -f "$(HOME)/.zshenv" ]; then \
touch "$(HOME)/.zshenv"; \
fi)
$(call execute,if ! grep -q "export PATH=\$$PATH:\$$FLUTTER_HOME/bin" "$(HOME)/.zshenv"; then \
echo "export FLUTTER_HOME=\"$(FLUTTER_HOME)\"" >> "$(HOME)/.zshenv"; \
echo 'export PATH=$$PATH:$$FLUTTER_HOME/bin' >> "$(HOME)/.zshenv"; \
echo "Flutter PATH added to $(HOME)/.zshenv"; \
echo "Please restart your terminal or run: source $(HOME)/.zshenv"; \
else \
echo "Flutter PATH already exists in .zshenv"; \
fi)
play: ## use to test commands
@echo "play target: before macro"
$(call execute,echo "in macro"; \
if [ "true" = "true" ] ; then \
echo " /Users/$(USER)/Library/Android/sdk/cmdline-tools/latest/bin/sdkmanager"; \
else \
echo "nope"; \
fi)
echo "after macro"