blob: 43a3d83f1e1f02cbe091d911a90606c29fbac8b0 [file] [log] [blame]
Dees_Troy51a0e822012-09-05 15:24:24 -04001LOCAL_PATH := $(call my-dir)
Sean hoytc3876222018-07-15 06:16:09 +02002include $(CLEAR_VARS)
3
4LOCAL_CFLAGS := -fno-strict-aliasing -Wno-implicit-fallthrough
5
6LOCAL_SRC_FILES := \
7 gui.cpp \
8 resources.cpp \
9 pages.cpp \
10 text.cpp \
11 image.cpp \
12 action.cpp \
13 console.cpp \
14 fill.cpp \
15 button.cpp \
16 checkbox.cpp \
17 fileselector.cpp \
18 progressbar.cpp \
19 animation.cpp \
20 object.cpp \
21 slider.cpp \
22 slidervalue.cpp \
23 listbox.cpp \
24 keyboard.cpp \
25 input.cpp \
26 blanktimer.cpp \
27 partitionlist.cpp \
28 mousecursor.cpp \
29 scrolllist.cpp \
30 patternpassword.cpp \
31 textbox.cpp \
32 terminal.cpp \
33 twmsg.cpp
34
35ifneq ($(TW_DELAY_TOUCH_INIT_MS),)
36 LOCAL_CFLAGS += -DTW_DELAY_TOUCH_INIT_MS=$(TW_DELAY_TOUCH_INIT_MS)
37endif
38
39ifneq ($(TWRP_CUSTOM_KEYBOARD),)
40 LOCAL_SRC_FILES += $(TWRP_CUSTOM_KEYBOARD)
41else
42 LOCAL_SRC_FILES += hardwarekeyboard.cpp
43endif
44
45LOCAL_SHARED_LIBRARIES += libminuitwrp libc libstdc++ libaosprecovery libselinux
46LOCAL_C_INCLUDES += $(LOCAL_PATH)/../otautil/include
47LOCAL_C_INCLUDES += $(LOCAL_PATH)/../twrpinstall/include
48ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0)
49 LOCAL_SHARED_LIBRARIES += libziparchive
50 LOCAL_STATIC_LIBRARIES += libotautil libtwrpinstall
51 ifneq ($(TW_INCLUDE_CRYPTO),)
52 LOCAL_C_INCLUDES += bootable/recovery/crypto/fscrypt
53 endif
54 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 28; echo $$?),0)
55 LOCAL_C_INCLUDES += $(LOCAL_PATH)/../install/include \
56 system/core/libziparchive/include/ \
57 $(LOCAL_PATH)/../recovery_ui/include \
58 $(LOCAL_PATH)/../fuse_sideload/include
59 LOCAL_CFLAGS += -D_USE_SYSTEM_ZIPARCHIVE
60 else
61 LOCAL_C_INCLUDES += $(LOCAL_PATH)/../install28/ \
62 $(LOCAL_PATH)/../fuse_sideload28/
63 LOCAL_CFLAGS += -DUSE_28_INSTALL -DUSE_OTAUTIL_ZIPARCHIVE
64 endif
65else
66 LOCAL_SHARED_LIBRARIES += libminzip
67 LOCAL_CFLAGS += -DUSE_MINZIP
68endif
69ifeq ($(TARGET_USERIMAGES_USE_EXT4), true)
70 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -le 28; echo $$?),0)
71 LOCAL_C_INCLUDES += system/extras/ext4_utils \
72 system/extras/ext4_utils/include \
73 $(LOCAL_PATH)/../crypto/ext4crypt
74 LOCAL_SHARED_LIBRARIES += libext4_utils
75 endif
76endif
77
78LOCAL_MODULE := libguitwrp
79
80#TWRP_EVENT_LOGGING := true
81ifeq ($(TWRP_EVENT_LOGGING), true)
82 LOCAL_CFLAGS += -D_EVENT_LOGGING
83endif
84ifneq ($(TW_USE_KEY_CODE_TOUCH_SYNC),)
85 LOCAL_CFLAGS += -DTW_USE_KEY_CODE_TOUCH_SYNC=$(TW_USE_KEY_CODE_TOUCH_SYNC)
86endif
87ifneq ($(TW_OZIP_DECRYPT_KEY),)
88 LOCAL_CFLAGS += -DTW_OZIP_DECRYPT_KEY=\"$(TW_OZIP_DECRYPT_KEY)\"
89else
90 LOCAL_CFLAGS += -DTW_OZIP_DECRYPT_KEY=0
91endif
92ifneq ($(TW_NO_SCREEN_BLANK),)
93 LOCAL_CFLAGS += -DTW_NO_SCREEN_BLANK
94endif
95ifneq ($(TW_NO_SCREEN_TIMEOUT),)
96 LOCAL_CFLAGS += -DTW_NO_SCREEN_TIMEOUT
97endif
98ifeq ($(TW_OEM_BUILD), true)
99 LOCAL_CFLAGS += -DTW_OEM_BUILD
100endif
101ifneq ($(TW_X_OFFSET),)
102 LOCAL_CFLAGS += -DTW_X_OFFSET=$(TW_X_OFFSET)
103endif
104ifneq ($(TW_Y_OFFSET),)
105 LOCAL_CFLAGS += -DTW_Y_OFFSET=$(TW_Y_OFFSET)
106endif
107ifneq ($(TW_W_OFFSET),)
108 LOCAL_CFLAGS += -DTW_W_OFFSET=$(TW_W_OFFSET)
109endif
110ifneq ($(TW_H_OFFSET),)
111 LOCAL_CFLAGS += -DTW_H_OFFSET=$(TW_H_OFFSET)
112endif
113ifeq ($(TW_ROUND_SCREEN), true)
114 LOCAL_CFLAGS += -DTW_ROUND_SCREEN
115endif
116ifeq ($(TW_EXCLUDE_NANO), true)
117 LOCAL_CFLAGS += -DTW_EXCLUDE_NANO
118endif
119ifeq ($(AB_OTA_UPDATER),true)
120 LOCAL_CFLAGS += -DAB_OTA_UPDATER=1
121endif
122ifeq ($(TW_SCREEN_BLANK_ON_BOOT), true)
123 LOCAL_CFLAGS += -DTW_SCREEN_BLANK_ON_BOOT
124endif
125
126LOCAL_C_INCLUDES += \
127 bionic \
128 system/core/base/include \
129 system/core/include \
130 system/core/libpixelflinger/include \
131 external/freetype/include
132
133ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0)
134 LOCAL_C_INCLUDES += external/stlport/stlport
135 LOCAL_CFLAGS += -DUSE_FUSE_SIDELOAD22
136endif
137
138LOCAL_CFLAGS += -DTWRES=\"$(TWRES_PATH)\"
139
140include $(BUILD_STATIC_LIBRARY)
Dees_Troy51a0e822012-09-05 15:24:24 -0400141
142# Transfer in the resources for the device
143include $(CLEAR_VARS)
144LOCAL_MODULE := twrp
bigbiffd58ba182020-03-23 10:02:29 -0400145LOCAL_MODULE_TAGS := optional
bigbiff673c7ae2020-12-02 19:44:56 -0500146LOCAL_MODULE_CLASS := DATA
Dees Troy3454ade2015-01-20 19:21:04 +0000147LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)$(TWRES_PATH)
Dees_Troy51a0e822012-09-05 15:24:24 -0400148
Matt Mowerd4a11182017-01-18 20:06:36 -0600149# The extra blank line before *** is intentional to ensure it ends up on its own line
150define TW_THEME_WARNING_MSG
151
152****************************************************************************
153 Could not find ui.xml for TW_THEME: $(TW_THEME)
154 Set TARGET_SCREEN_WIDTH and TARGET_SCREEN_HEIGHT to automatically select
155 an appropriate theme, or set TW_THEME to one of the following:
Ethan Yonker58f21322018-08-24 11:17:36 -0500156 $(notdir $(wildcard $(LOCAL_PATH)/theme/*_*))
Matt Mowerd4a11182017-01-18 20:06:36 -0600157****************************************************************************
158endef
159define TW_CUSTOM_THEME_WARNING_MSG
160
161****************************************************************************
162 Could not find ui.xml for TW_CUSTOM_THEME: $(TW_CUSTOM_THEME)
Matt Mower0c005712017-02-12 13:10:08 -0600163 Expected to find custom theme's ui.xml at:
Matt Mowerd4a11182017-01-18 20:06:36 -0600164 $(TWRP_THEME_LOC)/ui.xml
165 Please fix this or set TW_THEME to one of the following:
Ethan Yonker58f21322018-08-24 11:17:36 -0500166 $(notdir $(wildcard $(LOCAL_PATH)/theme/*_*))
Matt Mowerd4a11182017-01-18 20:06:36 -0600167****************************************************************************
168endef
169
Ethan Yonker58f21322018-08-24 11:17:36 -0500170TWRP_RES := $(LOCAL_PATH)/theme/common/fonts
171TWRP_RES += $(LOCAL_PATH)/theme/common/languages
nkk716e4114f2017-01-19 16:56:07 +0200172ifeq ($(TW_EXTRA_LANGUAGES),true)
Ethan Yonker58f21322018-08-24 11:17:36 -0500173 TWRP_RES += $(LOCAL_PATH)/theme/extra-languages/fonts
174 TWRP_RES += $(LOCAL_PATH)/theme/extra-languages/languages
nkk716e4114f2017-01-19 16:56:07 +0200175endif
176
Ethan Yonker1ecaca72014-04-14 09:27:15 -0500177ifeq ($(TW_CUSTOM_THEME),)
Ethan Yonker591b9202015-03-11 11:17:15 -0500178 ifeq ($(TW_THEME),)
niks255d73903c2017-01-15 17:39:48 +0600179 ifeq ($(DEVICE_RESOLUTION),)
Matt Mowerd4a11182017-01-18 20:06:36 -0600180 GUI_WIDTH := $(TARGET_SCREEN_WIDTH)
181 GUI_HEIGHT := $(TARGET_SCREEN_HEIGHT)
182 else
183 SPLIT_DEVICE_RESOLUTION := $(subst x, ,$(DEVICE_RESOLUTION))
184 GUI_WIDTH := $(word 1, $(SPLIT_DEVICE_RESOLUTION))
185 GUI_HEIGHT := $(word 2, $(SPLIT_DEVICE_RESOLUTION))
niks255d73903c2017-01-15 17:39:48 +0600186 endif
Matt Mowerd4a11182017-01-18 20:06:36 -0600187
188 # Minimum resolution of 100x100
189 # This also ensures GUI_WIDTH and GUI_HEIGHT are numbers
190 ifeq ($(shell test $(GUI_WIDTH) -ge 100; echo $$?),0)
191 ifeq ($(shell test $(GUI_HEIGHT) -ge 100; echo $$?),0)
192 ifeq ($(shell test $(GUI_WIDTH) -gt $(GUI_HEIGHT); echo $$?),0)
193 ifeq ($(shell test $(GUI_WIDTH) -ge 1280; echo $$?),0)
194 TW_THEME := landscape_hdpi
195 else
196 TW_THEME := landscape_mdpi
197 endif
198 else ifeq ($(shell test $(GUI_WIDTH) -lt $(GUI_HEIGHT); echo $$?),0)
199 ifeq ($(shell test $(GUI_WIDTH) -ge 720; echo $$?),0)
200 TW_THEME := portrait_hdpi
201 else
202 TW_THEME := portrait_mdpi
203 endif
204 else ifeq ($(shell test $(GUI_WIDTH) -eq $(GUI_HEIGHT); echo $$?),0)
205 # watch_hdpi does not yet exist
206 TW_THEME := watch_mdpi
207 endif
208 endif
Ethan Yonker591b9202015-03-11 11:17:15 -0500209 endif
210 endif
bigbiffce8f83c2015-12-12 18:30:21 -0500211
Ethan Yonker58f21322018-08-24 11:17:36 -0500212 TWRP_THEME_LOC := $(LOCAL_PATH)/theme/$(TW_THEME)
Matt Mowerd4a11182017-01-18 20:06:36 -0600213 ifeq ($(wildcard $(TWRP_THEME_LOC)/ui.xml),)
214 $(warning $(TW_THEME_WARNING_MSG))
215 $(error Theme selection failed; exiting)
216 endif
217
Ethan Yonker58f21322018-08-24 11:17:36 -0500218 TWRP_RES += $(LOCAL_PATH)/theme/common/$(word 1,$(subst _, ,$(TW_THEME))).xml
nkk716e4114f2017-01-19 16:56:07 +0200219 # for future copying of used include xmls and fonts:
220 # UI_XML := $(TWRP_THEME_LOC)/ui.xml
221 # TWRP_INCLUDE_XMLS := $(shell xmllint --xpath '/recovery/include/xmlfile/@name' $(UI_XML)|sed -n 's/[^\"]*\"\([^\"]*\)\"[^\"]*/\1\n/gp'|sort|uniq)
222 # TWRP_FONTS_TTF := $(shell xmllint --xpath '/recovery/resources/font/@filename' $(UI_XML)|sed -n 's/[^\"]*\"\([^\"]*\)\"[^\"]*/\1\n/gp'|sort|uniq)niq)
223else
224 TWRP_THEME_LOC := $(TW_CUSTOM_THEME)
Matt Mowerd4a11182017-01-18 20:06:36 -0600225 ifeq ($(wildcard $(TWRP_THEME_LOC)/ui.xml),)
226 $(warning $(TW_CUSTOM_THEME_WARNING_MSG))
227 $(error Theme selection failed; exiting)
nkk716e4114f2017-01-19 16:56:07 +0200228 endif
thatd16b2ce2015-07-27 20:39:19 +0200229endif
Vojtech Bocek76ee9032014-09-07 15:01:56 +0200230
Matt Mowerd4a11182017-01-18 20:06:36 -0600231TWRP_RES += $(TW_ADDITIONAL_RES)
232
Dees_Troy51a0e822012-09-05 15:24:24 -0400233TWRP_RES_GEN := $(intermediates)/twrp
Ethan Yonker5c933692014-04-04 11:26:32 -0500234$(TWRP_RES_GEN):
Dees Troy3454ade2015-01-20 19:21:04 +0000235 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)$(TWRES_PATH)
thatd16b2ce2015-07-27 20:39:19 +0200236 cp -fr $(TWRP_RES) $(TARGET_RECOVERY_ROOT_OUT)$(TWRES_PATH)
Dees Troy3454ade2015-01-20 19:21:04 +0000237 cp -fr $(TWRP_THEME_LOC)/* $(TARGET_RECOVERY_ROOT_OUT)$(TWRES_PATH)
Dees_Troy51a0e822012-09-05 15:24:24 -0400238
239LOCAL_GENERATED_SOURCES := $(TWRP_RES_GEN)
bigbiff673c7ae2020-12-02 19:44:56 -0500240#LOCAL_SRC_FILES := twrp
241LOCAL_SRC_FILES := $(TWRP_RES_GEN)
242$(warning LOCAL_SRC_FILES: $(LOCAL_SRC_FILES))
Dees_Troy7d15c252012-09-05 20:47:21 -0400243include $(BUILD_PREBUILT)