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