Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 481b0210 authored by Colin Cross's avatar Colin Cross Committed by Gerrit Code Review
Browse files

Merge "Skip parts of notice_files.mk that don't apply to Soong modules" into main

parents 12410186 00d65a01
Loading
Loading
Loading
Loading
+100 −124
Original line number Diff line number Diff line
###########################################################
## Track NOTICE files
###########################################################
$(call record-module-type,NOTICE_FILE)

ifneq ($(LOCAL_NOTICE_FILE),)
  notice_file:=$(strip $(LOCAL_NOTICE_FILE))
@@ -9,6 +8,43 @@ else
  notice_file:=$(strip $(wildcard $(LOCAL_PATH)/LICENSE $(LOCAL_PATH)/LICENCE $(LOCAL_PATH)/NOTICE))
endif

ifeq ($(LOCAL_MODULE_CLASS),GYP)
  # We ignore NOTICE files for modules of type GYP.
  notice_file :=
endif

ifeq ($(LOCAL_MODULE_CLASS),FAKE)
  # We ignore NOTICE files for modules of type FAKE.
  notice_file :=
endif

# Soong generates stub libraries that don't need NOTICE files
ifdef LOCAL_NO_NOTICE_FILE
  ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
    $(call pretty-error,LOCAL_NO_NOTICE_FILE should not be used by Android.mk files)
  endif
  notice_file :=
endif

module_license_metadata := $(call local-meta-intermediates-dir)/$(my_register_name).meta_lic

$(foreach target,$(ALL_MODULES.$(my_register_name).BUILT) $(ALL_MODULES.$(my_register_name).INSTALLED) $(foreach bi,$(LOCAL_SOONG_BUILT_INSTALLED),$(call word-colon,1,$(bi))),\
  $(eval ALL_TARGETS.$(target).META_LIC := $(module_license_metadata)))

$(foreach f,$(my_test_data) $(my_test_config),\
  $(if $(strip $(ALL_TARGETS.$(call word-colon,1,$(f)).META_LIC)), \
    $(call declare-copy-target-license-metadata,$(call word-colon,2,$(f)),$(call word-colon,1,$(f))), \
    $(eval ALL_TARGETS.$(call word-colon,2,$(f)).META_LIC := $(module_license_metadata))))

ALL_MODULES.$(my_register_name).META_LIC := $(strip $(ALL_MODULES.$(my_register_name).META_LIC) $(module_license_metadata))

ifdef LOCAL_SOONG_LICENSE_METADATA
  # Soong modules have already produced a license metadata file, copy it to where Make expects it.
  $(eval $(call copy-one-license-metadata-file, $(LOCAL_SOONG_LICENSE_METADATA), $(module_license_metadata),$(ALL_MODULES.$(my_register_name).BUILT),$(ALL_MODUES.$(my_register_name).INSTALLED)))
else
  # Make modules don't have enough information to produce a license metadata rule until after fix-notice-deps
  # has been called, store the necessary information until later.

  ifneq (,$(strip $(LOCAL_LICENSE_PACKAGE_NAME)))
    license_package_name:=$(strip $(LOCAL_LICENSE_PACKAGE_NAME))
  else
@@ -33,37 +69,6 @@ else
    license_conditions:=by_exception_only
  endif

ifeq ($(LOCAL_MODULE_CLASS),GYP)
  # We ignore NOTICE files for modules of type GYP.
  notice_file :=
endif

ifeq ($(LOCAL_MODULE_CLASS),FAKE)
  # We ignore NOTICE files for modules of type FAKE.
  notice_file :=
endif

# Soong generates stub libraries that don't need NOTICE files
ifdef LOCAL_NO_NOTICE_FILE
  ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
    $(call pretty-error,LOCAL_NO_NOTICE_FILE should not be used by Android.mk files)
  endif
  notice_file :=
endif

ifeq ($(LOCAL_MODULE_CLASS),NOTICE_FILES)
# If this is a NOTICE-only module, we don't include base_rule.mk,
# so my_prefix is not set at this point.
ifeq ($(LOCAL_IS_HOST_MODULE),true)
  my_prefix := HOST_
  LOCAL_HOST_PREFIX :=
else
  my_prefix := TARGET_
endif
endif

installed_notice_file :=

  is_container:=$(strip $(LOCAL_MODULE_IS_CONTAINER))
  ifeq (,$(is_container))
    ifneq (,$(strip $(filter %.zip %.tar %.tgz %.tar.gz %.apk %.img %.srcszip %.apex, $(LOCAL_BUILT_MODULE))))
@@ -121,30 +126,6 @@ else
    notice_deps := $(strip $(notice_deps) $(foreach d,$(LOCAL_TARGET_REQUIRED_MODULES),$(subst :,_,$(d)):static))
  endif

local_path := $(LOCAL_PATH)


module_license_metadata :=

ifdef my_register_name
  module_license_metadata := $(call local-meta-intermediates-dir)/$(my_register_name).meta_lic

  $(foreach target,$(ALL_MODULES.$(my_register_name).BUILT) $(ALL_MODULES.$(my_register_name).INSTALLED) $(foreach bi,$(LOCAL_SOONG_BUILT_INSTALLED),$(call word-colon,1,$(bi))),\
    $(eval ALL_TARGETS.$(target).META_LIC := $(module_license_metadata)))

  $(foreach f,$(my_test_data) $(my_test_config),\
    $(if $(strip $(ALL_TARGETS.$(call word-colon,1,$(f)).META_LIC)), \
      $(call declare-copy-target-license-metadata,$(call word-colon,2,$(f)),$(call word-colon,1,$(f))), \
      $(eval ALL_TARGETS.$(call word-colon,2,$(f)).META_LIC := $(module_license_metadata))))

  ALL_MODULES.$(my_register_name).META_LIC := $(strip $(ALL_MODULES.$(my_register_name).META_LIC) $(module_license_metadata))

  ifdef LOCAL_SOONG_LICENSE_METADATA
    # Soong modules have already produced a license metadata file, copy it to where Make expects it.
    $(eval $(call copy-one-license-metadata-file, $(LOCAL_SOONG_LICENSE_METADATA), $(module_license_metadata),$(ALL_MODULES.$(my_register_name).BUILT),$(ALL_MODUES.$(my_register_name).INSTALLED)))
  else
    # Make modules don't have enough information to produce a license metadata rule until after fix-notice-deps
    # has been called, store the necessary information until later.
  ALL_MODULES.$(my_register_name).DELAYED_META_LIC := $(strip $(ALL_MODULES.$(my_register_name).DELAYED_META_LIC) $(module_license_metadata))
  ALL_MODULES.$(my_register_name).LICENSE_PACKAGE_NAME := $(strip $(license_package_name))
  ALL_MODULES.$(my_register_name).MODULE_TYPE := $(strip $(ALL_MODULES.$(my_register_name).MODULE_TYPE) $(LOCAL_MODULE_TYPE))
@@ -156,12 +137,7 @@ ifdef my_register_name
  ALL_MODULES.$(my_register_name).IS_CONTAINER := $(strip $(filter-out false,$(ALL_MODULES.$(my_register_name).IS_CONTAINER) $(is_container)))
  ALL_MODULES.$(my_register_name).PATH := $(strip $(ALL_MODULES.$(my_register_name).PATH) $(local_path))
endif
endif

ifdef notice_file

ifdef my_register_name
ALL_MODULES.$(my_register_name).NOTICES := $(ALL_MODULES.$(my_register_name).NOTICES) $(notice_file)
endif

endif  # notice_file