blob: 218de3d0e76f61a5318e3f24e0e7820ddec7ace2 [file] [log] [blame]
Dees_Troy51a0e822012-09-05 15:24:24 -04001LOCAL_PATH := $(call my-dir)
Dees_Troy51a0e822012-09-05 15:24:24 -04002# Transfer in the resources for the device
3include $(CLEAR_VARS)
4LOCAL_MODULE := twrp
bigbiffd58ba182020-03-23 10:02:29 -04005LOCAL_MODULE_TAGS := optional
bigbiff673c7ae2020-12-02 19:44:56 -05006LOCAL_MODULE_CLASS := DATA
Dees Troy3454ade2015-01-20 19:21:04 +00007LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)$(TWRES_PATH)
Dees_Troy51a0e822012-09-05 15:24:24 -04008
Matt Mowerd4a11182017-01-18 20:06:36 -06009# The extra blank line before *** is intentional to ensure it ends up on its own line
10define TW_THEME_WARNING_MSG
11
12****************************************************************************
13 Could not find ui.xml for TW_THEME: $(TW_THEME)
14 Set TARGET_SCREEN_WIDTH and TARGET_SCREEN_HEIGHT to automatically select
15 an appropriate theme, or set TW_THEME to one of the following:
Ethan Yonker58f21322018-08-24 11:17:36 -050016 $(notdir $(wildcard $(LOCAL_PATH)/theme/*_*))
Matt Mowerd4a11182017-01-18 20:06:36 -060017****************************************************************************
18endef
19define TW_CUSTOM_THEME_WARNING_MSG
20
21****************************************************************************
22 Could not find ui.xml for TW_CUSTOM_THEME: $(TW_CUSTOM_THEME)
Matt Mower0c005712017-02-12 13:10:08 -060023 Expected to find custom theme's ui.xml at:
Matt Mowerd4a11182017-01-18 20:06:36 -060024 $(TWRP_THEME_LOC)/ui.xml
25 Please fix this or set TW_THEME to one of the following:
Ethan Yonker58f21322018-08-24 11:17:36 -050026 $(notdir $(wildcard $(LOCAL_PATH)/theme/*_*))
Matt Mowerd4a11182017-01-18 20:06:36 -060027****************************************************************************
28endef
29
Ethan Yonker58f21322018-08-24 11:17:36 -050030TWRP_RES := $(LOCAL_PATH)/theme/common/fonts
31TWRP_RES += $(LOCAL_PATH)/theme/common/languages
nkk716e4114f2017-01-19 16:56:07 +020032ifeq ($(TW_EXTRA_LANGUAGES),true)
Ethan Yonker58f21322018-08-24 11:17:36 -050033 TWRP_RES += $(LOCAL_PATH)/theme/extra-languages/fonts
34 TWRP_RES += $(LOCAL_PATH)/theme/extra-languages/languages
nkk716e4114f2017-01-19 16:56:07 +020035endif
36
Ethan Yonker1ecaca72014-04-14 09:27:15 -050037ifeq ($(TW_CUSTOM_THEME),)
Ethan Yonker591b9202015-03-11 11:17:15 -050038 ifeq ($(TW_THEME),)
niks255d73903c2017-01-15 17:39:48 +060039 ifeq ($(DEVICE_RESOLUTION),)
Matt Mowerd4a11182017-01-18 20:06:36 -060040 GUI_WIDTH := $(TARGET_SCREEN_WIDTH)
41 GUI_HEIGHT := $(TARGET_SCREEN_HEIGHT)
42 else
43 SPLIT_DEVICE_RESOLUTION := $(subst x, ,$(DEVICE_RESOLUTION))
44 GUI_WIDTH := $(word 1, $(SPLIT_DEVICE_RESOLUTION))
45 GUI_HEIGHT := $(word 2, $(SPLIT_DEVICE_RESOLUTION))
niks255d73903c2017-01-15 17:39:48 +060046 endif
Matt Mowerd4a11182017-01-18 20:06:36 -060047
48 # Minimum resolution of 100x100
49 # This also ensures GUI_WIDTH and GUI_HEIGHT are numbers
50 ifeq ($(shell test $(GUI_WIDTH) -ge 100; echo $$?),0)
51 ifeq ($(shell test $(GUI_HEIGHT) -ge 100; echo $$?),0)
52 ifeq ($(shell test $(GUI_WIDTH) -gt $(GUI_HEIGHT); echo $$?),0)
53 ifeq ($(shell test $(GUI_WIDTH) -ge 1280; echo $$?),0)
54 TW_THEME := landscape_hdpi
55 else
56 TW_THEME := landscape_mdpi
57 endif
58 else ifeq ($(shell test $(GUI_WIDTH) -lt $(GUI_HEIGHT); echo $$?),0)
59 ifeq ($(shell test $(GUI_WIDTH) -ge 720; echo $$?),0)
60 TW_THEME := portrait_hdpi
61 else
62 TW_THEME := portrait_mdpi
63 endif
64 else ifeq ($(shell test $(GUI_WIDTH) -eq $(GUI_HEIGHT); echo $$?),0)
65 # watch_hdpi does not yet exist
66 TW_THEME := watch_mdpi
67 endif
68 endif
Ethan Yonker591b9202015-03-11 11:17:15 -050069 endif
70 endif
bigbiffce8f83c2015-12-12 18:30:21 -050071
Ethan Yonker58f21322018-08-24 11:17:36 -050072 TWRP_THEME_LOC := $(LOCAL_PATH)/theme/$(TW_THEME)
Matt Mowerd4a11182017-01-18 20:06:36 -060073 ifeq ($(wildcard $(TWRP_THEME_LOC)/ui.xml),)
74 $(warning $(TW_THEME_WARNING_MSG))
75 $(error Theme selection failed; exiting)
76 endif
77
Ethan Yonker58f21322018-08-24 11:17:36 -050078 TWRP_RES += $(LOCAL_PATH)/theme/common/$(word 1,$(subst _, ,$(TW_THEME))).xml
nkk716e4114f2017-01-19 16:56:07 +020079 # for future copying of used include xmls and fonts:
80 # UI_XML := $(TWRP_THEME_LOC)/ui.xml
81 # TWRP_INCLUDE_XMLS := $(shell xmllint --xpath '/recovery/include/xmlfile/@name' $(UI_XML)|sed -n 's/[^\"]*\"\([^\"]*\)\"[^\"]*/\1\n/gp'|sort|uniq)
82 # TWRP_FONTS_TTF := $(shell xmllint --xpath '/recovery/resources/font/@filename' $(UI_XML)|sed -n 's/[^\"]*\"\([^\"]*\)\"[^\"]*/\1\n/gp'|sort|uniq)niq)
83else
84 TWRP_THEME_LOC := $(TW_CUSTOM_THEME)
Matt Mowerd4a11182017-01-18 20:06:36 -060085 ifeq ($(wildcard $(TWRP_THEME_LOC)/ui.xml),)
86 $(warning $(TW_CUSTOM_THEME_WARNING_MSG))
87 $(error Theme selection failed; exiting)
nkk716e4114f2017-01-19 16:56:07 +020088 endif
thatd16b2ce2015-07-27 20:39:19 +020089endif
Vojtech Bocek76ee9032014-09-07 15:01:56 +020090
Matt Mowerd4a11182017-01-18 20:06:36 -060091TWRP_RES += $(TW_ADDITIONAL_RES)
92
Dees_Troy51a0e822012-09-05 15:24:24 -040093TWRP_RES_GEN := $(intermediates)/twrp
Ethan Yonker5c933692014-04-04 11:26:32 -050094$(TWRP_RES_GEN):
Dees Troy3454ade2015-01-20 19:21:04 +000095 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)$(TWRES_PATH)
thatd16b2ce2015-07-27 20:39:19 +020096 cp -fr $(TWRP_RES) $(TARGET_RECOVERY_ROOT_OUT)$(TWRES_PATH)
Dees Troy3454ade2015-01-20 19:21:04 +000097 cp -fr $(TWRP_THEME_LOC)/* $(TARGET_RECOVERY_ROOT_OUT)$(TWRES_PATH)
Dees_Troy51a0e822012-09-05 15:24:24 -040098
99LOCAL_GENERATED_SOURCES := $(TWRP_RES_GEN)
bigbiff673c7ae2020-12-02 19:44:56 -0500100#LOCAL_SRC_FILES := twrp
101LOCAL_SRC_FILES := $(TWRP_RES_GEN)
102$(warning LOCAL_SRC_FILES: $(LOCAL_SRC_FILES))
Dees_Troy7d15c252012-09-05 20:47:21 -0400103include $(BUILD_PREBUILT)