blob: 9529735c99bc6203e27d52e75904e8efe2944948 [file] [log] [blame]
Dees_Troy51a0e822012-09-05 15:24:24 -04001LOCAL_PATH := $(call my-dir)
2include $(CLEAR_VARS)
3
bigbiffd58ba182020-03-23 10:02:29 -04004LOCAL_CFLAGS := -fno-strict-aliasing -Wno-implicit-fallthrough
Motorhead1991c7f2e122014-06-12 15:57:36 -07005
Dees_Troy51a0e822012-09-05 15:24:24 -04006LOCAL_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 \
Vojtech Bocekede51c52014-02-07 23:58:09 +010020 object.cpp \
Dees_Troy51a0e822012-09-05 15:24:24 -040021 slider.cpp \
Vojtech Bocek85932342013-04-01 22:11:33 +020022 slidervalue.cpp \
Dees_Troy51a0e822012-09-05 15:24:24 -040023 listbox.cpp \
24 keyboard.cpp \
bigbiff bigbiff8a68c312013-02-10 14:28:30 -050025 input.cpp \
26 blanktimer.cpp \
Vojtech Bocek1fc30fc2014-01-29 18:37:19 +010027 partitionlist.cpp \
Ethan Yonker0a3a98f2015-02-05 00:48:28 +010028 mousecursor.cpp \
Vojtech Bocek7e11ac52015-03-05 23:21:49 +010029 scrolllist.cpp \
Ethan Yonker44925ad2015-07-22 12:33:59 -050030 patternpassword.cpp \
Ethan Yonker74db1572015-10-28 12:44:49 -050031 textbox.cpp \
that1964d192016-01-07 00:41:03 +010032 terminal.cpp \
Ethan Yonker74db1572015-10-28 12:44:49 -050033 twmsg.cpp
Dees_Troy51a0e822012-09-05 15:24:24 -040034
35ifneq ($(TWRP_CUSTOM_KEYBOARD),)
Ethan Yonker591b9202015-03-11 11:17:15 -050036 LOCAL_SRC_FILES += $(TWRP_CUSTOM_KEYBOARD)
Dees_Troy51a0e822012-09-05 15:24:24 -040037else
Ethan Yonker591b9202015-03-11 11:17:15 -050038 LOCAL_SRC_FILES += hardwarekeyboard.cpp
Dees_Troy51a0e822012-09-05 15:24:24 -040039endif
40
Ethan Yonker8373cfe2017-09-08 06:50:54 -050041LOCAL_SHARED_LIBRARIES += libminuitwrp libc libstdc++ libaosprecovery libselinux
bigbiffd58ba182020-03-23 10:02:29 -040042LOCAL_C_INCLUDES += $(LOCAL_PATH)/../otautil/include
Ethan Yonker8373cfe2017-09-08 06:50:54 -050043ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0)
bigbiffd58ba182020-03-23 10:02:29 -040044 LOCAL_SHARED_LIBRARIES += libziparchive
45 LOCAL_STATIC_LIBRARIES += libotautil
46 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 28; echo $$?),0)
47 LOCAL_C_INCLUDES += $(LOCAL_PATH)/../install/include \
48 system/core/libziparchive/include/ \
49 $(LOCAL_PATH)/../recovery_ui/include \
50 $(LOCAL_PATH)/../fuse_sideload/include
51 LOCAL_CFLAGS += -D_USE_SYSTEM_ZIPARCHIVE
52 else
53 LOCAL_C_INCLUDES += $(LOCAL_PATH)/../install28/ \
54 $(LOCAL_PATH)/../fuse_sideload28/
55 LOCAL_CFLAGS += -DUSE_28_INSTALL -DUSE_OTAUTIL_ZIPARCHIVE
56 endif
Ethan Yonker8373cfe2017-09-08 06:50:54 -050057else
58 LOCAL_SHARED_LIBRARIES += libminzip
59 LOCAL_CFLAGS += -DUSE_MINZIP
60endif
bigbiff325e0a22020-06-08 15:59:32 -040061ifeq ($(TARGET_USERIMAGES_USE_EXT4), true)
62 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -le 28; echo $$?),0)
63 LOCAL_C_INCLUDES += system/extras/ext4_utils \
64 system/extras/ext4_utils/include \
65 $(LOCAL_PATH)/../crypto/ext4crypt
66 LOCAL_SHARED_LIBRARIES += libext4_utils
67 endif
68endif
69
Dees_Troy2673cec2013-04-02 20:22:16 +000070LOCAL_MODULE := libguitwrp
Dees_Troy51a0e822012-09-05 15:24:24 -040071
Dees_Troy51a0e822012-09-05 15:24:24 -040072#TWRP_EVENT_LOGGING := true
73ifeq ($(TWRP_EVENT_LOGGING), true)
Ethan Yonker30fa3352015-03-09 13:57:21 -050074 LOCAL_CFLAGS += -D_EVENT_LOGGING
75endif
76ifneq ($(TW_USE_KEY_CODE_TOUCH_SYNC),)
77 LOCAL_CFLAGS += -DTW_USE_KEY_CODE_TOUCH_SYNC=$(TW_USE_KEY_CODE_TOUCH_SYNC)
Dees_Troy51a0e822012-09-05 15:24:24 -040078endif
79
bigbiff bigbiff87940362013-03-09 09:58:50 -050080ifneq ($(TW_NO_SCREEN_BLANK),)
Ethan Yonker591b9202015-03-11 11:17:15 -050081 LOCAL_CFLAGS += -DTW_NO_SCREEN_BLANK
bigbiff bigbiff87940362013-03-09 09:58:50 -050082endif
Ricardo Gomezc9ecd442013-07-05 16:13:52 -070083ifneq ($(TW_NO_SCREEN_TIMEOUT),)
Ethan Yonker591b9202015-03-11 11:17:15 -050084 LOCAL_CFLAGS += -DTW_NO_SCREEN_TIMEOUT
Ricardo Gomezc9ecd442013-07-05 16:13:52 -070085endif
bigbiff bigbiffc7eee6f2014-09-02 18:59:01 -040086ifeq ($(TW_OEM_BUILD), true)
Ethan Yonker83e82572014-04-04 10:59:28 -050087 LOCAL_CFLAGS += -DTW_OEM_BUILD
88endif
Ethan Yonker751a85e2014-12-12 16:59:10 -060089ifneq ($(TW_X_OFFSET),)
Ethan Yonker591b9202015-03-11 11:17:15 -050090 LOCAL_CFLAGS += -DTW_X_OFFSET=$(TW_X_OFFSET)
Ethan Yonker751a85e2014-12-12 16:59:10 -060091endif
92ifneq ($(TW_Y_OFFSET),)
Ethan Yonker591b9202015-03-11 11:17:15 -050093 LOCAL_CFLAGS += -DTW_Y_OFFSET=$(TW_Y_OFFSET)
Ethan Yonker751a85e2014-12-12 16:59:10 -060094endif
James Christopher Adduonodcd1e442016-11-06 13:17:34 -050095ifneq ($(TW_W_OFFSET),)
96 LOCAL_CFLAGS += -DTW_W_OFFSET=$(TW_W_OFFSET)
97endif
98ifneq ($(TW_H_OFFSET),)
99 LOCAL_CFLAGS += -DTW_H_OFFSET=$(TW_H_OFFSET)
100endif
Ethan Yonker63e414f2015-02-06 15:44:39 -0600101ifeq ($(TW_ROUND_SCREEN), true)
Ethan Yonker591b9202015-03-11 11:17:15 -0500102 LOCAL_CFLAGS += -DTW_ROUND_SCREEN
bigbiff bigbiff163d4742013-11-16 13:25:27 -0500103endif
104
Matt Mower0c88b842017-01-15 16:00:49 -0600105LOCAL_C_INCLUDES += \
106 bionic \
107 system/core/include \
bigbiffd58ba182020-03-23 10:02:29 -0400108 system/core/libpixelflinger/include \
109 external/freetype/include
Matt Mower0c88b842017-01-15 16:00:49 -0600110
Xing0af1ac12015-11-27 11:19:37 -0800111ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0)
112 LOCAL_C_INCLUDES += external/stlport/stlport
Ethan Yonker58f21322018-08-24 11:17:36 -0500113 LOCAL_CFLAGS += -DUSE_FUSE_SIDELOAD22
Xing0af1ac12015-11-27 11:19:37 -0800114endif
115
Dees Troy3454ade2015-01-20 19:21:04 +0000116LOCAL_CFLAGS += -DTWRES=\"$(TWRES_PATH)\"
Dees_Troy51a0e822012-09-05 15:24:24 -0400117
118include $(BUILD_STATIC_LIBRARY)
119
120# Transfer in the resources for the device
121include $(CLEAR_VARS)
122LOCAL_MODULE := twrp
bigbiffd58ba182020-03-23 10:02:29 -0400123LOCAL_MODULE_TAGS := optional
Dees_Troy51a0e822012-09-05 15:24:24 -0400124LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
Dees Troy3454ade2015-01-20 19:21:04 +0000125LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)$(TWRES_PATH)
Dees_Troy51a0e822012-09-05 15:24:24 -0400126
Matt Mowerd4a11182017-01-18 20:06:36 -0600127# The extra blank line before *** is intentional to ensure it ends up on its own line
128define TW_THEME_WARNING_MSG
129
130****************************************************************************
131 Could not find ui.xml for TW_THEME: $(TW_THEME)
132 Set TARGET_SCREEN_WIDTH and TARGET_SCREEN_HEIGHT to automatically select
133 an appropriate theme, or set TW_THEME to one of the following:
Ethan Yonker58f21322018-08-24 11:17:36 -0500134 $(notdir $(wildcard $(LOCAL_PATH)/theme/*_*))
Matt Mowerd4a11182017-01-18 20:06:36 -0600135****************************************************************************
136endef
137define TW_CUSTOM_THEME_WARNING_MSG
138
139****************************************************************************
140 Could not find ui.xml for TW_CUSTOM_THEME: $(TW_CUSTOM_THEME)
Matt Mower0c005712017-02-12 13:10:08 -0600141 Expected to find custom theme's ui.xml at:
Matt Mowerd4a11182017-01-18 20:06:36 -0600142 $(TWRP_THEME_LOC)/ui.xml
143 Please fix this or set TW_THEME to one of the following:
Ethan Yonker58f21322018-08-24 11:17:36 -0500144 $(notdir $(wildcard $(LOCAL_PATH)/theme/*_*))
Matt Mowerd4a11182017-01-18 20:06:36 -0600145****************************************************************************
146endef
147
Ethan Yonker58f21322018-08-24 11:17:36 -0500148TWRP_RES := $(LOCAL_PATH)/theme/common/fonts
149TWRP_RES += $(LOCAL_PATH)/theme/common/languages
nkk716e4114f2017-01-19 16:56:07 +0200150ifeq ($(TW_EXTRA_LANGUAGES),true)
Ethan Yonker58f21322018-08-24 11:17:36 -0500151 TWRP_RES += $(LOCAL_PATH)/theme/extra-languages/fonts
152 TWRP_RES += $(LOCAL_PATH)/theme/extra-languages/languages
nkk716e4114f2017-01-19 16:56:07 +0200153endif
154
Ethan Yonker1ecaca72014-04-14 09:27:15 -0500155ifeq ($(TW_CUSTOM_THEME),)
Ethan Yonker591b9202015-03-11 11:17:15 -0500156 ifeq ($(TW_THEME),)
niks255d73903c2017-01-15 17:39:48 +0600157 ifeq ($(DEVICE_RESOLUTION),)
Matt Mowerd4a11182017-01-18 20:06:36 -0600158 GUI_WIDTH := $(TARGET_SCREEN_WIDTH)
159 GUI_HEIGHT := $(TARGET_SCREEN_HEIGHT)
160 else
161 SPLIT_DEVICE_RESOLUTION := $(subst x, ,$(DEVICE_RESOLUTION))
162 GUI_WIDTH := $(word 1, $(SPLIT_DEVICE_RESOLUTION))
163 GUI_HEIGHT := $(word 2, $(SPLIT_DEVICE_RESOLUTION))
niks255d73903c2017-01-15 17:39:48 +0600164 endif
Matt Mowerd4a11182017-01-18 20:06:36 -0600165
166 # Minimum resolution of 100x100
167 # This also ensures GUI_WIDTH and GUI_HEIGHT are numbers
168 ifeq ($(shell test $(GUI_WIDTH) -ge 100; echo $$?),0)
169 ifeq ($(shell test $(GUI_HEIGHT) -ge 100; echo $$?),0)
170 ifeq ($(shell test $(GUI_WIDTH) -gt $(GUI_HEIGHT); echo $$?),0)
171 ifeq ($(shell test $(GUI_WIDTH) -ge 1280; echo $$?),0)
172 TW_THEME := landscape_hdpi
173 else
174 TW_THEME := landscape_mdpi
175 endif
176 else ifeq ($(shell test $(GUI_WIDTH) -lt $(GUI_HEIGHT); echo $$?),0)
177 ifeq ($(shell test $(GUI_WIDTH) -ge 720; echo $$?),0)
178 TW_THEME := portrait_hdpi
179 else
180 TW_THEME := portrait_mdpi
181 endif
182 else ifeq ($(shell test $(GUI_WIDTH) -eq $(GUI_HEIGHT); echo $$?),0)
183 # watch_hdpi does not yet exist
184 TW_THEME := watch_mdpi
185 endif
186 endif
Ethan Yonker591b9202015-03-11 11:17:15 -0500187 endif
188 endif
bigbiffce8f83c2015-12-12 18:30:21 -0500189
Ethan Yonker58f21322018-08-24 11:17:36 -0500190 TWRP_THEME_LOC := $(LOCAL_PATH)/theme/$(TW_THEME)
Matt Mowerd4a11182017-01-18 20:06:36 -0600191 ifeq ($(wildcard $(TWRP_THEME_LOC)/ui.xml),)
192 $(warning $(TW_THEME_WARNING_MSG))
193 $(error Theme selection failed; exiting)
194 endif
195
Ethan Yonker58f21322018-08-24 11:17:36 -0500196 TWRP_RES += $(LOCAL_PATH)/theme/common/$(word 1,$(subst _, ,$(TW_THEME))).xml
nkk716e4114f2017-01-19 16:56:07 +0200197 # for future copying of used include xmls and fonts:
198 # UI_XML := $(TWRP_THEME_LOC)/ui.xml
199 # TWRP_INCLUDE_XMLS := $(shell xmllint --xpath '/recovery/include/xmlfile/@name' $(UI_XML)|sed -n 's/[^\"]*\"\([^\"]*\)\"[^\"]*/\1\n/gp'|sort|uniq)
200 # TWRP_FONTS_TTF := $(shell xmllint --xpath '/recovery/resources/font/@filename' $(UI_XML)|sed -n 's/[^\"]*\"\([^\"]*\)\"[^\"]*/\1\n/gp'|sort|uniq)niq)
201else
202 TWRP_THEME_LOC := $(TW_CUSTOM_THEME)
Matt Mowerd4a11182017-01-18 20:06:36 -0600203 ifeq ($(wildcard $(TWRP_THEME_LOC)/ui.xml),)
204 $(warning $(TW_CUSTOM_THEME_WARNING_MSG))
205 $(error Theme selection failed; exiting)
nkk716e4114f2017-01-19 16:56:07 +0200206 endif
thatd16b2ce2015-07-27 20:39:19 +0200207endif
Vojtech Bocek76ee9032014-09-07 15:01:56 +0200208
Matt Mowerd4a11182017-01-18 20:06:36 -0600209TWRP_RES += $(TW_ADDITIONAL_RES)
210
Dees_Troy51a0e822012-09-05 15:24:24 -0400211TWRP_RES_GEN := $(intermediates)/twrp
Ethan Yonker5c933692014-04-04 11:26:32 -0500212$(TWRP_RES_GEN):
Dees Troy3454ade2015-01-20 19:21:04 +0000213 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)$(TWRES_PATH)
thatd16b2ce2015-07-27 20:39:19 +0200214 cp -fr $(TWRP_RES) $(TARGET_RECOVERY_ROOT_OUT)$(TWRES_PATH)
Dees Troy3454ade2015-01-20 19:21:04 +0000215 cp -fr $(TWRP_THEME_LOC)/* $(TARGET_RECOVERY_ROOT_OUT)$(TWRES_PATH)
Dees_Troy51a0e822012-09-05 15:24:24 -0400216
217LOCAL_GENERATED_SOURCES := $(TWRP_RES_GEN)
218LOCAL_SRC_FILES := twrp $(TWRP_RES_GEN)
Dees_Troy7d15c252012-09-05 20:47:21 -0400219include $(BUILD_PREBUILT)