-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
104 lines (86 loc) · 2.43 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
# Error Handling
SHELL := /bin/bash
.SHELLFLAGS := -o pipefail -c
# Name of this Makefile
MAKEFILE_NAME := $(lastword $(MAKEFILE_LIST))
# Special targets that should not be listed
EXCLUDE_LIST := menu .PHONY
# Function to extract targets from the Makefile
define extract_targets
$(shell awk -F: '/^[a-zA-Z0-9_-]+:/ {print $$1}' $(MAKEFILE_NAME) | grep -v -E '^($(EXCLUDE_LIST))$$')
endef
TARGETS := $(call extract_targets)
.PHONY: $(TARGETS) menu all help venv install run bundle bundleWithOutModels ci compressBundle downloadModels
menu: ## Makefile Interactive Menu
@# Check if fzf is installed
@if command -v fzf >/dev/null 2>&1; then \
echo "Using fzf for selection..."; \
echo "$(TARGETS)" | tr ' ' '\n' | fzf > .selected_target; \
target_choice=$$(cat .selected_target); \
else \
echo "fzf not found, using numbered menu:"; \
echo "$(TARGETS)" | tr ' ' '\n' > .targets; \
awk '{print NR " - " $$0}' .targets; \
read -p "Enter choice: " choice; \
target_choice=$$(awk 'NR == '$$choice' {print}' .targets); \
fi; \
if [ -n "$$target_choice" ]; then \
$(MAKE) $$target_choice; \
else \
echo "Invalid choice"; \
fi
venv:
@( \
test -d .venv || \
python3 -m venv .venv; \
echo "Virtual environment created"; \
)
install:
@( \
source .venv/bin/activate; \
pip install -U -r requirements.txt; \
if [ "$(shell uname)" == "Darwin" ]; then \
$(MAKE) installBrew; \
fi; \
)
installBrew:
@( \
brew install python-tk; \
)
run:
@( \
source .venv/bin/activate; \
python3 superprompter.py; \
)
bundle:
@( \
source .venv/bin/activate; \
python download_models.py; \
python3 bundle.py --include-models; \
)
bundleWithOutModels:
@( \
rm -f *.spec; \
source .venv/bin/activate; \
python bundle.py; \
)
downloadModels:
@( \
source .venv/bin/activate; \
python download_models.py; \
)
compressBundle:
# tar gz the SuperPrompter.app directory and the dist/SuperPrompter linux executable
@( \
if [ -f dist/SuperPrompter.app ]; then \
tar -czvf dist/SuperPrompter.app.tar.gz dist/SuperPrompter.app; \
fi; \
if [ -f dist/SuperPrompter ]; then \
tar -czvf dist/SuperPrompter.linux.tar.gz dist/SuperPrompter; \
fi; \
)
help: ## This help function
@egrep '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
all: venv install run
ci: venv install bundleWithOutModels compressBundle
.DEFAULT_GOAL := menu