make/CreateJmods.gmk
branchihse-cflags-rewrite-branch
changeset 56726 3a9b7a1f9197
parent 50149 d93ae85b18c1
child 52804 28094715ae71
--- a/make/CreateJmods.gmk	Thu Mar 15 10:01:56 2018 +0100
+++ b/make/CreateJmods.gmk	Mon Jun 11 12:10:55 2018 +0200
@@ -39,16 +39,16 @@
 JMODS_DIR := $(IMAGES_OUTPUTDIR)/jmods
 JMODS_TEMPDIR := $(SUPPORT_OUTPUTDIR)/jmods
 
-LIBS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
+LIBS_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
     $(SUPPORT_OUTPUTDIR)/modules_libs $(IMPORT_MODULES_LIBS))))
-CMDS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
+CMDS_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
     $(SUPPORT_OUTPUTDIR)/modules_cmds $(IMPORT_MODULES_CMDS))))
-CONF_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
+CONF_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
     $(SUPPORT_OUTPUTDIR)/modules_conf $(IMPORT_MODULES_CONF))))
-CLASSES_DIR := $(wildcard $(JDK_OUTPUTDIR)/modules/$(MODULE))
-INCLUDE_HEADERS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
+CLASSES_DIR ?= $(wildcard $(JDK_OUTPUTDIR)/modules/$(MODULE))
+INCLUDE_HEADERS_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
     $(SUPPORT_OUTPUTDIR)/modules_include $(IMPORT_MODULES_INCLUDE_HEADERS))))
-MAN_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \
+MAN_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
     $(SUPPORT_OUTPUTDIR)/modules_man $(IMPORT_MODULES_MAN))))
 
 $(eval $(call FillCacheFind, \
@@ -80,10 +80,15 @@
   DEPS += $(call CacheFind, $(MAN_DIR))
 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 := \
-    $(call uniq, $(SUPPORT_OUTPUTDIR)/modules_legal/java.base \
-    $(call FindModuleLegalDirs, $(MODULE))) \
-    #
+    $(SUPPORT_OUTPUTDIR)/modules_legal/common \
+    $(if $(wildcard $(SUPPORT_OUTPUTDIR)/modules_legal/$(MODULE)), \
+      $(wildcard $(SUPPORT_OUTPUTDIR)/modules_legal/$(MODULE)), \
+      $(call FindModuleLegalSrcDirs, $(MODULE)) \
+    )
 
 LEGAL_NOTICES_PATH := $(call PathList, $(LEGAL_NOTICES))
 DEPS += $(call CacheFind, $(LEGAL_NOTICES))
@@ -112,6 +117,27 @@
           --hash-modules '^(?!$(EXCLUDE_PATTERN)$$)'
     endif
   endif
+else # not java.base
+  ifeq ($(OPENJDK_TARGET_OS), windows)
+    # Only java.base needs to include the MSVC*_DLLs. Make sure no other module
+    # tries to include them (typically imported ones).
+    ifneq ($(MSVCR_DLL), )
+      ifneq ($(wildcard $(LIBS_DIR)/$(notdir $(MSVCR_DLL))), )
+        JMOD_FLAGS += --exclude '$(notdir $(MSVCR_DLL))'
+      endif
+    endif
+    ifneq ($(MSVCP_DLL), )
+      ifneq ($(wildcard $(LIBS_DIR)/$(notdir $(MSVCP_DLL))), )
+        JMOD_FLAGS += --exclude '$(notdir $(MSVCP_DLL))'
+      endif
+    endif
+    ifneq ($(UCRT_DLL_DIR), )
+      UCRT_DLL_FILES := $(notdir $(wildcard $(UCRT_DLL_DIR)/*.dll))
+      ifneq ($(wildcard $(LIBS_DIR)/$(firstword $(UCRT_DLL_FILES))), )
+        JMOD_FLAGS += $(patsubst %, --exclude '%', $(UCRT_DLL_FILES))
+      endif
+    endif
+  endif
 endif
 
 # Changes to the jmod tool itself should also trigger a rebuild of all jmods.
@@ -128,18 +154,21 @@
   DEPS := $(filter-out $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/classlist, $(DEPS))
 endif
 
+JMOD_FLAGS += --exclude '**{_the.*,_*.marker,*.diz,*.debuginfo,*.dSYM/**,*.dSYM,*.pdb,*.map}'
+
 # Create jmods in a temp dir and then move them into place to keep the
 # module path in $(IMAGES_OUTPUTDIR)/jmods valid at all times.
 $(JMODS_DIR)/$(MODULE).jmod: $(DEPS)
 	$(call LogWarn, Creating $(patsubst $(OUTPUTDIR)/%, %, $@))
 	$(call MakeDir, $(JMODS_DIR) $(JMODS_TEMPDIR))
 	$(RM) $@ $(JMODS_TEMPDIR)/$(notdir $@)
-	$(JMOD) create \
-            --module-version $(VERSION_SHORT) \
-            --target-platform '$(OPENJDK_MODULE_TARGET_PLATFORM)' \
-            --module-path $(JMODS_DIR) \
-	    --exclude '**{_the.*,_*.marker,*.diz,*.debuginfo,*.dSYM/**,*.dSYM,*.pdb,*.map}' \
-	    $(JMOD_FLAGS) $(JMODS_TEMPDIR)/$(notdir $@)
+	$(call ExecuteWithLog, $(SUPPORT_OUTPUTDIR)/jmods/$(MODULE).jmod, \
+	    $(JMOD) create \
+	        --module-version $(VERSION_SHORT) \
+	        --target-platform '$(OPENJDK_MODULE_TARGET_PLATFORM)' \
+	        --module-path $(JMODS_DIR) \
+	        $(JMOD_FLAGS) $(JMODS_TEMPDIR)/$(notdir $@) \
+	)
 	$(MV) $(JMODS_TEMPDIR)/$(notdir $@) $@
 
 TARGETS += $(JMODS_DIR)/$(MODULE).jmod