Adding SetupExecute to more places, and adding functionality. ihse-setupexecute-branch
authorihse
Thu, 07 Feb 2019 19:35:33 +0100
branchihse-setupexecute-branch
changeset 57159 0258a6f7d03f
parent 57158 003703d03633
child 57162 e1a04d30f1c7
Adding SetupExecute to more places, and adding functionality.
make/CreateJmods.gmk
make/ExplodedImageOptimize.gmk
make/Main.gmk
make/UpdateX11Wrappers.gmk
make/common/Execute.gmk
make/gensrc/GensrcCommonJdk.gmk
make/gensrc/GensrcX11Wrappers.gmk
--- a/make/CreateJmods.gmk	Thu Feb 07 13:04:38 2019 +0100
+++ b/make/CreateJmods.gmk	Thu Feb 07 19:35:33 2019 +0100
@@ -26,6 +26,7 @@
 
 include $(SPEC)
 include MakeBase.gmk
+include Execute.gmk
 include Modules.gmk
 
 ifeq ($(MODULE), )
@@ -37,7 +38,8 @@
 ################################################################################
 
 JMODS_DIR := $(IMAGES_OUTPUTDIR)/jmods
-JMODS_TEMPDIR := $(SUPPORT_OUTPUTDIR)/jmods
+JMODS_SUPPORT_DIR := $(SUPPORT_OUTPUTDIR)/jmods
+JMOD_FILE := $(MODULE).jmod
 
 LIBS_DIR ?= $(firstword $(wildcard $(addsuffix /$(MODULE), \
     $(SUPPORT_OUTPUTDIR)/modules_libs $(IMPORT_MODULES_LIBS))))
@@ -156,22 +158,22 @@
 
 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
+# Create jmods in the support 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 $@)
-	$(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 $@) $@
+$(eval $(call SetupExecute, create_$(JMOD_FILE), \
+    WARN := Creating $(JMOD_FILE), \
+    DEPS := $(DEPS), \
+    OUTPUT_FILE := $(JMODS_DIR)/$(JMOD_FILE), \
+    SUPPORT_DIR := $(JMODS_SUPPORT_DIR), \
+    PRE_COMMAND := $(RM) $(JMODS_DIR)/$(JMOD_FILE) $(JMODS_SUPPORT_DIR)/$(JMOD_FILE), \
+    COMMAND := $(JMOD) create --module-version $(VERSION_SHORT) \
+        --target-platform '$(OPENJDK_MODULE_TARGET_PLATFORM)' \
+        --module-path $(JMODS_DIR) $(JMOD_FLAGS) \
+        $(JMODS_SUPPORT_DIR)/$(JMOD_FILE), \
+    POST_COMMAND := $(MV) $(JMODS_SUPPORT_DIR)/$(JMOD_FILE) $(JMODS_DIR)/$(JMOD_FILE), \
+))
 
-TARGETS += $(JMODS_DIR)/$(MODULE).jmod
+TARGETS += $(create_$(JMOD_FILE))
 
 ################################################################################
 
--- a/make/ExplodedImageOptimize.gmk	Thu Feb 07 13:04:38 2019 +0100
+++ b/make/ExplodedImageOptimize.gmk	Thu Feb 07 19:35:33 2019 +0100
@@ -29,19 +29,21 @@
 
 include $(SPEC)
 include MakeBase.gmk
+include Execute.gmk
 include $(TOPDIR)/make/ModuleTools.gmk
 
 ################################################################################
 
