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:
parent
b0dd8f00ac
commit
2962a15145
@ -472,6 +472,13 @@ jdk.localedata_COPY := _dict _th
|
||||
# data files and shouldn't go in the product
|
||||
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
|
||||
#
|
||||
|
@ -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.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,61 +28,68 @@ default: all
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
include JavaCompilation.gmk
|
||||
include Modules.gmk
|
||||
|
||||
SRC_ZIP_WORK_DIR := $(SUPPORT_OUTPUTDIR)/src
|
||||
|
||||
# Hook to include the corresponding custom file, if present.
|
||||
$(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
|
||||
SRC_ZIP_INCLUDES ?= \
|
||||
com \
|
||||
java \
|
||||
javax \
|
||||
jdk \
|
||||
org \
|
||||
sun \
|
||||
#
|
||||
# Find extra source dirs for a module that are not part of normal compilation
|
||||
# but should be included in src.zip.
|
||||
# $1: Module to find dirs for
|
||||
ExtraSrcDirs = \
|
||||
$(wildcard $(SUPPORT_OUTPUTDIR)/rmic/$(strip $1))
|
||||
|
||||
SRC_ZIP_EXCLUDES ?=
|
||||
ALL_MODULES := $(FindAllModules)
|
||||
|
||||
SRC_ZIP_SRCS += $(wildcard \
|
||||
$(JDK_TOPDIR)/src/*/share/classes \
|
||||
$(JDK_TOPDIR)/src/*/$(OPENJDK_TARGET_OS)/classes \
|
||||
$(JDK_TOPDIR)/src/*/$(OPENJDK_TARGET_OS_API_DIR)/classes \
|
||||
$(LANGTOOLS_TOPDIR)/src/*/share/classes \
|
||||
$(CORBA_TOPDIR)/src/*/share/classes \
|
||||
$(JAXP_TOPDIR)/src/*/share/classes \
|
||||
$(JAXWS_TOPDIR)/src/*/share/classes \
|
||||
$(SUPPORT_OUTPUTDIR)/gensrc/j* \
|
||||
$(SUPPORT_OUTPUTDIR)/rmic/j* \
|
||||
# Generate the src dirs in the first make invocation and then call this makefile
|
||||
# again to create src.zip.
|
||||
$(foreach m, $(ALL_MODULES), \
|
||||
$(foreach d, $(call FindModuleSrcDirs, $m) $(call ExtraSrcDirs, $m), \
|
||||
$(eval $d_TARGET := $(SRC_ZIP_WORK_DIR)/$(patsubst $(TOPDIR)/%,%,$d)/$m) \
|
||||
$(if $(SRC_GENERATED), , \
|
||||
$(eval $$($d_TARGET): $d ; \
|
||||
$$(if $(filter $(TOPDIR)/%, $d), $$(link-file-relative), $$(link-file-absolute)) \
|
||||
) \
|
||||
#
|
||||
) \
|
||||
$(eval SRC_ZIP_SRCS += $$($d_TARGET)) \
|
||||
$(eval SRC_ZIP_SRCS_$m += $$($d_TARGET)) \
|
||||
) \
|
||||
)
|
||||
|
||||
# Need to copy launcher src files into desired directory structure
|
||||
# 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*)))
|
||||
TARGETS += $(SRC_ZIP_SRCS)
|
||||
|
||||
# This dir needs to exist before macro is evaluated to avoid warning from find.
|
||||
$(call MakeDir, $(SUPPORT_OUTPUTDIR)/src)
|
||||
$(eval $(call SetupZipArchive,BUILD_SRC_ZIP, \
|
||||
SRC := $(SRC_ZIP_SRCS) $(SUPPORT_OUTPUTDIR)/src, \
|
||||
INCLUDES := $(SRC_ZIP_INCLUDES) launcher, \
|
||||
################################################################################
|
||||
# Only evaluate the creation of src.zip in a sub make call when the symlinked
|
||||
# src directory structure has been generated.
|
||||
ifeq ($(SRC_GENERATED), true)
|
||||
$(eval $(call SetupZipArchive, BUILD_SRC_ZIP, \
|
||||
SRC := $(dir $(SRC_ZIP_SRCS)), \
|
||||
INCLUDES := $(SRC_ZIP_INCLUDES), \
|
||||
INCLUDE_FILES := $(SRC_ZIP_INCLUDE_FILES), \
|
||||
EXCLUDES := $(SRC_ZIP_EXCLUDES), \
|
||||
EXCLUDE_FILES := $(SRC_ZIP_EXCLUDE_FILES), \
|
||||
SUFFIXES := .java .c .h, \
|
||||
SUFFIXES := .java, \
|
||||
ZIP := $(SUPPORT_OUTPUTDIR)/src.zip, \
|
||||
EXTRA_DEPS := $(COPY_LAUNCHER_SRC)))
|
||||
))
|
||||
|
||||
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
|
||||
|
@ -575,25 +575,21 @@ RelativePath = \
|
||||
$($(strip $1)_dotdots)/$($(strip $1)_suffix)
|
||||
|
||||
################################################################################
|
||||
# link-file-* works similarly to install file but creates a symlink instead on
|
||||
# platforms that support it. There are two versions, either creating a relative
|
||||
# or an absolute link.
|
||||
ifeq ($(OPENJDK_BUILD_OS), windows)
|
||||
link-file-absolute = $(install-file)
|
||||
link-file-relative = $(install-file)
|
||||
else
|
||||
define link-file-relative
|
||||
# link-file-* works similarly to install-file but creates a symlink instead.
|
||||
# There are two versions, either creating a relative or an absolute link. Be
|
||||
# careful when using this on Windows since the symlink created is only valid in
|
||||
# the unix emulation environment.
|
||||
define link-file-relative
|
||||
$(call MakeDir, $(@D))
|
||||
$(RM) $@
|
||||
$(LN) -s $(call RelativePath, $<, $(@D)) $@
|
||||
endef
|
||||
endef
|
||||
|
||||
define link-file-absolute
|
||||
define link-file-absolute
|
||||
$(call MakeDir, $(@D))
|
||||
$(RM) $@
|
||||
$(LN) -s $< $@
|
||||
endef
|
||||
endif
|
||||
endef
|
||||
|
||||
################################################################################
|
||||
# Filter out duplicate sub strings while preserving order. Keeps the first occurance.
|
||||
|
@ -178,6 +178,16 @@ FindAllModuleInfos = \
|
||||
$(patsubst %,%/$(strip $1)/$(sub)/module-info.java, $(TOP_SRC_DIRS))) \
|
||||
$(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
|
||||
# position of the module directory differs depending on if this is an imported
|
||||
# src dir or not.
|
||||
@ -193,6 +203,13 @@ FindAllModules = \
|
||||
$(sort $(filter-out $(MODULES_FILTER), \
|
||||
$(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 = \
|
||||
$(filter-out $(MODULES_FILTER), \
|
||||
$(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*))))
|
||||
|
@ -73,6 +73,11 @@ define SetupZipArchiveBody
|
||||
else
|
||||
$1_ZIP_INCLUDES := $$(addprefix -i$(SPACE)$(DQUOTE),$$(addsuffix /*$(DQUOTE),$$($1_INCLUDES)))
|
||||
endif
|
||||
else
|
||||
ifneq ($$($1_SUFFIXES),)
|
||||
$1_ZIP_INCLUDES := $$(foreach s,$$($1_SUFFIXES), \
|
||||
$$(addprefix -i$(SPACE)$(DQUOTE),*$$s$(DQUOTE)))
|
||||
endif
|
||||
endif
|
||||
ifneq ($$($1_INCLUDE_FILES),)
|
||||
$1_ZIP_INCLUDES += $$(addprefix -i$(SPACE),$$($1_INCLUDE_FILES))
|
||||
|
Loading…
Reference in New Issue
Block a user