-
-
Notifications
You must be signed in to change notification settings - Fork 221
/
Makefile
279 lines (245 loc) · 11.1 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
###########################################################
TARGET=Onion
VERSION=4.3.1-1
RA_SUBVERSION=1.15.0.13
###########################################################
ifneq ($(VERSION_OVERRIDE),)
VERSION = $(VERSION_OVERRIDE)
endif
RELEASE_NAME := $(TARGET)-v$(VERSION)
ifdef OS
current_dir := $(shell cd)
ROOT_DIR := $(subst \,/,$(current_dir))
makedir := mkdir
createfile := echo.>
else
ROOT_DIR := $(shell pwd)
makedir := mkdir -p
createfile := touch
endif
# Directories
SRC_DIR := $(ROOT_DIR)/src
THIRD_PARTY_DIR := $(ROOT_DIR)/third-party
BUILD_DIR := $(ROOT_DIR)/build
BUILD_TEST_DIR := $(ROOT_DIR)/build_test
TEST_SRC_DIR := $(ROOT_DIR)/test
BIN_DIR := $(ROOT_DIR)/build/.tmp_update/bin
DIST_DIR := $(ROOT_DIR)/dist
INSTALLER_DIR := $(DIST_DIR)/miyoo/app/.tmp_update
RELEASE_DIR := $(ROOT_DIR)/release
STATIC_BUILD := $(ROOT_DIR)/static/build
STATIC_DIST := $(ROOT_DIR)/static/dist
STATIC_CONFIGS := $(ROOT_DIR)/static/configs
CACHE := $(ROOT_DIR)/cache
STATIC_PACKAGES := $(ROOT_DIR)/static/packages
PACKAGES_DIR := $(ROOT_DIR)/build/App/PackageManager/data
PACKAGES_EMU_DEST := $(PACKAGES_DIR)/Emu
PACKAGES_APP_DEST := $(PACKAGES_DIR)/App
PACKAGES_RAPP_DEST := $(PACKAGES_DIR)/RApp
TEMP_DIR := $(ROOT_DIR)/cache/temp
INCLUDE_DIR := $(ROOT_DIR)/include
ifeq (,$(GTEST_INCLUDE_DIR))
GTEST_INCLUDE_DIR = /usr/include/
endif
TOOLCHAIN := aemiii91/miyoomini-toolchain:latest
include ./src/common/commands.mk
###########################################################
.PHONY: all version core apps external release clean deepclean git-clean with-toolchain patch lib test
all: dist
version: # used by workflow
@echo $(VERSION)
print-version:
@echo Onion v$(VERSION)
@echo RetroArch sub-v$(RA_SUBVERSION)
$(CACHE)/.setup:
@$(ECHO) $(PRINT_RECIPE)
@mkdir -p $(BUILD_DIR) $(DIST_DIR) $(RELEASE_DIR)
@rsync -a --exclude='.gitkeep' $(STATIC_BUILD)/ $(BUILD_DIR)
@rsync -a --exclude='.gitkeep' $(STATIC_DIST)/ $(DIST_DIR)
# Copy shared libraries
@cp -R $(ROOT_DIR)/lib/. $(DIST_DIR)/miyoo/app/.tmp_update/lib
# Set version number
@mkdir -p $(BUILD_DIR)/.tmp_update/onionVersion
@echo -n "v$(VERSION)" > $(BUILD_DIR)/.tmp_update/onionVersion/version.txt
@sed -i "s/{VERSION}/$(VERSION)/g" $(BUILD_DIR)/autorun.inf
# Copy all resources from src folders
@find \
$(SRC_DIR)/gameSwitcher \
$(SRC_DIR)/chargingState \
$(SRC_DIR)/bootScreen \
$(SRC_DIR)/themeSwitcher \
$(SRC_DIR)/tweaks \
$(SRC_DIR)/randomGamePicker \
$(SRC_DIR)/easter \
-depth -type d -name res -exec cp -r {}/. $(BUILD_DIR)/.tmp_update/res/ \;
@find \
$(SRC_DIR)/packageManager \
$(SRC_DIR)/themeSwitcher \
-depth -type d -name script -exec cp -r {}/. $(BUILD_DIR)/.tmp_update/script/ \;
@find $(SRC_DIR)/installUI -depth -type d -name res -exec cp -r {}/. $(INSTALLER_DIR)/res/ \;
# Download themes from theme repo
@chmod a+x $(ROOT_DIR)/.github/get_themes.sh && $(ROOT_DIR)/.github/get_themes.sh
# Copy static configs
@mkdir -p $(TEMP_DIR)/configs $(BUILD_DIR)/.tmp_update/config
@rsync -a --exclude='.gitkeep' $(STATIC_CONFIGS)/ $(TEMP_DIR)/configs
# Copy static packages
@mkdir -p $(PACKAGES_APP_DEST) $(PACKAGES_EMU_DEST) $(PACKAGES_RAPP_DEST)
@rsync -a --exclude='.gitkeep' $(STATIC_PACKAGES)/App/ $(PACKAGES_APP_DEST)
@rsync -a --exclude='.gitkeep' $(STATIC_PACKAGES)/Emu/ $(PACKAGES_EMU_DEST)
@rsync -a --exclude='.gitkeep' $(STATIC_PACKAGES)/RApp/ $(PACKAGES_RAPP_DEST)
@$(STATIC_PACKAGES)/common/apply.sh "$(PACKAGES_EMU_DEST)"
@$(STATIC_PACKAGES)/common/apply.sh "$(PACKAGES_RAPP_DEST)"
@$(STATIC_PACKAGES)/common/auto_advmenu_rc.sh "$(PACKAGES_EMU_DEST)" "$(TEMP_DIR)/configs/BIOS/.advance/advmenu.rc"
@$(STATIC_PACKAGES)/common/auto_advmenu_rc.sh "$(PACKAGES_RAPP_DEST)" "$(TEMP_DIR)/configs/BIOS/.advance/advmenu.rc"
# Create full_resolution files
@chmod a+x $(ROOT_DIR)/.github/create_fullres_files.sh && $(ROOT_DIR)/.github/create_fullres_files.sh
# Set flag: finished setup
@touch $(CACHE)/.setup
build: core apps external
@$(ECHO) $(PRINT_DONE)
core: $(CACHE)/.setup
@$(ECHO) $(PRINT_RECIPE)
# Build Onion binaries
@cd $(SRC_DIR)/bootScreen && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/chargingState && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/gameSwitcher && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/mainUiBatPerc && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/keymon && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/playActivity && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/themeSwitcher && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/tweaks && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/packageManager && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/sendkeys && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/setState && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/renameRom && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/infoPanel && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/prompt && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/batmon && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/easter && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/read_uuid && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/detectKey && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/axp && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/pressMenu2Kill && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/pngScale && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/libgamename && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/gameNameList && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/sendUDP && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/tree && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/pippi && BUILD_DIR=$(BIN_DIR) make
# Build dependencies for installer
@mkdir -p $(INSTALLER_DIR)/bin
@cd $(SRC_DIR)/installUI && BUILD_DIR=$(INSTALLER_DIR)/bin/ VERSION=$(VERSION) make
@cp $(BIN_DIR)/prompt $(INSTALLER_DIR)/bin/
@cp $(BIN_DIR)/batmon $(INSTALLER_DIR)/bin/
@cp $(BIN_DIR)/detectKey $(INSTALLER_DIR)/bin/
@cp $(BIN_DIR)/infoPanel $(INSTALLER_DIR)/bin/
@cp $(BIN_DIR)/gameNameList $(INSTALLER_DIR)/bin/
@cp $(BIN_DIR)/playActivity $(INSTALLER_DIR)/bin/
@cp $(BIN_DIR)/7z $(INSTALLER_DIR)/bin/
# Overrider miyoo libraries
@cp $(BIN_DIR)/libgamename.so $(BUILD_DIR)/miyoo/lib/
apps: $(CACHE)/.setup
@$(ECHO) $(PRINT_RECIPE)
@cd $(SRC_DIR)/batteryMonitorUI && BUILD_DIR="$(PACKAGES_APP_DEST)/Battery Monitor/App/BatteryMonitorUI" make
@find $(SRC_DIR)/batteryMonitorUI -depth -type d -name res -exec cp -r {}/. "$(PACKAGES_APP_DEST)/Battery Monitor/App/BatteryMonitorUI/res/" \;
@cd $(SRC_DIR)/playActivityUI && BUILD_DIR="$(PACKAGES_APP_DEST)/Activity Tracker/App/PlayActivity" make
@find $(SRC_DIR)/playActivityUI -depth -type d -name res -exec cp -r {}/. "$(PACKAGES_APP_DEST)/Activity Tracker/App/PlayActivity/res/" \;
@find $(SRC_DIR)/packageManager -depth -type d -name res -exec cp -r {}/. $(BUILD_DIR)/App/PackageManager/res/ \;
@cd $(SRC_DIR)/clock && BUILD_DIR="$(BIN_DIR)" make
@cd $(SRC_DIR)/randomGamePicker && BUILD_DIR="$(BIN_DIR)" make
# Preinstalled apps
@cp -a "$(PACKAGES_APP_DEST)/Activity Tracker/." $(BUILD_DIR)/
@cp -a "$(PACKAGES_APP_DEST)/Quick Guide/." $(BUILD_DIR)/
@cp -a "$(PACKAGES_APP_DEST)/RetroArch (Shortcut)/." $(BUILD_DIR)/
@cp -a "$(PACKAGES_APP_DEST)/Tweaks/." $(BUILD_DIR)/
@cp -a "$(PACKAGES_APP_DEST)/ThemeSwitcher/." $(BUILD_DIR)/
$(THIRD_PARTY_DIR)/RetroArch/retroarch_miyoo354:
@$(ECHO) $(PRINT_RECIPE)
# RetroArch
@$(ECHO) $(COLOR_BLUE)"\n-- Build RetroArch"$(COLOR_NORMAL)
@cd $(THIRD_PARTY_DIR)/RetroArch && make clean all
@cd $(THIRD_PARTY_DIR)/RetroArch && make clean all MIYOO354=1 PACKAGE_NAME=retroarch_miyoo354
external: $(CACHE)/.setup $(THIRD_PARTY_DIR)/RetroArch/retroarch_miyoo354
@$(ECHO) $(PRINT_RECIPE)
# Add RetroArch
@cp $(THIRD_PARTY_DIR)/RetroArch/retroarch $(BUILD_DIR)/RetroArch/
@cp $(THIRD_PARTY_DIR)/RetroArch/retroarch_miyoo354 $(BUILD_DIR)/RetroArch/
@echo $(RA_SUBVERSION) > $(BUILD_DIR)/RetroArch/onion_ra_version.txt
@$(BUILD_DIR)/.tmp_update/script/build_ext_cache.sh $(BUILD_DIR)/RetroArch/.retroarch
# SearchFilter
@$(ECHO) $(COLOR_BLUE)"\n-- Build SearchFilter"$(COLOR_NORMAL)
@cd $(THIRD_PARTY_DIR)/SearchFilter && make build && cp -a build/. $(BUILD_DIR)
@cp -a $(BUILD_DIR)/App/Search/. "$(PACKAGES_APP_DEST)/Search (Find your games)/App/Search"
@mv -f $(BUILD_DIR)/App/Filter/* "$(PACKAGES_APP_DEST)/List shortcuts (Filter+Refresh)/App/Filter"
@rmdir $(BUILD_DIR)/App/Filter
# Other
@$(ECHO) $(COLOR_BLUE)"\n-- Build Terminal"$(COLOR_NORMAL)
@cd $(THIRD_PARTY_DIR)/Terminal && make && cp ./st "$(BIN_DIR)"
@$(ECHO) $(COLOR_BLUE)"\n-- Build DinguxCommander"$(COLOR_NORMAL)
@cd $(THIRD_PARTY_DIR)/DinguxCommander && make && cp ./output/DinguxCommander "$(PACKAGES_APP_DEST)/File Explorer (DinguxCommander)/App/Commander_Italic"
dist: build
@$(ECHO) $(PRINT_RECIPE)
# Package configs
@cp -R $(TEMP_DIR)/configs/Saves/CurrentProfile/ $(TEMP_DIR)/configs/Saves/GuestProfile
@echo -n "Packaging configs..."
@cd $(TEMP_DIR)/configs && 7z a -mtm=off $(BUILD_DIR)/.tmp_update/config/configs.pak . -bsp1 -bso0
@echo " DONE"
@rm -rf $(TEMP_DIR)/configs
@rmdir $(TEMP_DIR)
# Package RetroArch separately
@echo -n "Packaging RetroArch..."
@cd $(BUILD_DIR) && 7z a -mtm=off retroarch.pak ./RetroArch -bsp1 -bso0
@echo " DONE"
@mkdir -p $(DIST_DIR)/RetroArch
@mv $(BUILD_DIR)/retroarch.pak $(DIST_DIR)/RetroArch/
@echo $(RA_SUBVERSION) > $(DIST_DIR)/RetroArch/ra_package_version.txt
# Package Onion core
@echo -n "Packaging Onion..."
@cd $(BUILD_DIR) && 7z a -mtm=off $(DIST_DIR)/miyoo/app/.tmp_update/onion.pak . -x!RetroArch -bsp1 -bso0
@echo " DONE"
@$(ECHO) $(PRINT_DONE)
release: dist
@$(ECHO) $(PRINT_RECIPE)
@rm -f $(RELEASE_DIR)/$(RELEASE_NAME).zip
@cd $(DIST_DIR) && 7z a -mtc=off $(RELEASE_DIR)/$(RELEASE_NAME).zip . -bsp1 -bso0
@$(ECHO) $(PRINT_DONE)
clean:
@$(ECHO) $(PRINT_RECIPE)
@rm -rf $(BUILD_DIR) $(BUILD_TEST_DIR) $(ROOT_DIR)/dist $(TEMP_DIR)/configs
@rm -f $(CACHE)/.setup
@find include src -type f -name *.o -exec rm -f {} \;
deepclean: clean
@rm -rf $(CACHE)
@rm -f $(THIRD_PARTY_DIR)/RetroArch/retroarch_miyoo354
@cd $(THIRD_PARTY_DIR)/RetroArch && make clean
@cd $(THIRD_PARTY_DIR)/SearchFilter && make clean
@cd $(THIRD_PARTY_DIR)/Terminal && make clean
@cd $(THIRD_PARTY_DIR)/DinguxCommander && make clean
dev: clean
@$(MAKE_DEV)
git-clean:
@git clean -xfd -e .vscode
git-submodules:
@git submodule update --init --recursive
pwd:
@echo $(ROOT_DIR)
$(CACHE)/.docker:
docker pull $(TOOLCHAIN)
$(makedir) cache
$(createfile) $(CACHE)/.docker
toolchain: $(CACHE)/.docker
docker run -it --rm -v "$(ROOT_DIR)":/root/workspace $(TOOLCHAIN) /bin/bash
with-toolchain: $(CACHE)/.docker
docker run --rm -v "$(ROOT_DIR)":/root/workspace $(TOOLCHAIN) /bin/bash -c "source /root/.bashrc; make $(CMD)"
patch:
@chmod a+x $(ROOT_DIR)/.github/create_patch.sh && $(ROOT_DIR)/.github/create_patch.sh
external-libs:
@cd $(ROOT_DIR)/include/SDL && make clean && make
test: external-libs
@mkdir -p $(BUILD_TEST_DIR)/infoPanel_test_data && cd $(TEST_SRC_DIR) && BUILD_DIR=$(BUILD_TEST_DIR)/ make dev
@cp -R $(TEST_SRC_DIR)/infoPanel_test_data $(BUILD_TEST_DIR)/
cd $(BUILD_TEST_DIR) && ./test
static-analysis: external-libs
@cd $(ROOT_DIR) && cppcheck -I $(INCLUDE_DIR) --enable=all $(SRC_DIR)
format:
@find ./src -regex '.*\.\(c\|h\|cpp\|hpp\)' -exec clang-format -style=file -i {} \;