forked from OnionUI/Onion
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
193 lines (163 loc) · 6.74 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
###########################################################
TARGET=TelmiOS
VERSION=1.6.2
###########################################################
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
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 TelmiOS v$(VERSION)
$(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)/bootScreen \
$(SRC_DIR)/storyTeller \
$(SRC_DIR)/chargingState \
-depth -type d -name res -exec cp -r {}/. $(BUILD_DIR)/.tmp_update/res/ \;
@find $(SRC_DIR)/installUI -depth -type d -name res -exec cp -r {}/. $(INSTALLER_DIR)/res/ \;
# Copy static configs
@mkdir -p $(TEMP_DIR)/configs $(BUILD_DIR)/.tmp_update/config
@rsync -a --exclude='.gitkeep' $(STATIC_CONFIGS)/ $(TEMP_DIR)/configs
# Set flag: finished setup
@touch $(CACHE)/.setup
build: core apps external
@$(ECHO) $(PRINT_DONE)
core: $(CACHE)/.setup
@$(ECHO) $(PRINT_RECIPE)
# Build Telmi binaries
@cd $(SRC_DIR)/bootScreen && BUILD_DIR=$(BIN_DIR) make
@cd $(SRC_DIR)/storyTeller && 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
# 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/
dist: build
@$(ECHO) $(PRINT_RECIPE)
# Package configs
@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 Telmi core
@echo -n "Packaging TelmiOS..."
@cd $(BUILD_DIR) && 7z a -mtm=off $(DIST_DIR)/miyoo/app/.tmp_update/onion.pak . -bsp1 -bso0
@echo " DONE"
@$(ECHO) $(PRINT_DONE)
release: dist
@$(ECHO) $(PRINT_RECIPE)
@rm -f "$(RELEASE_DIR)/$(RELEASE_NAME).zip" "$(RELEASE_DIR)/$(RELEASE_NAME)-update.zip"
@cd "$(DIST_DIR)" && 7z a -mtc=off "$(RELEASE_DIR)/$(RELEASE_NAME).zip" . -bsp1 -bso0
@cd "$(BUILD_DIR)" && 7z a -mtc=off -spf -tzip "$(RELEASE_DIR)/$(RELEASE_NAME)-update.zip" "autorun.inf" ".tmp_update/bin/batmon" ".tmp_update/bin/bootScreen" ".tmp_update/bin/chargingState" ".tmp_update/bin/storyTeller" ".tmp_update/onionVersion/version.txt" ".tmp_update/res" ".tmp_update/script/customlogo" ".tmp_update/runtime.sh" -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)
dev: clean
@$(MAKE_DEV)
git-clean:
@git clean -xfd -e .vscode
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
lib:
@cd $(ROOT_DIR)/include/cJSON && make clean && make
@cd $(ROOT_DIR)/include/SDL && make clean && make
test:
@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:
@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 {} \;