-PACKAGES_ATTRIBUTE_TARGET := $(JDK_OUTPUTDIR)/_packages_attribute.done
 ALL_MODULEINFO_CLASSES := $(wildcard $(JDK_OUTPUTDIR)/modules/*/module-info.class)
 
-$(PACKAGES_ATTRIBUTE_TARGET): $(ALL_MODULEINFO_CLASSES) $(BUILD_JIGSAW_CLASSES)
-	$(call LogInfo, Optimizing the exploded image)
-	$(call ExecuteWithLog, $@, $(TOOL_ADD_PACKAGES_ATTRIBUTE) $(JDK_OUTPUTDIR))
-	$(TOUCH) $@
+$(eval $(call SetupExecute, optimize_image, \
+    INFO := Optimizing the exploded image, \
+    DEPS := $(ALL_MODULEINFO_CLASSES) $(BUILD_JIGSAW_CLASSES), \
+    OUTPUT_DIR := $(JDK_OUTPUTDIR), \
+    COMMAND := $(TOOL_ADD_PACKAGES_ATTRIBUTE) $(JDK_OUTPUTDIR), \
+))
 
-TARGETS := $(PACKAGES_ATTRIBUTE_TARGET)
+TARGETS := $(optimize_image_TARGET)
 
 ################################################################################
 
--- a/make/Main.gmk	Thu Feb 07 13:04:38 2019 +0100
+++ b/make/Main.gmk	Thu Feb 07 19:35:33 2019 +0100
@@ -456,7 +456,7 @@
 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CreateJmods.gmk \
 	    MODULE=$1 \
 	    JMODS_DIR=$(INTERIM_JMODS_DIR) \
-	    JMODS_TEMPDIR=$(INTERIM_JMODS_DIR)/temp \
+	    JMODS_SUPPORT_DIR=$(INTERIM_JMODS_DIR)/support \
 	    INTERIM_JMOD=true \
 	)
 endef
--- a/make/UpdateX11Wrappers.gmk	Thu Feb 07 13:04:38 2019 +0100
+++ b/make/UpdateX11Wrappers.gmk	Thu Feb 07 19:35:33 2019 +0100
@@ -29,6 +29,7 @@
 
 include $(SPEC)
 include MakeBase.gmk
+include Execute.gmk
 include NativeCompilation.gmk
 include ToolsJdk.gmk
 
@@ -47,17 +48,21 @@
 endif
 
 X11WRAPPERS_OUTPUT := $(SUPPORT_OUTPUTDIR)/x11wrappers
+GENERATOR_SOURCE_FILE := $(X11WRAPPERS_OUTPUT)/src/data_generator.c
 
 GENSRC_X11WRAPPERS_DATADIR := $(TOPDIR)/make/data/x11wrappergen
+WRAPPER_OUTPUT_FILE := $(GENSRC_X11WRAPPERS_DATADIR)/sizes-$(BITS).txt
 
 BITS := $(OPENJDK_TARGET_CPU_BITS)
 
 # Generate the C code for the program that will output the offset file.
-$(X11WRAPPERS_OUTPUT)/src/data_generator.c: $(GENSRC_X11WRAPPERS_DATADIR)/xlibtypes.txt $(BUILD_TOOLS_JDK)
-	$(call LogInfo, Generating X11 wrapper data generator source code)
-	$(call MakeDir, $(@D))
-	$(call ExecuteWithLog, $@, \
-	    $(TOOL_WRAPPERGENERATOR) gen_c_source $@ $(GENSRC_X11WRAPPERS_DATADIR)/xlibtypes.txt $(BITS))
+$(eval $(call SetupExecute, gensrc_generator, \
+    INFO := Generating X11 wrapper data generator source code, \
+    DEPS := $(GENSRC_X11WRAPPERS_DATADIR)/xlibtypes.txt $(BUILD_TOOLS_JDK), \
+    OUTPUT_FILE := $(GENERATOR_SOURCE_FILE), \
+    COMMAND := $(TOOL_WRAPPERGENERATOR) gen_c_source $(GENERATOR_SOURCE_FILE) \
+        $(GENSRC_X11WRAPPERS_DATADIR)/xlibtypes.txt $(BITS), \
+))
 
 DATA_GENERATOR_INCLUDES := \
     -I$(TOPDIR)/src/hotspot/share/include \
@@ -75,7 +80,7 @@
 $(eval $(call SetupNativeCompilation, BUILD_DATA_GENERATOR, \
     PROGRAM := data_generator, \
     OUTPUT_DIR := $(X11WRAPPERS_OUTPUT)/bin, \
-    EXTRA_FILES := $(X11WRAPPERS_OUTPUT)/src/data_generator.c, \
+    EXTRA_FILES := $(GENERATOR_SOURCE_FILE), \
     CFLAGS := $(X_CFLAGS) $(DATA_GENERATOR_INCLUDES) $(CFLAGS_JDKEXE), \
     LDFLAGS := $(LDFLAGS_JDKEXE), \
     LIBS := $(X_LIBS), \
@@ -83,16 +88,19 @@
 ))
 
 # Run the executable to create the data file.
-$(GENSRC_X11WRAPPERS_DATADIR)/sizes-$(BITS).txt: $(BUILD_DATA_GENERATOR_TARGET)
-	$(call LogInfo, Generating X11 wrapper data files)
-	$(call MakeDir, $(@D))
-	$(call ExecuteWithLog, $(X11WRAPPERS_OUTPUT)/generation, \
-	    $(BUILD_DATA_GENERATOR_TARGET) | $(SORT) > $@)
+$(eval $(call SetupExecute, run_wrappergen, \
+    INFO := Generating X11 wrapper data files, \
+    DEPS := $(BUILD_DATA_GENERATOR), \
+    OUTPUT_FILE := $(WRAPPER_OUTPUT_FILE), \
+    COMMAND := $(BUILD_DATA_GENERATOR_TARGET) | $(SORT) > $(WRAPPER_OUTPUT_FILE), \
+))
+
+wrapper-information: $(run_wrappergen)
 	$(ECHO) IMPORTANT: If you update the X11 wrapper data files, they most certainly
 	$(ECHO) need to be updated for both 32 and 64 bit platforms. You have now
 	$(ECHO) updated them for $(BITS) bit platforms only.
 
-TARGETS += $(GENSRC_X11WRAPPERS_DATADIR)/sizes-$(BITS).txt
+TARGETS += $(run_wrappergen) wrapper-information
 
 ################################################################################
 
--- a/make/common/Execute.gmk	Thu Feb 07 13:04:38 2019 +0100
+++ b/make/common/Execute.gmk	Thu Feb 07 19:35:33 2019 +0100
@@ -42,10 +42,13 @@
 #
 # Remaining parameters are named arguments. These include:
 #   COMMAND     : The command to execute
+#   PRE_COMMAND :
 #   POST_COMMAND:
 #   OUTPUT_DIR  : The directory that will contain the result from the command
+#   SUPPORT_DIR :
 #   OUTPUT_FILE : Use this if the command results in a single output file.
 #   INFO        : Message to display at LOG=info level when running command (optional).
+#   WARN        : Message to display at LOG=warn level when running command (optional).
 #   DEPS        : Dependencies for the execution to take place
 #
 
@@ -60,48 +63,104 @@
     ifneq ($$($1_OUTPUT_DIR), )
       $$(error Cannot specify both OUTPUT_DIR and OUTPUT_FILE in SetupExecute $1)
     endif
+    # We need to know output dir since we will make sure it is created.
     $1_OUTPUT_DIR := $$(patsubst %/,%, $$(dir $$($1_OUTPUT_FILE)))
-  else ifeq ($$($1_OUTPUT_DIR), )
+    ifeq ($$($1_SUPPORT_DIR), )
+      # If support dir is not given, use base dir of output file.
+      $1_SUPPORT_DIR := $$($1_OUTPUT_DIR)
+    endif
+  else ifneq ($$($1_OUTPUT_DIR), )
+    ifeq ($$($1_SUPPORT_DIR), )
+      # If support dir is not given, use output dir.
+      $1_SUPPORT_DIR := $$($1_OUTPUT_DIR)
+    endif
+  else
     $$(error OUTPUT_DIR or OUTPUT_FILE is required in SetupExecute $1)
   endif
 
-  $1_BASE := $$($1_OUTPUT_DIR)/_$1
-  $1_MARKER := $$($1_BASE).marker
+  $1_BASE := $$($1_SUPPORT_DIR)/_$1
+  $1_PRE_MARKER := $$($1_BASE)_pre.marker
+  $1_EXEC_MARKER := $$($1_BASE)_exec.marker
+  $1_POST_MARKER := $$($1_BASE)_post.marker
 
   ifeq ($$($1_OUTPUT_FILE), )
-    $1_RESULT := $$($1_MARKER)
+    # No specified output file, use markers everywhere
+    $1_EXEC_RESULT := $$($1_EXEC_MARKER)
+    ifeq ($$($1_POST_COMMAND), )
+      $1_FINAL_RESULT := $$($1_EXEC_MARKER)
+    else
+      $1_FINAL_RESULT := $$($1_POST_MARKER)
+    endif
+
   else
     # If we have a single output file, we don't need a separate marker
-    $1_RESULT := $$($1_OUTPUT_FILE)
+
+    ifeq ($$($1_POST_COMMAND), )
+      $1_EXEC_RESULT := $$($1_OUTPUT_FILE)
+      $1_FINAL_RESULT := $$($1_EXEC_RESULT)
+    else
+      $1_EXEC_RESULT := $$($1_EXEC_MARKER)
+      $1_FINAL_RESULT := $$($1_OUTPUT_FILE)
+    endif
+
   endif
 
-  ifeq ($$($1_INFO), )
+  ifeq ($$($1_INFO)$$($1_WARN), )
+    # If neither info nor warn is provided, add basic info text.
     $1_INFO := Running commands for $1
   endif
 
-  $$($1_RESULT): $$($1_DEPS)
-	$$(call LogInfo, $$($1_INFO))
-	$$(call MakeDir, $$(@D))
-	$$(call ExecuteWithLog, $$($1_BASE), \
+  ifneq ($$($1_PRE_COMMAND), )
+
+    $$($1_PRE_MARKER): $$($1_DEPS)
+        ifneq ($$($1_WARN), )
+	  $$(call LogWarn, $$($1_WARN))
+        endif
+        ifneq ($$($1_INFO), )
+	  $$(call LogInfo, $$($1_INFO))
+        endif
+	$$(call MakeDir, $$($1_SUPPORT_DIR) $$($1_OUTPUT_DIR))
+	$$(call ExecuteWithLog, $$($1_BASE)_pre, \
+	    $$($1_PRE_COMMAND))
+	$$(TOUCH) $$@
+
+    $$($1_EXEC_RESULT): $$($1_PRE_MARKER)
+	$$(call ExecuteWithLog, $$($1_BASE)_exec, \
 	    $$($1_COMMAND))
-        ifeq ($$($1_RESULT), $$($1_MARKER))
+        ifeq ($$($1_EXEC_RESULT), $$($1_EXEC_MARKER))
 	  $$(TOUCH) $$@
         endif
 
-  # Export all our generated targets in $1, and the final target in $1_TARGET.
-  $1 := $$($1_RESULT)
-  $1_TARGET := $$($1_RESULT)
+    $1 := $$($1_PRE_MARKER) $$($1_EXEC_RESULT)
+  else
+    $$($1_EXEC_RESULT): $$($1_DEPS)
+        ifneq ($$($1_WARN), )
+	  $$(call LogWarn, $$($1_WARN))
+        endif
+        ifneq ($$($1_INFO), )
+	  $$(call LogInfo, $$($1_INFO))
+        endif
+	$$(call MakeDir, $$($1_SUPPORT_DIR) $$($1_OUTPUT_DIR))
+	$$(call ExecuteWithLog, $$($1_BASE)_exec, \
+	    $$($1_COMMAND))
+        ifeq ($$($1_EXEC_RESULT), $$($1_EXEC_MARKER))
+	  $$(TOUCH) $$@
+        endif
+
+    $1 := $$($1_EXEC_RESULT)
+  endif
 
   ifneq ($$($1_POST_COMMAND), )
-    $1_POST_MARKER := $$($1_BASE)_post.marker
 
-    $$($1_POST_MARKER): $$($1_MARKER)
-	$$(call ExecuteWithLog, $$($1_BASE), \
+    $$($1_FINAL_RESULT): $$($1_EXEC_RESULT)
+	$$(call ExecuteWithLog, $$($1_BASE)_post, \
 	    $$($1_POST_COMMAND))
 	$$(TOUCH) $$@
 
-    $1 += $$($1_POST_MARKER)
-    $1_TARGET := $$($1_POST_MARKER)
+    $1 += $$($1_FINAL_RESULT)
   endif
 
+  # Export all our generated targets in $1, and the final target in $1_TARGET.
+  $1_TARGET := $$($1_FINAL_RESULT)
+
 endef
--- a/make/gensrc/GensrcCommonJdk.gmk	Thu Feb 07 13:04:38 2019 +0100
+++ b/make/gensrc/GensrcCommonJdk.gmk	Thu Feb 07 19:35:33 2019 +0100
@@ -27,6 +27,7 @@
 
 include $(SPEC)
 include MakeBase.gmk
+include Execute.gmk
 include JavaCompilation.gmk
 include NativeCompilation.gmk
 include TextFileProcessing.gmk
--- a/make/gensrc/GensrcX11Wrappers.gmk	Thu Feb 07 13:04:38 2019 +0100
+++ b/make/gensrc/GensrcX11Wrappers.gmk	Thu Feb 07 19:35:33 2019 +0100
@@ -26,27 +26,22 @@
 # Generate java sources using the X11 offsets that are precalculated in files
 # make/data/x11wrappergen/sizes-<address size>.txt.
 
-GENSRC_X11WRAPPERS_OUTPUT_TOP := $(SUPPORT_OUTPUTDIR)/gensrc/java.desktop
-
-GENSRC_X11WRAPPERS_MARKER := $(GENSRC_X11WRAPPERS_OUTPUT_TOP)/_x11wrappers.marker
-
 # Put the generated Java classes used to interface X11 from awt here.
-GENSRC_X11WRAPPERS_OUTPUTDIR := $(GENSRC_X11WRAPPERS_OUTPUT_TOP)/sun/awt/X11
+GENSRC_X11WRAPPERS_OUTPUTDIR := $(SUPPORT_OUTPUTDIR)/gensrc/java.desktop/sun/awt/X11
 
 # The pre-calculated offset file are stored here:
 GENSRC_X11WRAPPERS_DATADIR := $(TOPDIR)/make/data/x11wrappergen
 GENSRC_X11WRAPPERS_DATA := $(GENSRC_X11WRAPPERS_DATADIR)/sizes-$(OPENJDK_TARGET_CPU_BITS).txt
 
 # Run the tool on the offset files to generate several Java classes used in awt.
-$(GENSRC_X11WRAPPERS_MARKER): $(BUILD_TOOLS_JDK) $(GENSRC_X11WRAPPERS_DATA) \
-    $(GENSRC_X11WRAPPERS_DATADIR)/xlibtypes.txt
-	$(call MakeDir, $(GENSRC_X11WRAPPERS_OUTPUTDIR))
-	$(call LogInfo, Generating X11 wrapper source files)
-	$(call ExecuteWithLog, $@, \
-	    $(TOOL_WRAPPERGENERATOR) gen_java $(GENSRC_X11WRAPPERS_OUTPUTDIR) \
-	        $(GENSRC_X11WRAPPERS_DATADIR)/xlibtypes.txt $(GENSRC_X11WRAPPERS_DATA) \
-	        $(OPENJDK_TARGET_CPU_BITS))
-	$(TOUCH) $@
+$(eval $(call SetupExecute, gen_x11wrappers, \
+    INFO := Generating X11 wrapper source files, \
+    DEPS := $(BUILD_TOOLS_JDK) $(GENSRC_X11WRAPPERS_DATA) \
+        $(GENSRC_X11WRAPPERS_DATADIR)/xlibtypes.txt, \
+    OUTPUT_DIR := $(GENSRC_X11WRAPPERS_OUTPUTDIR), \
+    COMMAND := $(TOOL_WRAPPERGENERATOR) gen_java $(GENSRC_X11WRAPPERS_OUTPUTDIR) \
+        $(GENSRC_X11WRAPPERS_DATADIR)/xlibtypes.txt $(GENSRC_X11WRAPPERS_DATA) \
+        $(OPENJDK_TARGET_CPU_BITS), \
+))
 
-
-GENSRC_JAVA_DESKTOP += $(GENSRC_X11WRAPPERS_MARKER)
+GENSRC_JAVA_DESKTOP += $(gen_x11wrappers_TARGET)