blob: 450748d259c52be241bd6a11c654dd44128be8a7 [file] [log] [blame]
Dees_Troy51a0e822012-09-05 15:24:24 -04001LOCAL_PATH := $(call my-dir)
Dees_Troy51a0e822012-09-05 15:24:24 -04002
3# Transfer in the resources for the device
4include $(CLEAR_VARS)
5LOCAL_MODULE := twrp
bigbiffd58ba182020-03-23 10:02:29 -04006LOCAL_MODULE_TAGS := optional
bigbiff673c7ae2020-12-02 19:44:56 -05007LOCAL_MODULE_CLASS := DATA
Dees Troy3454ade2015-01-20 19:21:04 +00008LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)$(TWRES_PATH)
Dees_Troy51a0e822012-09-05 15:24:24 -04009
Matt Mowerd4a11182017-01-18 20:06:36 -060010# The extra blank line before *** is intentional to ensure it ends up on its own line
11define TW_THEME_WARNING_MSG
12
13****************************************************************************
14 Could not find ui.xml for TW_THEME: $(TW_THEME)
15 Set TARGET_SCREEN_WIDTH and TARGET_SCREEN_HEIGHT to automatically select
16 an appropriate theme, or set TW_THEME to one of the following:
Ethan Yonker58f21322018-08-24 11:17:36 -050017 $(notdir $(wildcard $(LOCAL_PATH)/theme/*_*))
Matt Mowerd4a11182017-01-18 20:06:36 -060018****************************************************************************
19endef
20define TW_CUSTOM_THEME_WARNING_MSG
21
22****************************************************************************
23 Could not find ui.xml for TW_CUSTOM_THEME: $(TW_CUSTOM_THEME)
Matt Mower0c005712017-02-12 13:10:08 -060024 Expected to find custom theme's ui.xml at:
Matt Mowerd4a11182017-01-18 20:06:36 -060025 $(TWRP_THEME_LOC)/ui.xml
26 Please fix this or set TW_THEME to one of the following:
Ethan Yonker58f21322018-08-24 11:17:36 -050027 $(notdir $(wildcard $(LOCAL_PATH)/theme/*_*))
Matt Mowerd4a11182017-01-18 20:06:36 -060028****************************************************************************
29endef
30
Ethan Yonker58f21322018-08-24 11:17:36 -050031TWRP_RES := $(LOCAL_PATH)/theme/common/fonts
32TWRP_RES += $(LOCAL_PATH)/theme/common/languages
nkk716e4114f2017-01-19 16:56:07 +020033ifeq ($(TW_EXTRA_LANGUAGES),true)
Ethan Yonker58f21322018-08-24 11:17:36 -050034 TWRP_RES += $(LOCAL_PATH)/theme/extra-languages/fonts
35 TWRP_RES += $(LOCAL_PATH)/theme/extra-languages/languages
nkk716e4114f2017-01-19 16:56:07 +020036endif
37
Ethan Yonker1ecaca72014-04-14 09:27:15 -050038ifeq ($(TW_CUSTOM_THEME),)
Ethan Yonker591b9202015-03-11 11:17:15 -050039 ifeq ($(TW_THEME),)
niks255d73903c2017-01-15 17:39:48 +060040 ifeq ($(DEVICE_RESOLUTION),)
Matt Mowerd4a11182017-01-18 20:06:36 -060041 GUI_WIDTH := $(TARGET_SCREEN_WIDTH)
42 GUI_HEIGHT := $(TARGET_SCREEN_HEIGHT)
43 else
44 SPLIT_DEVICE_RESOLUTION := $(subst x, ,$(DEVICE_RESOLUTION))
45 GUI_WIDTH := $(word 1, $(SPLIT_DEVICE_RESOLUTION))
46 GUI_HEIGHT := $(word 2, $(SPLIT_DEVICE_RESOLUTION))
niks255d73903c2017-01-15 17:39:48 +060047 endif
Matt Mowerd4a11182017-01-18 20:06:36 -060048
49 # Minimum resolution of 100x100
50 # This also ensures GUI_WIDTH and GUI_HEIGHT are numbers
51 ifeq ($(shell test $(GUI_WIDTH) -ge 100; echo $$?),0)
52 ifeq ($(shell test $(GUI_HEIGHT) -ge 100; echo $$?),0)
53 ifeq ($(shell test $(GUI_WIDTH) -gt $(GUI_HEIGHT); echo $$?),0)
54 ifeq ($(shell test $(GUI_WIDTH) -ge 1280; echo $$?),0)
55 TW_THEME := landscape_hdpi
56 else
57 TW_THEME := landscape_mdpi
58 endif
59 else ifeq ($(shell test $(GUI_WIDTH) -lt $(GUI_HEIGHT); echo $$?),0)
60 ifeq ($(shell test $(GUI_WIDTH) -ge 720; echo $$?),0)
61 TW_THEME := portrait_hdpi
62 else
63 TW_THEME := portrait_mdpi
64 endif
65 else ifeq ($(shell test $(GUI_WIDTH) -eq $(GUI_HEIGHT); echo $$?),0)
66 # watch_hdpi does not yet exist
67 TW_THEME := watch_mdpi
68 endif
69 endif
Ethan Yonker591b9202015-03-11 11:17:15 -050070 endif
71 endif
bigbiffce8f83c2015-12-12 18:30:21 -050072
Ethan Yonker58f21322018-08-24 11:17:36 -050073 TWRP_THEME_LOC := $(LOCAL_PATH)/theme/$(TW_THEME)
Matt Mowerd4a11182017-01-18 20:06:36 -060074 ifeq ($(wildcard $(TWRP_THEME_LOC)/ui.xml),)
75 $(warning $(TW_THEME_WARNING_MSG))
76 $(error Theme selection failed; exiting)
77 endif
78
Ethan Yonker58f21322018-08-24 11:17:36 -050079 TWRP_RES += $(LOCAL_PATH)/theme/common/$(word 1,$(subst _, ,$(TW_THEME))).xml
nkk716e4114f2017-01-19 16:56:07 +020080 # for future copying of used include xmls and fonts:
81 # UI_XML := $(TWRP_THEME_LOC)/ui.xml
82 # TWRP_INCLUDE_XMLS := $(shell xmllint --xpath '/recovery/include/xmlfile/@name' $(UI_XML)|sed -n 's/[^\"]*\"\([^\"]*\)\"[^\"]*/\1\n/gp'|sort|uniq)
83 # TWRP_FONTS_TTF := $(shell xmllint --xpath '/recovery/resources/font/@filename' $(UI_XML)|sed -n 's/[^\"]*\"\([^\"]*\)\"[^\"]*/\1\n/gp'|sort|uniq)niq)
84else
85 TWRP_THEME_LOC := $(TW_CUSTOM_THEME)
Matt Mowerd4a11182017-01-18 20:06:36 -060086 ifeq ($(wildcard $(TWRP_THEME_LOC)/ui.xml),)
87 $(warning $(TW_CUSTOM_THEME_WARNING_MSG))
88 $(error Theme selection failed; exiting)
nkk716e4114f2017-01-19 16:56:07 +020089 endif
thatd16b2ce2015-07-27 20:39:19 +020090endif
Vojtech Bocek76ee9032014-09-07 15:01:56 +020091
Matt Mowerd4a11182017-01-18 20:06:36 -060092TWRP_RES += $(TW_ADDITIONAL_RES)
93
Dees_Troy51a0e822012-09-05 15:24:24 -040094TWRP_RES_GEN := $(intermediates)/twrp
Ethan Yonker5c933692014-04-04 11:26:32 -050095$(TWRP_RES_GEN):
Dees Troy3454ade2015-01-20 19:21:04 +000096 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)$(TWRES_PATH)
thatd16b2ce2015-07-27 20:39:19 +020097 cp -fr $(TWRP_RES) $(TARGET_RECOVERY_ROOT_OUT)$(TWRES_PATH)
Dees Troy3454ade2015-01-20 19:21:04 +000098 cp -fr $(TWRP_THEME_LOC)/* $(TARGET_RECOVERY_ROOT_OUT)$(TWRES_PATH)
Dees_Troy51a0e822012-09-05 15:24:24 -040099
100LOCAL_GENERATED_SOURCES := $(TWRP_RES_GEN)
bigbiff673c7ae2020-12-02 19:44:56 -0500101#LOCAL_SRC_FILES := twrp
102LOCAL_SRC_FILES := $(TWRP_RES_GEN)
103$(warning LOCAL_SRC_FILES: $(LOCAL_SRC_FILES))
Dees_Troy7d15c252012-09-05 20:47:21 -0400104include $(BUILD_PREBUILT)