blob: 1b62d6c6165d8b972e398fcd711344604edd265b [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001AUDIO_PARAM_OUT_DIR := $(TARGET_OUT_VENDOR_ETC)/audio_param
2EXTRACT_FILE_LIST := *_AudioParam.xml *_ParamUnitDesc.xml *_ParamTreeView.xml
3
4LOCAL_AUDIO_PARAM_FILE_PATTERN := $(subst *,%,$(EXTRACT_FILE_LIST))
5LOCAL_AUDIO_PARAM_INSTALLED :=
6
7ifneq (,$(strip $(INSTALL_AUDIO_PARAM_FILE_LIST))$(strip $(INSTALL_AUDIO_PARAM_DIR_LIST)))
8 $(warning $(newline)\
9*********************************************************************$(newline)\
10INSTALL_AUDIO_PARAM_FILE_LIST and INSTALL_AUDIO_PARAM_DIR_LIST are no$(newline)\
11longer supported, but observed the following usages:$(newline)$(newline)\
12$(if $(strip $(INSTALL_AUDIO_PARAM_FILE_LIST)),$(space)$(space)INSTALL_AUDIO_PARAM_FILE_LIST: $(INSTALL_AUDIO_PARAM_FILE_LIST)$(newline))\
13$(if $(strip $(INSTALL_AUDIO_PARAM_DIR_LIST)),$(space)$(space)INSTALL_AUDIO_PARAM_DIR_LIST: $(INSTALL_AUDIO_PARAM_DIR_LIST)$(newline))\
14$(newline)\
15To add custom AudioParam files, please use:$(newline)\
16$(space)$(space)CUSTOM_AUDIO_PARAM_FILE_LIST += $$(YOUR_FILES)$(newline)\
17Likewise, for custom AudioParam directories:$(newline)\
18$(space)$(space)CUSTOM_AUDIO_PARAM_DIR_LIST += $$(YOUR_DIRS)$(newline)\
19*********************************************************************)
20 $(error Please use CUSTOM_AUDIO_PARAM_FILE_LIST and CUSTOM_AUDIO_PARAM_DIR_LIST instead of INSTALL_AUDIO_PARAM_FILE_LIST and INSTALL_AUDIO_PARAM_DIR_LIST)
21endif
22
23# Add chip & project's default.audio_param by default
24CHIP := $(MTK_PLATFORM_DIR)
25CUSTOM_AUDIO_PARAM_FILE_LIST += $(MTK_TARGET_PROJECT_FOLDER)/default.audio_param device/mediatek/$(CHIP)/default.audio_param
26
27# Deploy these files in MTK_AUDIO_PARAM_FILE_LIST to LOCAL_DEFAULT_AUDIO_PARAM_FILE
28# Check if the audio_param exist, uncompress & delete it
29LOCAL_DEFAULT_AUDIO_PARAM_FILE := $(firstword $(wildcard $(CUSTOM_AUDIO_PARAM_FILE_LIST) $(MTK_AUDIO_PARAM_FILE_LIST)))
30
31ifneq (,$(filter custom_images,$(MAKECMDGOALS)))
32AUDIO_PARAM_CUSTOM_IMAGE_ZIP_FILE := $(LOCAL_DEFAULT_AUDIO_PARAM_FILE)
33AUDIO_PARAM_CUSTOM_IMAGE_XML_FILES :=
34AUDIO_PARAM_CUSTOM_IMAGE_ZIPPED_FILES :=
35endif
36
37ifneq ($(LOCAL_DEFAULT_AUDIO_PARAM_FILE),)
38LOCAL_AUDIO_PARAM_UNZIP_FILE_LIST := $(filter $(LOCAL_AUDIO_PARAM_FILE_PATTERN),$(shell unzip -Z -1 $(LOCAL_DEFAULT_AUDIO_PARAM_FILE)))
39
40# $(1): input.zip
41# $(2): output.file
42define unzip-audio-param-file
43$(2): $(1)
44 mkdir -p $$(dir $(2))
45 unzip -qo $(1) $$(notdir $(2)) -d $$(dir $(2))
46endef
47$(foreach f,$(LOCAL_AUDIO_PARAM_UNZIP_FILE_LIST),\
48 $(eval src := $(LOCAL_DEFAULT_AUDIO_PARAM_FILE))\
49 $(eval dst := $(AUDIO_PARAM_OUT_DIR)/$(notdir $(f)))\
50 $(if $(filter custom_images,$(MAKECMDGOALS)), \
51 $(eval AUDIO_PARAM_CUSTOM_IMAGE_ZIPPED_FILES += $(src)))\
52 $(eval LOCAL_AUDIO_PARAM_INSTALLED += $(dst))\
53 $(eval $(call unzip-audio-param-file,$(src),$(dst)))\
54)
55endif
56
57LOCAL_AUDIO_PARAM_COPY_FILE_LIST := $(filter $(LOCAL_AUDIO_PARAM_FILE_PATTERN),$(foreach d,$(CUSTOM_AUDIO_PARAM_DIR_LIST) $(MTK_AUDIO_PARAM_DIR_LIST),$(wildcard $(d)/*.xml)))
58LOCAL_AUDIO_PARAM_COPY_FILE_STEM := $(sort $(filter-out $(notdir $(LOCAL_AUDIO_PARAM_UNZIP_FILE_LIST)),$(notdir $(LOCAL_AUDIO_PARAM_COPY_FILE_LIST))))
59$(foreach f,$(LOCAL_AUDIO_PARAM_COPY_FILE_STEM),\
60 $(eval chk := $(filter %/$(f),$(LOCAL_AUDIO_PARAM_COPY_FILE_LIST)))\
61 $(eval src := $(firstword $(chk)))\
62 $(if $(filter custom_images,$(MAKECMDGOALS)),\
63 $(eval AUDIO_PARAM_CUSTOM_IMAGE_XML_FILES += $(src)))\
64 $(eval exc := $(filter-out $(src),$(chk)))\
65 $(if $(strip $(exc)),$(info AudioParam: $(src) overrides $(exc)))\
66 $(eval dst := $(AUDIO_PARAM_OUT_DIR)/$(f))\
67 $(eval LOCAL_AUDIO_PARAM_INSTALLED += $(dst))\
68 $(eval $(call copy-one-file,$(src),$(dst)))\
69)
70
71ifneq (,$(filter custom_images,$(MAKECMDGOALS)))
72AUDIO_PARAM_CUSTOM_IMAGE_ZIP_FILE := \
73 $(strip $(AUDIO_PARAM_CUSTOM_IMAGE_ZIP_FILE))
74AUDIO_PARAM_CUSTOM_IMAGE_ZIPPED_FILES := \
75 $(strip $(AUDIO_PARAM_CUSTOM_IMAGE_ZIPPED_FILES))
76AUDIO_PARAM_CUSTOM_IMAGE_XML_FILES := \
77 $(strip $(AUDIO_PARAM_CUSTOM_IMAGE_XML_FILES))
78endif
79
80ALL_DEFAULT_INSTALLED_MODULES += $(LOCAL_AUDIO_PARAM_INSTALLED)
81.PHONY: MODULES-IN-vendor-mediatek-proprietary-external-AudioParamParser
82MODULES-IN-vendor-mediatek-proprietary-external-AudioParamParser: $(LOCAL_AUDIO_PARAM_INSTALLED)