rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | AUDIO_PARAM_OUT_DIR := $(TARGET_OUT_VENDOR_ETC)/audio_param |
| 2 | EXTRACT_FILE_LIST := *_AudioParam.xml *_ParamUnitDesc.xml *_ParamTreeView.xml |
| 3 | |
| 4 | LOCAL_AUDIO_PARAM_FILE_PATTERN := $(subst *,%,$(EXTRACT_FILE_LIST)) |
| 5 | LOCAL_AUDIO_PARAM_INSTALLED := |
| 6 | |
| 7 | ifneq (,$(strip $(INSTALL_AUDIO_PARAM_FILE_LIST))$(strip $(INSTALL_AUDIO_PARAM_DIR_LIST))) |
| 8 | $(warning $(newline)\ |
| 9 | *********************************************************************$(newline)\ |
| 10 | INSTALL_AUDIO_PARAM_FILE_LIST and INSTALL_AUDIO_PARAM_DIR_LIST are no$(newline)\ |
| 11 | longer 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)\ |
| 15 | To add custom AudioParam files, please use:$(newline)\ |
| 16 | $(space)$(space)CUSTOM_AUDIO_PARAM_FILE_LIST += $$(YOUR_FILES)$(newline)\ |
| 17 | Likewise, 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) |
| 21 | endif |
| 22 | |
| 23 | # Add chip & project's default.audio_param by default |
| 24 | CHIP := $(MTK_PLATFORM_DIR) |
| 25 | CUSTOM_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 |
| 29 | LOCAL_DEFAULT_AUDIO_PARAM_FILE := $(firstword $(wildcard $(CUSTOM_AUDIO_PARAM_FILE_LIST) $(MTK_AUDIO_PARAM_FILE_LIST))) |
| 30 | |
| 31 | ifneq (,$(filter custom_images,$(MAKECMDGOALS))) |
| 32 | AUDIO_PARAM_CUSTOM_IMAGE_ZIP_FILE := $(LOCAL_DEFAULT_AUDIO_PARAM_FILE) |
| 33 | AUDIO_PARAM_CUSTOM_IMAGE_XML_FILES := |
| 34 | AUDIO_PARAM_CUSTOM_IMAGE_ZIPPED_FILES := |
| 35 | endif |
| 36 | |
| 37 | ifneq ($(LOCAL_DEFAULT_AUDIO_PARAM_FILE),) |
| 38 | LOCAL_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 |
| 42 | define unzip-audio-param-file |
| 43 | $(2): $(1) |
| 44 | mkdir -p $$(dir $(2)) |
| 45 | unzip -qo $(1) $$(notdir $(2)) -d $$(dir $(2)) |
| 46 | endef |
| 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 | ) |
| 55 | endif |
| 56 | |
| 57 | LOCAL_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))) |
| 58 | LOCAL_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 | |
| 71 | ifneq (,$(filter custom_images,$(MAKECMDGOALS))) |
| 72 | AUDIO_PARAM_CUSTOM_IMAGE_ZIP_FILE := \ |
| 73 | $(strip $(AUDIO_PARAM_CUSTOM_IMAGE_ZIP_FILE)) |
| 74 | AUDIO_PARAM_CUSTOM_IMAGE_ZIPPED_FILES := \ |
| 75 | $(strip $(AUDIO_PARAM_CUSTOM_IMAGE_ZIPPED_FILES)) |
| 76 | AUDIO_PARAM_CUSTOM_IMAGE_XML_FILES := \ |
| 77 | $(strip $(AUDIO_PARAM_CUSTOM_IMAGE_XML_FILES)) |
| 78 | endif |
| 79 | |
| 80 | ALL_DEFAULT_INSTALLED_MODULES += $(LOCAL_AUDIO_PARAM_INSTALLED) |
| 81 | .PHONY: MODULES-IN-vendor-mediatek-proprietary-external-AudioParamParser |
| 82 | MODULES-IN-vendor-mediatek-proprietary-external-AudioParamParser: $(LOCAL_AUDIO_PARAM_INSTALLED) |