8062810: Examine src.zip in JDK image and decide if source classes should be organized by module

Reviewed-by: mchung, kcr
This commit is contained in:
Erik Joelsson 2016-10-28 14:29:20 +02:00
parent b0dd8f00ac
commit 2962a15145
5 changed files with 88 additions and 56 deletions

View File

@ -472,6 +472,13 @@ jdk.localedata_COPY := _dict _th
# data files and shouldn't go in the product # data files and shouldn't go in the product
jdk.localedata_EXCLUDE_FILES += sun/text/resources/ext/BreakIteratorRules_th.java jdk.localedata_EXCLUDE_FILES += sun/text/resources/ext/BreakIteratorRules_th.java
################################################################################
# If this is an imported module that has prebuilt classes, only compile
# module-info.java.
ifneq ($(wildcard $(IMPORT_MODULES_CLASSES)/$(MODULE)), )
$(MODULE)_INCLUDE_FILES := module-info.java
endif
################################################################################ ################################################################################
# Setup the compilation for the module # Setup the compilation for the module
# #

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
@ -28,61 +28,68 @@ default: all
include $(SPEC) include $(SPEC)
include MakeBase.gmk include MakeBase.gmk
include JavaCompilation.gmk include JavaCompilation.gmk
include Modules.gmk
SRC_ZIP_WORK_DIR := $(SUPPORT_OUTPUTDIR)/src
# Hook to include the corresponding custom file, if present. # Hook to include the corresponding custom file, if present.
$(eval $(call IncludeCustomExtension, , ZipSource.gmk)) $(eval $(call IncludeCustomExtension, , ZipSource.gmk))
################################################################################ ################################################################################
# Create the directory structure for src.zip using symlinks.
# <module>/<package>/<file>.java
# Use ?= to enable override in custom makefile # Find extra source dirs for a module that are not part of normal compilation
SRC_ZIP_INCLUDES ?= \ # but should be included in src.zip.
com \ # $1: Module to find dirs for
java \ ExtraSrcDirs = \
javax \ $(wildcard $(SUPPORT_OUTPUTDIR)/rmic/$(strip $1))
jdk \
org \
sun \
#
SRC_ZIP_EXCLUDES ?= ALL_MODULES := $(FindAllModules)
SRC_ZIP_SRCS += $(wildcard \ # Generate the src dirs in the first make invocation and then call this makefile
$(JDK_TOPDIR)/src/*/share/classes \ # again to create src.zip.
$(JDK_TOPDIR)/src/*/$(OPENJDK_TARGET_OS)/classes \ $(foreach m, $(ALL_MODULES), \
$(JDK_TOPDIR)/src/*/$(OPENJDK_TARGET_OS_API_DIR)/classes \ $(foreach d, $(call FindModuleSrcDirs, $m) $(call ExtraSrcDirs, $m), \
$(LANGTOOLS_TOPDIR)/src/*/share/classes \ $(eval $d_TARGET := $(SRC_ZIP_WORK_DIR)/$(patsubst $(TOPDIR)/%,%,$d)/$m) \
$(CORBA_TOPDIR)/src/*/share/classes \ $(if $(SRC_GENERATED), , \
$(JAXP_TOPDIR)/src/*/share/classes \ $(eval $$($d_TARGET): $d ; \
$(JAXWS_TOPDIR)/src/*/share/classes \ $$(if $(filter $(TOPDIR)/%, $d), $$(link-file-relative), $$(link-file-absolute)) \
$(SUPPORT_OUTPUTDIR)/gensrc/j* \ ) \
$(SUPPORT_OUTPUTDIR)/rmic/j* \
) \ ) \
# $(eval SRC_ZIP_SRCS += $$($d_TARGET)) \
$(eval SRC_ZIP_SRCS_$m += $$($d_TARGET)) \
) \
)
# Need to copy launcher src files into desired directory structure TARGETS += $(SRC_ZIP_SRCS)
# before zipping the sources.
$(eval $(call SetupCopyFiles,COPY_LAUNCHER_SRC, \
SRC := $(JDK_TOPDIR)/src/java.base, \
DEST := $(SUPPORT_OUTPUTDIR)/src/launcher, \
FLATTEN := true, \
FILES := $(wildcard \
$(JDK_TOPDIR)/src/java.base/share/native/launcher/* \
$(JDK_TOPDIR)/src/java.base/share/native/libjli/* \
$(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_API_DIR)/native/libjli/java_md*)))
# This dir needs to exist before macro is evaluated to avoid warning from find. ################################################################################
$(call MakeDir, $(SUPPORT_OUTPUTDIR)/src) # Only evaluate the creation of src.zip in a sub make call when the symlinked
$(eval $(call SetupZipArchive,BUILD_SRC_ZIP, \ # src directory structure has been generated.
SRC := $(SRC_ZIP_SRCS) $(SUPPORT_OUTPUTDIR)/src, \ ifeq ($(SRC_GENERATED), true)
INCLUDES := $(SRC_ZIP_INCLUDES) launcher, \ $(eval $(call SetupZipArchive, BUILD_SRC_ZIP, \
EXCLUDES := $(SRC_ZIP_EXCLUDES), \ SRC := $(dir $(SRC_ZIP_SRCS)), \
EXCLUDE_FILES := $(SRC_ZIP_EXCLUDE_FILES), \ INCLUDES := $(SRC_ZIP_INCLUDES), \
SUFFIXES := .java .c .h, \ INCLUDE_FILES := $(SRC_ZIP_INCLUDE_FILES), \
ZIP := $(SUPPORT_OUTPUTDIR)/src.zip, \ EXCLUDES := $(SRC_ZIP_EXCLUDES), \
EXTRA_DEPS := $(COPY_LAUNCHER_SRC))) EXCLUDE_FILES := $(SRC_ZIP_EXCLUDE_FILES), \
SUFFIXES := .java, \
ZIP := $(SUPPORT_OUTPUTDIR)/src.zip, \
))
do-zip: $(BUILD_SRC_ZIP)
.PHONY: do-zip
endif
zip: $(SRC_ZIP_SRCS)
+$(MAKE) $(MAKE_ARGS) -f ZipSource.gmk do-zip SRC_GENERATED=true
TARGETS += zip
################################################################################ ################################################################################
all: $(BUILD_SRC_ZIP) all: $(TARGETS)
.PHONY: default all .PHONY: default all zip

View File

@ -575,25 +575,21 @@ RelativePath = \
$($(strip $1)_dotdots)/$($(strip $1)_suffix) $($(strip $1)_dotdots)/$($(strip $1)_suffix)
################################################################################ ################################################################################
# link-file-* works similarly to install file but creates a symlink instead on # link-file-* works similarly to install-file but creates a symlink instead.
# platforms that support it. There are two versions, either creating a relative # There are two versions, either creating a relative or an absolute link. Be
# or an absolute link. # careful when using this on Windows since the symlink created is only valid in
ifeq ($(OPENJDK_BUILD_OS), windows) # the unix emulation environment.
link-file-absolute = $(install-file) define link-file-relative
link-file-relative = $(install-file)
else
define link-file-relative
$(call MakeDir, $(@D)) $(call MakeDir, $(@D))
$(RM) $@ $(RM) $@
$(LN) -s $(call RelativePath, $<, $(@D)) $@ $(LN) -s $(call RelativePath, $<, $(@D)) $@
endef endef
define link-file-absolute define link-file-absolute
$(call MakeDir, $(@D)) $(call MakeDir, $(@D))
$(RM) $@ $(RM) $@
$(LN) -s $< $@ $(LN) -s $< $@
endef endef
endif
################################################################################ ################################################################################
# Filter out duplicate sub strings while preserving order. Keeps the first occurance. # Filter out duplicate sub strings while preserving order. Keeps the first occurance.

View File

@ -178,6 +178,16 @@ FindAllModuleInfos = \
$(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \ $(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \
$(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC))) $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC)))
# Find module-info.java files in the specific source dir
# Param 1 - Src dir to find module-info.java files in
FindModuleInfosForSrcDir = \
$(wildcard \
$(foreach sub, $(SRC_SUBDIRS), \
$(patsubst %,%/*/$(sub)/module-info.java, $(strip $1)) \
) \
$(patsubst %,%/*/module-info.java, $(strip $1)) \
)
# Extract the module names from the paths of module-info.java files. The # Extract the module names from the paths of module-info.java files. The
# position of the module directory differs depending on if this is an imported # position of the module directory differs depending on if this is an imported
# src dir or not. # src dir or not.
@ -193,6 +203,13 @@ FindAllModules = \
$(sort $(filter-out $(MODULES_FILTER), \ $(sort $(filter-out $(MODULES_FILTER), \
$(call GetModuleNameFromModuleInfo, $(MODULE_INFOS)))) $(call GetModuleNameFromModuleInfo, $(MODULE_INFOS))))
# Find all modules in a specific src dir
# Param 1 - Src dir to find modules in
FindModulesForSrcDir = \
$(sort $(filter-out $(MODULES_FILTER), \
$(call GetModuleNameFromModuleInfo, $(call FindModuleInfosForSrcDir, $1)) \
))
FindImportedModules = \ FindImportedModules = \
$(filter-out $(MODULES_FILTER), \ $(filter-out $(MODULES_FILTER), \
$(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*)))) $(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*))))

View File

@ -73,6 +73,11 @@ define SetupZipArchiveBody
else else
$1_ZIP_INCLUDES := $$(addprefix -i$(SPACE)$(DQUOTE),$$(addsuffix /*$(DQUOTE),$$($1_INCLUDES))) $1_ZIP_INCLUDES := $$(addprefix -i$(SPACE)$(DQUOTE),$$(addsuffix /*$(DQUOTE),$$($1_INCLUDES)))
endif endif
else
ifneq ($$($1_SUFFIXES),)
$1_ZIP_INCLUDES := $$(foreach s,$$($1_SUFFIXES), \
$$(addprefix -i$(SPACE)$(DQUOTE),*$$s$(DQUOTE)))
endif
endif endif
ifneq ($$($1_INCLUDE_FILES),) ifneq ($$($1_INCLUDE_FILES),)
$1_ZIP_INCLUDES += $$(addprefix -i$(SPACE),$$($1_INCLUDE_FILES)) $1_ZIP_INCLUDES += $$(addprefix -i$(SPACE),$$($1_INCLUDE_FILES))