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 atmel \ 22 broadcom \ 23 csr \ 24 elan \ 25 fpc \ 26 google \ 27 htc \ 28 huawei \ 29 imgtec \ 30 invensense \ 31 intel \ 32 lge \ 33 moto \ 34 mtk \ 35 nvidia \ 36 nxp \ 37 nxpsw \ 38 qcom \ 39 qti \ 40 samsung \ 41 samsung_arm \ 42 sony \ 43 synaptics \ 44 ti \ 45 trusted_logic \ 46 verizon \ 47 widevine 48 49 50 _restrictions := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RESTRICT_VENDOR_FILES)) 51 52 ifneq (,$(_restrictions)) 53 ifneq (,$(PRODUCTS.$(INTERNAL_PRODUCT).VENDOR_PRODUCT_RESTRICT_VENDOR_FILES)) 54 $(error Error: cannot set both PRODUCT_RESTRICT_VENDOR_FILES and VENDOR_PRODUCT_RESTRICT_VENDOR_FILES) 55 endif 56 _vendor_exception_path_prefix := 57 _vendor_exception_modules := 58 else 59 _restrictions := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).VENDOR_PRODUCT_RESTRICT_VENDOR_FILES)) 60 _vendor_exception_path_prefix := $(patsubst %, vendor/%/%, $(PRODUCTS.$(INTERNAL_PRODUCT).VENDOR_EXCEPTION_PATHS)) 61 _vendor_exception_modules := $(PRODUCTS.$(INTERNAL_PRODUCT).VENDOR_EXCEPTION_MODULES) 62 endif 63 64 65 ifneq (,$(_restrictions)) 66 67 _vendor_check_modules := \ 68 $(foreach m, $(filter-out $(_vendor_exception_modules), $(product_MODULES)), \ 69 $(if $(filter-out FAKE, $(ALL_MODULES.$(m).CLASS)),\ 70 $(if $(filter vendor/%, $(ALL_MODULES.$(m).PATH)),\ 71 $(if $(filter-out $(_vendor_exception_path_prefix), $(ALL_MODULES.$(m).PATH)),\ 72 $(m))))) 73 74 _vendor_module_owner_info := 75 # Restrict owners 76 ifneq (,$(filter true owner all, $(_restrictions))) 77 78 _vendor_package_overlays := $(filter-out $(_vendor_exception_path_prefix),\ 79 $(filter vendor/%, $(PRODUCT_PACKAGE_OVERLAYS) $(DEVICE_PACKAGE_OVERLAYS))) 80 ifneq (,$(_vendor_package_overlays)) 81 $(error Error: Product "$(TARGET_PRODUCT)" cannot have overlay in vendor tree: $(_vendor_package_overlays)) 82 endif 83 _vendor_package_overlays := 84 85 _vendor_check_copy_files := $(filter-out $(_vendor_exception_path_prefix),\ 86 $(filter vendor/%, $(PRODUCT_COPY_FILES))) 87 ifneq (,$(_vendor_check_copy_files)) 88 $(foreach c, $(_vendor_check_copy_files), \ 89 $(if $(filter $(_vendor_owner_whitelist), $(call word-colon,3,$(c))),,\ 90 $(error Error: vendor PRODUCT_COPY_FILES file "$(c)" has unknown owner))\ 91 $(eval _vendor_module_owner_info += $(call word-colon,2,$(c)):$(call word-colon,3,$(c)))) 92 endif 93 _vendor_check_copy_files := 94 95 $(foreach m, $(_vendor_check_modules), \ 96 $(if $(filter $(_vendor_owner_whitelist), $(ALL_MODULES.$(m).OWNER)),,\ 97 $(error Error: vendor module "$(m)" in $(ALL_MODULES.$(m).PATH) with unknown owner \ 98 "$(ALL_MODULES.$(m).OWNER)" in product "$(TARGET_PRODUCT)"))\ 99 $(if $(ALL_MODULES.$(m).INSTALLED),\ 100 $(eval _vendor_module_owner_info += $(patsubst $(PRODUCT_OUT)/%,%,$(ALL_MODULES.$(m).INSTALLED)):$(ALL_MODULES.$(m).OWNER)))) 101 102 endif 103 104 105 # Restrict paths 106 ifneq (,$(filter path all, $(_restrictions))) 107 108 $(foreach m, $(_vendor_check_modules), \ 109 $(if $(filter-out ,$(ALL_MODULES.$(m).INSTALLED)),\ 110 $(if $(filter $(TARGET_OUT_VENDOR)/% $(TARGET_OUT_ODM)/% $(HOST_OUT)/%, $(ALL_MODULES.$(m).INSTALLED)),,\ 111 $(error Error: vendor module "$(m)" in $(ALL_MODULES.$(m).PATH) \ 112 in product "$(TARGET_PRODUCT)" being installed to \ 113 $(ALL_MODULES.$(m).INSTALLED) which is not in the vendor tree or odm tree)))) 114 115 endif 116 117 _vendor_module_owner_info_txt := $(call intermediates-dir-for,PACKAGING,vendor_owner_info)/vendor_owner_info.txt 118 $(_vendor_module_owner_info_txt): PRIVATE_INFO := $(_vendor_module_owner_info) 119 $(_vendor_module_owner_info_txt): 120 @echo "Write vendor module owner info $@" 121 @mkdir -p $(dir $@) && rm -f $@ 122 ifdef _vendor_module_owner_info 123 @for w in $(PRIVATE_INFO); \ 124 do \ 125 echo $$w >> $@; \ 126 done 127 else 128 @echo "No vendor module owner info." > $@ 129 endif 130 131 $(call dist-for-goals, droidcore, $(_vendor_module_owner_info_txt)) 132 133 _vendor_module_owner_info_txt := 134 _vendor_module_owner_info := 135 _vendor_check_modules := 136 _vendor_exception_path_prefix := 137 _vendor_exception_modules := 138 _restrictions := 139 endif 140