-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
239 lines (208 loc) · 8.22 KB
/
Makefile
File metadata and controls
239 lines (208 loc) · 8.22 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
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
# ChaOS Build System — Makefile
# Custom GrapheneOS builds for Pixel 9 Pro XL (komodo)
#
# Prerequisites:
# sudo apt install qemu-user-static binfmt-support docker.io docker-compose-v2
# sudo systemctl restart binfmt-support
SHELL := /bin/bash
.DEFAULT_GOAL := help
DEVICE := komodo
INCLUDE_FLOCKYOU ?= true
INCLUDE_WIRETAP ?= true
INCLUDE_LIVEWALLPAPER ?= true
NPROC := $(shell nproc)
JOBS := $(shell echo $$(( $(NPROC) + 2 )))
BUILDER_UID := $(shell id -u)
BUILDER_GID := $(shell id -g)
COMPOSE := BUILDER_UID=$(BUILDER_UID) BUILDER_GID=$(BUILDER_GID) docker compose
EXEC := $(COMPOSE) exec -T chaos-builder bash -c
EXEC_IT := $(COMPOSE) exec chaos-builder bash
# GrapheneOS tag to sync — override with: make sync TAG=2025021900
TAG ?= 2026021200
GRAPHENEOS_REPO := https://github.com/GrapheneOS/platform_manifest.git
export BUILDER_UID BUILDER_GID
# ==============================================================================
# Primary targets
# ==============================================================================
ALL_TARGETS := init sync keys bootanimation wallpaper sounds build sign
ifeq ($(INCLUDE_FLOCKYOU),true)
ALL_TARGETS := init sync keys bootanimation wallpaper sounds flockyou build sign
endif
ifeq ($(INCLUDE_WIRETAP),true)
ALL_TARGETS := $(filter-out build sign,$(ALL_TARGETS)) wiretap kernel-wiretap build sign
endif
ifeq ($(INCLUDE_LIVEWALLPAPER),true)
ALL_TARGETS := $(filter-out build sign,$(ALL_TARGETS)) livewallpaper build sign
endif
.PHONY: all
all: $(ALL_TARGETS) ## Full pipeline: init → sync → keys → bootanimation → wallpaper → sounds → [flockyou] → [livewallpaper] → build → sign
.PHONY: setup
setup: ## Build Docker image and create directory structure
@echo "==> Building ChaOS build environment..."
mkdir -p src keys out assets/bootanimation/parts/{part0,part1} config
$(COMPOSE) build
@echo "==> Starting container..."
$(COMPOSE) up -d
@echo "==> Setup complete."
.PHONY: init
init: _ensure-container ## Initialize repo with GrapheneOS manifest
@echo "==> Initializing GrapheneOS source tree..."
$(EXEC) ' \
cd /src && \
if [ ! -d .repo ]; then \
repo init -u $(GRAPHENEOS_REPO) -b refs/tags/$(TAG) --depth=1; \
else \
echo "Repo already initialized. Use make sync to update."; \
fi \
'
.PHONY: sync
sync: _ensure-container ## Sync all source repositories
@echo "==> Syncing source tree ($(JOBS) jobs)..."
$(EXEC) ' \
cd /src && \
repo sync -j8 --current-branch --no-tags --optimized-fetch --force-sync \
'
@echo "==> Sync complete."
.PHONY: keys
keys: _ensure-container ## Generate signing keys (one-time)
@echo "==> Generating signing keys..."
$(COMPOSE) exec chaos-builder bash /scripts/generate-keys.sh
@echo "==> Keys generated in keys/$(DEVICE)/"
.PHONY: bootanimation
bootanimation: _ensure-container ## Generate boot animation zip from frames
@echo "==> Generating ChaOS boot animation..."
$(EXEC) 'bash /scripts/generate-bootanimation.sh'
@echo "==> Boot animation ready: assets/bootanimation/bootanimation.zip"
.PHONY: flockyou
flockyou: ## Build Flock-You OEM APK in Docker
ifeq ($(INCLUDE_FLOCKYOU),true)
bash scripts/build-flockyou.sh
else
@echo "==> Flock-You excluded (INCLUDE_FLOCKYOU=false)"
endif
.PHONY: wiretap
wiretap: ## Build Wiretap daemon + eBPF objects in Docker
ifeq ($(INCLUDE_WIRETAP),true)
bash scripts/build-wiretap.sh
else
@echo "==> Wiretap excluded (INCLUDE_WIRETAP=false)"
endif
.PHONY: kernel-wiretap
kernel-wiretap: _ensure-container ## Patch kernel defconfig for eBPF support
ifeq ($(INCLUDE_WIRETAP),true)
@echo "==> Patching kernel for eBPF support..."
$(EXEC) 'bash /scripts/patch-kernel-ebpf.sh'
else
@echo "==> Wiretap excluded (INCLUDE_WIRETAP=false)"
endif
.PHONY: wallpaper
wallpaper: _ensure-container ## Generate dark navy static wallpaper
@echo "==> Generating ChaOS wallpaper..."
$(EXEC) 'bash /scripts/generate-wallpaper.sh'
@echo "==> Wallpaper ready: assets/wallpaper/default_wallpaper.png"
.PHONY: sounds
sounds: _ensure-container ## Generate system sounds (ringtone, notification, alarm)
@echo "==> Generating ChaOS system sounds..."
$(EXEC) 'bash /scripts/generate-sounds.sh'
@echo "==> Sounds ready: assets/sounds/"
.PHONY: livewallpaper
livewallpaper: _ensure-container ## Generate live wallpaper video
ifeq ($(INCLUDE_LIVEWALLPAPER),true)
@echo "==> Generating ChaOS live wallpaper video..."
$(EXEC) 'bash /scripts/generate-live-wallpaper-video.sh'
@echo "==> Live wallpaper video ready: assets/livewallpaper/chaos_live_bg.mp4"
else
@echo "==> Live wallpaper excluded (INCLUDE_LIVEWALLPAPER=false)"
endif
.PHONY: dev-build
dev-build: _ensure-container ## Development build with ADB enabled and userdebug variant
@echo "==> Starting ChaOS DEV build for $(DEVICE) with -j$(JOBS)..."
$(EXEC) 'JOBS=$(JOBS) CHAOS_DEV_BUILD=1 BUILD_VARIANT=userdebug bash /scripts/build.sh'
@echo "==> Dev build complete. Output in out/"
.PHONY: build
build: _ensure-container ## Full build inside Docker container
@echo "==> Starting ChaOS build for $(DEVICE) with -j$(JOBS)..."
$(EXEC) 'JOBS=$(JOBS) bash /scripts/build.sh'
@echo "==> Build complete. Output in out/"
.PHONY: sign
sign: _ensure-container ## Sign build artifacts with custom keys
@echo "==> Signing build artifacts..."
$(EXEC) ' \
cd /src && \
source build/envsetup.sh && \
lunch $(DEVICE)-cur-user && \
mkdir -p out/release-$(DEVICE) && \
sign_target_files_apks -o -d /keys/$(DEVICE) \
out/target/product/$(DEVICE)/obj/PACKAGING/target_files_intermediates/*-target_files*.zip \
out/release-$(DEVICE)/signed-target_files.zip && \
ota_from_target_files -k /keys/$(DEVICE)/releasekey \
out/release-$(DEVICE)/signed-target_files.zip \
out/release-$(DEVICE)/ChaOS-$(DEVICE)-ota_update.zip && \
img_from_target_files \
out/release-$(DEVICE)/signed-target_files.zip \
out/release-$(DEVICE)/ChaOS-$(DEVICE)-factory.zip \
'
@echo "==> Signed artifacts in out/release-$(DEVICE)/"
.PHONY: flash
flash: ## Flash to connected Pixel 9 Pro XL
@echo "==> Flashing ChaOS to $(DEVICE)..."
bash scripts/flash.sh
@echo "==> Flash complete."
# ==============================================================================
# Utility targets
# ==============================================================================
.PHONY: shell
shell: _ensure-container ## Drop into an interactive shell in the build container
$(EXEC_IT)
.PHONY: clean
clean: ## Remove out/ directory
@echo "==> Cleaning build output..."
rm -rf out/*
@echo "==> Clean complete."
.PHONY: mrproper
mrproper: ## Remove out/, ccache, and source tree
@echo "==> Deep clean: removing out/, ccache, source tree..."
$(COMPOSE) down -v 2>/dev/null || true
rm -rf out/* src/*
docker volume rm chaos-ccache 2>/dev/null || true
@echo "==> Deep clean complete."
.PHONY: status
status: _ensure-container ## Show build environment status
@echo "==> Container status:"
@$(COMPOSE) ps
@echo ""
@echo "==> ccache stats:"
@$(EXEC) 'ccache -s' 2>/dev/null || echo " (container not running)"
@echo ""
@echo "==> Disk usage:"
@du -sh src/ out/ keys/ 2>/dev/null || true
.PHONY: stop
stop: ## Stop the build container
$(COMPOSE) down
.PHONY: help
help: ## Show this help
@echo "ChaOS Build System — Custom GrapheneOS for Pixel 9 Pro XL ($(DEVICE))"
@echo ""
@echo "Prerequisites:"
@echo " sudo apt install qemu-user-static binfmt-support docker.io docker-compose-v2"
@echo " sudo systemctl restart binfmt-support"
@echo ""
@echo "Targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-16s\033[0m %s\n", $$1, $$2}'
@echo ""
@echo "Usage:"
@echo " make setup # First time: build Docker image"
@echo " make all # Full build pipeline"
@echo " make build # Incremental rebuild"
@echo " make flash # Flash to device"
@echo " make TAG=2025030100 init sync # Use specific GrapheneOS tag"
# ==============================================================================
# Internal targets
# ==============================================================================
.PHONY: _ensure-container
_ensure-container:
@if ! $(COMPOSE) ps --status running 2>/dev/null | grep -q chaos-builder; then \
echo "==> Starting build container..."; \
$(COMPOSE) up -d; \
fi