-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
120 lines (105 loc) · 3.99 KB
/
Makefile
File metadata and controls
120 lines (105 loc) · 3.99 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
.PHONY: help build-all build-deb build-windows clean test download-import-map compile-and-test
help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Available targets:'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
build-all: compile-and-test build-deb build-windows ## Build and test, then create packages
build-deb: build-jammy build-bookworm ## Build all DEB packages
build-jammy: compile-local prepare-src ## Build DEB package for Ubuntu Jammy
@echo "Building DEB package for Ubuntu Jammy..."
docker buildx build \
--target jammy \
--output type=local,dest=./output/jammy \
-f dalec-spry.yaml \
.
build-bookworm: compile-local prepare-src ## Build DEB package for Debian Bookworm
@echo "Building DEB package for Debian Bookworm..."
docker buildx build \
--target bookworm \
--output type=local,dest=./output/bookworm \
-f dalec-spry.yaml \
.
download-deps: ## Download import_map.json and deno.jsonc from Spry repository
@if [ ! -f import_map.json ]; then \
echo "Downloading import_map.json..."; \
curl -H "Authorization: Bearer $${GH_TOKEN}" -o import_map.json https://raw.githubusercontent.com/programmablemd/spry/refs/heads/main/import_map.json; \
echo "✅ import_map.json downloaded"; \
else \
echo "✅ import_map.json already exists"; \
fi
@if [ ! -f deno.jsonc ]; then \
echo "Downloading deno.jsonc..."; \
curl -H "Authorization: Bearer $${GH_TOKEN}" -o deno.jsonc https://raw.githubusercontent.com/programmablemd/spry/refs/heads/main/deno.jsonc; \
echo "✅ deno.jsonc downloaded"; \
else \
echo "✅ deno.jsonc already exists"; \
fi
build-windows: download-deps spry.ts ## Build Windows package (native Deno compilation)
@echo "Compiling spry for Windows..."
@if [ ! -f spry.exe ] || [ spry.ts -nt spry.exe ]; then \
sed 's/__BAKED_GH_TOKEN__/'$${GH_TOKEN}'/g' spry.ts > spry.build.ts; \
deno compile \
--allow-all \
--include web-ui \
--target x86_64-pc-windows-msvc \
--output=spry.exe \
spry.build.ts; \
rm spry.build.ts; \
fi
@echo "Packaging Windows binary..."
mkdir -p output
zip output/spry-windows.zip spry.exe
@echo "✅ Windows package created: output/spry-windows.zip"
compile-local: download-deps spry.ts ## Compile spry locally with Deno
@if [ ! -f spry ] || [ spry.ts -nt spry ]; then \
echo "Compiling spry..."; \
sed 's/__BAKED_GH_TOKEN__/'$${GH_TOKEN}'/g' spry.ts > spry.build.ts; \
deno compile \
--allow-all \
--include web-ui \
--output=spry \
spry.build.ts; \
rm spry.build.ts; \
echo "✅ Done! Binary created: ./spry"; \
else \
echo "✅ Binary is up to date: ./spry"; \
fi
prepare-src: compile-local ## Prepare src directory for DALEC
@echo "Preparing src directory for DALEC..."
@mkdir -p src/src/man
@cp spry src/src/spry
@cp man/spry.1 src/src/man/spry.1
@chmod +x src/src/spry
@echo "✅ Binary prepared in src/src/ directory"
test: compile-local ## Test the compiled binary with comprehensive tests
@echo "Running binary validation tests..."
@chmod +x scripts/test-binary.sh
@scripts/test-binary.sh ./spry
compile-and-test: compile-local test ## Compile and run tests
@echo "✅ Build and test complete!"
clean: ## Clean build artifacts
@echo "Cleaning build artifacts..."
rm -rf output/
rm -rf src/
rm -f spry
rm -f spry.exe
rm -f spry-*
@echo "✅ Clean complete."
install: ## Install spry locally (requires sudo)
@echo "Installing spry to /usr/local/bin..."
sudo cp spry /usr/local/bin/spry
sudo chmod +x /usr/local/bin/spry
@echo "Installing man page..."
sudo mkdir -p /usr/local/share/man/man1
sudo cp man/spry.1 /usr/local/share/man/man1/spry.1
@echo "Updating man database..."
sudo mandb
@echo "Installation complete. Run 'spry --help' to verify."
uninstall: ## Uninstall spry from system
@echo "Uninstalling spry..."
sudo rm -f /usr/local/bin/spry
sudo rm -f /usr/local/share/man/man1/spry.1
@echo "Updating man database..."
sudo mandb
@echo "Uninstall complete."