vendor_module_check.mk revision 6eea8e25fdfa70491dc4ea3345b75799ea79e028
1# 2# Copyright (C) 2011 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17# Restrict the vendor module owners here. 18_vendor_owner_whitelist := \ 19 asus \ 20 audience \ 21 broadcom \ 22 csr \ 23 elan \ 24 google \ 25 htc \ 26 imgtec \ 27 invensense \ 28 intel \ 29 lge \ 30 moto \ 31 nvidia \ 32 nxp \ 33 qcom \ 34 qti \ 35 samsung \ 36 samsung_arm \ 37 ti \ 38 trusted_logic \ 39 widevine 40 41 42ifneq (,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RESTRICT_VENDOR_FILES)) 43 44_vendor_check_modules := $(sort $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES)) 45$(call expand-required-modules,_vendor_check_modules,$(_vendor_check_modules)) 46 47# Expand the target modules installed via LOCAL_SHARED_LIBRARIES 48# $(1): the list of modules to expand. 49define expand-required-shared-libraries 50$(eval _ersl_new_modules := $(filter $(addsuffix :%,$(1)),$(TARGET_DEPENDENCIES_ON_SHARED_LIBRARIES)))\ 51$(eval _ersl_new_modules := $(foreach p,$(_ersl_new_modules),$(word 3,$(subst :,$(space),$(p)))))\ 52$(eval _ersl_new_modules := $(sort $(subst $(comma),$(space),$(_ersl_new_modules))))\ 53$(eval _ersl_new_modules := $(filter-out $(_vendor_check_modules),$(_ersl_new_modules)))\ 54$(if $(_ersl_new_modules),$(eval _vendor_check_modules += $(_ersl_new_modules))\ 55 $(call expand-required-shared-libraries,$(_ersl_new_modules))) 56endef 57$(call expand-required-shared-libraries,$(_vendor_check_modules)) 58 59_vendor_module_owner_info := 60# Restrict owners 61ifneq (,$(filter true owner all, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RESTRICT_VENDOR_FILES))) 62 63ifneq (,$(filter vendor/%, $(PRODUCT_PACKAGE_OVERLAYS) $(DEVICE_PACKAGE_OVERLAYS))) 64$(error Error: Product "$(TARGET_PRODUCT)" cannot have overlay in vendor tree: \ 65 $(filter vendor/%, $(PRODUCT_PACKAGE_OVERLAYS) $(DEVICE_PACKAGE_OVERLAYS))) 66endif 67_vendor_check_copy_files := $(filter vendor/%, $(PRODUCT_COPY_FILES)) 68ifneq (,$(_vendor_check_copy_files)) 69$(foreach c, $(_vendor_check_copy_files), \ 70 $(if $(filter $(_vendor_owner_whitelist), $(call word-colon,3,$(c))),,\ 71 $(error Error: vendor PRODUCT_COPY_FILES file "$(c)" has unknown owner))\ 72 $(eval _vendor_module_owner_info += $(call word-colon,2,$(c)):$(call word-colon,3,$(c)))) 73endif 74_vendor_check_copy_files := 75 76$(foreach m, $(_vendor_check_modules), \ 77 $(if $(filter vendor/%, $(ALL_MODULES.$(m).PATH)),\ 78 $(if $(filter-out FAKE, $(ALL_MODULES.$(m).CLASS)),\ 79 $(if $(filter $(_vendor_owner_whitelist), $(ALL_MODULES.$(m).OWNER)),,\ 80 $(error Error: vendor module "$(m)" in $(ALL_MODULES.$(m).PATH) with unknown owner \ 81 "$(ALL_MODULES.$(m).OWNER)" in product "$(TARGET_PRODUCT)"))\ 82 $(if $(ALL_MODULES.$(m).INSTALLED),\ 83 $(eval _vendor_module_owner_info += $(patsubst $(PRODUCT_OUT)/%,%,$(ALL_MODULES.$(m).INSTALLED)):$(ALL_MODULES.$(m).OWNER)))))) 84 85endif 86 87 88# Restrict paths 89ifneq (,$(filter path all, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RESTRICT_VENDOR_FILES))) 90 91$(foreach m, $(_vendor_check_modules), \ 92 $(if $(filter vendor/%, $(ALL_MODULES.$(m).PATH)),\ 93 $(if $(filter-out FAKE, $(ALL_MODULES.$(m).CLASS)),\ 94 $(if $(filter-out ,$(ALL_MODULES.$(m).INSTALLED)),\ 95 $(if $(filter $(TARGET_OUT_VENDOR)/% $(HOST_OUT)/%, $(ALL_MODULES.$(m).INSTALLED)),,\ 96 $(error Error: vendor module "$(m)" in $(ALL_MODULES.$(m).PATH) \ 97 in product "$(TARGET_PRODUCT)" being installed to \ 98 $(ALL_MODULES.$(m).INSTALLED) which is not in the vendor tree)))))) 99 100endif 101 102_vendor_module_owner_info_txt := $(call intermediates-dir-for,PACKAGING,vendor_owner_info)/vendor_owner_info.txt 103$(_vendor_module_owner_info_txt): PRIVATE_INFO := $(_vendor_module_owner_info) 104$(_vendor_module_owner_info_txt): 105 @echo "Write vendor module owner info $@" 106 @mkdir -p $(dir $@) && rm -f $@ 107ifdef _vendor_module_owner_info 108 @for w in $(PRIVATE_INFO); \ 109 do \ 110 echo $$w >> $@; \ 111 done 112else 113 @echo "No vendor module owner info." > $@ 114endif 115 116$(call dist-for-goals, droidcore, $(_vendor_module_owner_info_txt)) 117 118_vendor_module_owner_info_txt := 119_vendor_module_owner_info := 120_vendor_check_modules := 121endif 122