vendor_module_check.mk revision bbd499821623c412c5ccb26da3df441b46082823
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	broadcom \
20	csr \
21	imgtec \
22	invensense \
23	nxp \
24	samsung \
25	samsung_arm \
26	ti
27
28
29ifneq (,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RESTRICT_VENDOR_FILES))
30
31_check_modules := $(sort $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES))
32
33# expand with the required modules
34# $(1) the module name set to expand
35define _expand_required_modules
36$(eval _erm_new_modules:=)\
37$(foreach m, $(1), $(eval r:=$(ALL_MODULES.$(m).REQUIRED))\
38  $(if $(r), $(if $(filter $(_check_modules), $(r)),,\
39    $(eval _check_modules := $(_check_modules) $(r))\
40    $(eval _erm_new_modules := $(_erm_new_modules) $(r)))))\
41$(if $(_erm_new_modules), $(call _expand_required_modules, $(_erm_new_modules)))
42endef
43
44$(call _expand_required_modules, $(_check_modules))
45
46
47# Restrict owners
48ifneq (,$(filter true owner all, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RESTRICT_VENDOR_FILES)))
49
50ifneq (,$(filter vendor/%, $(PRODUCT_PACKAGE_OVERLAYS) $(DEVICE_PACKAGE_OVERLAYS)))
51$(error Error: Product "$(TARGET_PRODUCT)" can not have overlay in vendor tree: \
52    $(filter vendor/%, $(PRODUCT_PACKAGE_OVERLAYS) $(DEVICE_PACKAGE_OVERLAYS)))
53endif
54ifneq (,$(filter vendor/%, $(PRODUCT_COPY_FILES)))
55$(error Error: Product "$(TARGET_PRODUCT)" can not have PRODUCT_COPY_FILES from vendor tree: \
56    $(filter vendor/%, $(PRODUCT_COPY_FILES)))
57endif
58
59$(foreach m, $(_check_modules), \
60  $(if $(filter vendor/%, $(ALL_MODULES.$(m).PATH)),\
61    $(if $(filter $(_vendor_owner_whitelist), $(ALL_MODULES.$(m).OWNER)),,\
62      $(error Error: vendor module "$(m)" in $(ALL_MODULES.$(m).PATH) with unknown owner \
63        "$(ALL_MODULES.$(m).OWNER)" in product "$(TARGET_PRODUCT)"))))
64
65endif
66
67
68# Restrict paths
69ifneq (,$(filter path all, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RESTRICT_VENDOR_FILES)))
70
71$(foreach m, $(_check_modules), \
72  $(if $(filter vendor/%, $(ALL_MODULES.$(m).PATH)),\
73    $(if $(filter $(TARGET_OUT_VENDOR)/%, $(ALL_MODULES.$(m).INSTALLED)),,\
74      $(error Error: vendor module "$(m)" in $(ALL_MODULES.$(m).PATH) \
75        in product "$(TARGET_PRODUCT)" being installed to \
76        $(ALL_MODULES.$(m).INSTALLED) which is not in the vendor tree))))
77
78endif
79
80endif
81