8199539: Provide a standard way for the build to filter un-needed legal .md files

Reviewed-by: tbell, ihse
This commit is contained in:
Erik Joelsson 2018-04-05 23:46:05 +02:00
parent e17e623bd4
commit 98cd47840a
5 changed files with 81 additions and 8 deletions

View File

@ -80,10 +80,15 @@ ifneq ($(MAN_DIR), )
DEPS += $(call CacheFind, $(MAN_DIR)) DEPS += $(call CacheFind, $(MAN_DIR))
endif endif
# If a specific modules_legal dir exists for this module, only pick up files
# from there. These files were explicitly filtered or modified in <module>-copy
# targets. For the rest, just pick up everything from the source legal dirs.
LEGAL_NOTICES := \ LEGAL_NOTICES := \
$(call uniq, $(SUPPORT_OUTPUTDIR)/modules_legal/java.base \ $(SUPPORT_OUTPUTDIR)/modules_legal/common \
$(call FindModuleLegalDirs, $(MODULE))) \ $(if $(wildcard $(SUPPORT_OUTPUTDIR)/modules_legal/$(MODULE)), \
# $(wildcard $(SUPPORT_OUTPUTDIR)/modules_legal/$(MODULE)), \
$(call FindModuleLegalSrcDirs, $(MODULE)) \
)
LEGAL_NOTICES_PATH := $(call PathList, $(LEGAL_NOTICES)) LEGAL_NOTICES_PATH := $(call PathList, $(LEGAL_NOTICES))
DEPS += $(call CacheFind, $(LEGAL_NOTICES)) DEPS += $(call CacheFind, $(LEGAL_NOTICES))

View File

@ -394,12 +394,11 @@ ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE))
endif endif
LEGAL_SUBDIRS += share/legal LEGAL_SUBDIRS += share/legal
# Find all legal dirs for a particular module # Find all legal src dirs for a particular module
# $1 - Module to find legal dirs for # $1 - Module to find legal dirs for
FindModuleLegalDirs = \ FindModuleLegalSrcDirs = \
$(strip $(wildcard \ $(strip $(wildcard \
$(addsuffix /$(strip $1), $(SUPPORT_OUTPUTDIR)/modules_legal \ $(addsuffix /$(strip $1), $(IMPORT_MODULES_LEGAL)) \
$(IMPORT_MODULES_LEGAL)) \
$(foreach sub, $(LEGAL_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS))) \ $(foreach sub, $(LEGAL_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS))) \
)) ))

View File

@ -24,6 +24,7 @@
# #
include CopyCommon.gmk include CopyCommon.gmk
include Modules.gmk
include TextFileProcessing.gmk include TextFileProcessing.gmk
$(eval $(call IncludeCustomExtension, copy/Copy-java.base.gmk)) $(eval $(call IncludeCustomExtension, copy/Copy-java.base.gmk))
@ -224,12 +225,27 @@ JDK_ADDITIONAL_LICENSE_INFO ?= $(wildcard $(TOPDIR)/ADDITIONAL_LICENSE_INFO)
$(eval $(call SetupCopyFiles, COPY_JDK_NOTICES, \ $(eval $(call SetupCopyFiles, COPY_JDK_NOTICES, \
FILES := $(JDK_LICENSE) $(JDK_NOTICE) $(JDK_ADDITIONAL_LICENSE_INFO), \ FILES := $(JDK_LICENSE) $(JDK_NOTICE) $(JDK_ADDITIONAL_LICENSE_INFO), \
DEST := $(LEGAL_DST_DIR), \ DEST := $(COMMON_LEGAL_DST_DIR), \
FLATTEN := true, \ FLATTEN := true, \
)) ))
TARGETS += $(COPY_JDK_NOTICES) TARGETS += $(COPY_JDK_NOTICES)
################################################################################
#
# Copy and filter the legal files depending on what 3rd party components are
# bundled or linked from the OS.
#
ifeq ($(USE_EXTERNAL_LIBZ), true)
LEGAL_EXCLUDES += zlib.md
endif
$(eval $(call SetupCopyLegalFiles, COPY_LEGAL, \
EXCLUDES := $(LEGAL_EXCLUDES), \
))
TARGETS += $(COPY_LEGAL)
################################################################################ ################################################################################
# Optionally copy libffi.so.? into the the image # Optionally copy libffi.so.? into the the image

View File

@ -24,6 +24,7 @@
# #
include CopyCommon.gmk include CopyCommon.gmk
include Modules.gmk
$(eval $(call IncludeCustomExtension, copy/Copy-java.desktop.gmk)) $(eval $(call IncludeCustomExtension, copy/Copy-java.desktop.gmk))
@ -48,3 +49,34 @@ $(LIB_DST_DIR)/%: $(PSFONTPROPFILE_SRC_DIR)/%
TARGETS += $(PSFONTPROPFILE_TARGET_FILES) TARGETS += $(PSFONTPROPFILE_TARGET_FILES)
################################################################################ ################################################################################
#
# Copy and filter the legal files depending on what 3rd party components are
# bundled or linked from the OS.
#
ifeq ($(USE_EXTERNAL_LIBJPEG), true)
LEGAL_EXCLUDES += jpeg.md
endif
ifeq ($(USE_EXTERNAL_LIBGIF), true)
LEGAL_EXCLUDES += giflib.md
endif
ifeq ($(USE_EXTERNAL_LIBPNG), true)
LEGAL_EXCLUDES += libpng.md
endif
ifeq ($(USE_EXTERNAL_LCMS), true)
LEGAL_EXCLUDES += lcms.md
endif
ifeq ($(FREETYPE_TO_USE), system)
LEGAL_EXCLUDES += freetype.md
endif
$(eval $(call SetupCopyLegalFiles, COPY_LEGAL, \
EXCLUDES := $(LEGAL_EXCLUDES), \
))
TARGETS += $(COPY_LEGAL)
################################################################################

View File

@ -26,6 +26,7 @@
LIB_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE) LIB_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)
CONF_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_conf/$(MODULE) CONF_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_conf/$(MODULE)
LEGAL_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_legal/$(MODULE) LEGAL_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_legal/$(MODULE)
COMMON_LEGAL_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_legal/common
################################################################################ ################################################################################
# #
@ -60,3 +61,23 @@ ifneq ($(wildcard $(INCLUDE_SOURCE_OS_DIR)/*), )
TARGETS += $(COPY_EXPORTED_INCLUDE_OS) TARGETS += $(COPY_EXPORTED_INCLUDE_OS)
endif endif
################################################################################
# Setup make rules for copying legal files. This is only needed if the files
# need to be filtered due to optional components being enabled/disabled.
# Otherwise CreateJmods.gmk will find the legal files in the original src dirs.
#
# Parameter 1 is the name of the rule.
#
# Remaining parameters are named arguments. These include:
# EXCLUDES : List of filenames to exclude from copy
SetupCopyLegalFiles = $(NamedParamsMacroTemplate)
define SetupCopyLegalFilesBody
$$(eval $$(call SetupCopyFiles, $1, \
SRC := $$(CUSTOM_ROOT), \
DEST := $$(LEGAL_DST_DIR), \
FILES := $$(filter-out $$(addprefix %/, $$($1_EXCLUDES)), \
$$(wildcard $$(addsuffix /*, $$(call FindModuleLegalSrcDirs, $$(MODULE))))), \
FLATTEN := true, \
))
endef