github.com/westcoastroms/westcoastroms-build@v0.0.0-20190928114312-2350e5a73030/build/make/core/tasks/vendor_module_check.mk (about)

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