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 imgtec \ 26 invensense \ 27 lge \ 28 nvidia \ 29 nxp \ 30 qcom \ 31 samsung \ 32 samsung_arm \ 33 ti \ 34 trusted_logic \ 35 widevine 36 37 38 ifneq (,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RESTRICT_VENDOR_FILES)) 39 40 _vendor_check_modules := $(sort $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES)) 41 $(call expand-required-modules,_vendor_check_modules,$(_vendor_check_modules)) 42 43 # Expand the target modules installed via LOCAL_SHARED_LIBRARIES 44 # $(1): the list of modules to expand. 45 define expand-required-shared-libraries 46 $(eval _ersl_new_modules := $(filter $(addsuffix :%,$(1)),$(TARGET_DEPENDENCIES_ON_SHARED_LIBRARIES)))\ 47 $(eval _ersl_new_modules := $(foreach p,$(_ersl_new_modules),$(word 3,$(subst :,$(space),$(p)))))\ 48 $(eval _ersl_new_modules := $(sort $(subst $(comma),$(space),$(_ersl_new_modules))))\ 49 $(eval _ersl_new_modules := $(filter-out $(_vendor_check_modules),$(_ersl_new_modules)))\ 50 $(if $(_ersl_new_modules),$(eval _vendor_check_modules += $(_ersl_new_modules))\ 51 $(call expand-required-shared-libraries,$(_ersl_new_modules))) 52 endef 53 $(call expand-required-shared-libraries,$(_vendor_check_modules)) 54 55 _vendor_module_owner_info := 56 # Restrict owners 57 ifneq (,$(filter true owner all, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RESTRICT_VENDOR_FILES))) 58 59 ifneq (,$(filter vendor/%, $(PRODUCT_PACKAGE_OVERLAYS) $(DEVICE_PACKAGE_OVERLAYS))) 60 $(error Error: Product "$(TARGET_PRODUCT)" cannot have overlay in vendor tree: \ 61 $(filter vendor/%, $(PRODUCT_PACKAGE_OVERLAYS) $(DEVICE_PACKAGE_OVERLAYS))) 62 endif 63 _vendor_check_copy_files := $(filter vendor/%, $(PRODUCT_COPY_FILES)) 64 ifneq (,$(_vendor_check_copy_files)) 65 $(foreach c, $(_vendor_check_copy_files), \ 66 $(if $(filter $(_vendor_owner_whitelist), $(call word-colon,3,$(c))),,\ 67 $(error Error: vendor PRODUCT_COPY_FILES file "$(c)" has unknown owner))\ 68 $(eval _vendor_module_owner_info += $(call word-colon,2,$(c)):$(call word-colon,3,$(c)))) 69 endif 70 _vendor_check_copy_files := 71 72 $(foreach m, $(_vendor_check_modules), \ 73 $(if $(filter vendor/%, $(ALL_MODULES.$(m).PATH)),\ 74 $(if $(filter $(_vendor_owner_whitelist), $(ALL_MODULES.$(m).OWNER)),,\ 75 $(error Error: vendor module "$(m)" in $(ALL_MODULES.$(m).PATH) with unknown owner \ 76 "$(ALL_MODULES.$(m).OWNER)" in product "$(TARGET_PRODUCT)"))\ 77 $(if $(ALL_MODULES.$(m).INSTALLED),\ 78 $(eval _vendor_module_owner_info += $(patsubst $(PRODUCT_OUT)/%,%,$(ALL_MODULES.$(m).INSTALLED)):$(ALL_MODULES.$(m).OWNER))))) 79 80 endif 81 82 83 # Restrict paths 84 ifneq (,$(filter path all, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RESTRICT_VENDOR_FILES))) 85 86 $(foreach m, $(_vendor_check_modules), \ 87 $(if $(filter vendor/%, $(ALL_MODULES.$(m).PATH)),\ 88 $(if $(filter $(TARGET_OUT_VENDOR)/%, $(ALL_MODULES.$(m).INSTALLED)),,\ 89 $(error Error: vendor module "$(m)" in $(ALL_MODULES.$(m).PATH) \ 90 in product "$(TARGET_PRODUCT)" being installed to \ 91 $(ALL_MODULES.$(m).INSTALLED) which is not in the vendor tree)))) 92 93 endif 94 95 _vendor_module_owner_info_txt := $(call intermediates-dir-for,PACKAGING,vendor_owner_info)/vendor_owner_info.txt 96 $(_vendor_module_owner_info_txt): PRIVATE_INFO := $(_vendor_module_owner_info) 97 $(_vendor_module_owner_info_txt): 98 @echo "Write vendor module owner info $@" 99 @mkdir -p $(dir $@) && rm -f $@ 100 ifdef _vendor_module_owner_info 101 @for w in $(PRIVATE_INFO); \ 102 do \ 103 echo $$w >> $@; \ 104 done 105 else 106 @echo "No vendor module owner info." > $@ 107 endif 108 109 $(call dist-for-goals, droidcore, $(_vendor_module_owner_info_txt)) 110 111 _vendor_module_owner_info_txt := 112 _vendor_module_owner_info := 113 _vendor_check_modules := 114 endif 115