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