Convert some more to SetupExecute. ihse-setupexecute-branch
authorihse
Wed, 06 Feb 2019 21:31:36 +0100
branchihse-setupexecute-branch
changeset 57155 ba61956ea598
parent 57139 94ff48d6eee4
child 57158 003703d03633
Convert some more to SetupExecute.
make/common/Execute.gmk
make/hotspot/gensrc/GensrcDtrace.gmk
make/hotspot/gensrc/GensrcJfr.gmk
make/hotspot/gensrc/GensrcJvmti.gmk
make/hotspot/ide/CreateVSProject.gmk
--- a/make/common/Execute.gmk	Fri Feb 01 12:29:52 2019 +0100
+++ b/make/common/Execute.gmk	Wed Feb 06 21:31:36 2019 +0100
@@ -42,8 +42,9 @@
 #
 # Remaining parameters are named arguments. These include:
 #   COMMAND     : The command to execute
+#   POST_COMMAND:
 #   OUTPUT_DIR  : The directory that will contain the result from the command
-#   (OUTPUT_FILE : Use this if the command results in a single output file. (N/A))
+#   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).
 #   DEPS        : Dependencies for the execution to take place
 #
@@ -55,26 +56,50 @@
     $$(error COMMAND is missing in SetupExecute $1)
   endif
 
-  ifeq ($$($1_OUTPUT_DIR), )
-    $$(error OUTPUT_DIR is missing in SetupExecute $1)
-  endif
+  $1_BASE := $$($1_OUTPUT_DIR)/_$1
+  $1_MARKER := $$($1_BASE).marker
 
   ifeq ($$($1_INFO), )
     $1_INFO := Running commands for $1
   endif
 
-  $1_BASE := $$($1_OUTPUT_DIR)/_$1
-
-  $1_MARKER := $$($1_BASE).marker
+  ifeq ($$($1_OUTPUT_DIR)$$($1_OUTPUT_FILE), )
+    $$(error OUTPUT_DIR or OUTPUT_FILE is required in SetupExecute $1)
+  endif
 
-  $$($1_MARKER): $$($1_DEPS)
+  ifneq ($$($1_OUTPUT_DIR), )
+    ifneq ($$($1_OUTPUT_FILE), )
+      $$(error Cannot specify both OUTPUT_DIR and OUTPUT_FILE in SetupExecute $1)
+    endif
+    $1_RESULT := $$($1_MARKER)
+  else
+    # If we have a single output file, we don't need a separate marker
+    $1_RESULT := $$($1_OUTPUT_FILE)
+  endif
+
+  $$($1_RESULT): $$($1_DEPS)
 	$$(call LogInfo, $$($1_INFO))
-	$$(call MakeDir, $$($1_OUTPUT_DIR))
+	$$(call MakeDir, $$(@D))
 	$$(call ExecuteWithLog, $$($1_BASE), \
 	    $$($1_COMMAND))
+        ifeq ($$($1_RESULT), $$($1_MARKER))
+	  $$(TOUCH) $$@
+        endif
+
+  # Export all our generated targets in $1, and the final target in $1_TARGET.
+  $1 := $$($1_RESULT)
+  $1_TARGET := $$($1_RESULT)
+
+  ifneq ($$($1_POST_COMMAND), )
+    $1_POST_MARKER := $$($1_BASE)_post.marker
+
+    $$($1_POST_MARKER): $$($1_MARKER)
+	$$(call ExecuteWithLog, $$($1_BASE), \
+	    $$($1_POST_COMMAND))
 	$$(TOUCH) $$@
 
-  # Export our generated targets in $1, and also $1_TARGET for clarity.
-  $1 := $$($1_MARKER)
-  $1_TARGET := $$($1)
+    $1 += $$($1_POST_MARKER)
+    $1_TARGET := $$($1_POST_MARKER)
+  endif
+
 endef
--- a/make/hotspot/gensrc/GensrcDtrace.gmk	Fri Feb 01 12:29:52 2019 +0100
+++ b/make/hotspot/gensrc/GensrcDtrace.gmk	Wed Feb 06 21:31:36 2019 +0100
@@ -87,12 +87,14 @@
     # Argument 1: Output filename
     # Argument 2: dtrace-gen-offset tool command line option
     define SetupDtraceOffsetsGeneration
-      $1: $$(BUILD_DTRACE_GEN_OFFSETS)
-	$$(call LogInfo, Generating dtrace $2 file $$(@F))
-	$$(call MakeDir, $$(@D))
-	$$(call ExecuteWithLog, $$@, ( $$(DTRACE_GEN_OFFSETS_TOOL) -$$(strip $2) > $$@ ) )
+      $$(eval $$(call SetupExecute, dtrace_offset_$2, \
+          INFO := Generating dtrace $2 file, \
+          DEPS := $$(BUILD_DTRACE_GEN_OFFSETS), \
+          OUTPUT_FILE := $1, \
+          COMMAND := ( $$(DTRACE_GEN_OFFSETS_TOOL) -$$(strip $2) > $1 ), \
+      ))
 
-      TARGETS += $1
+      TARGETS += $$(dtrace_offset_$2_TARGET)
     endef
 
     JVM_OFFSETS_H := $(DTRACE_GENSRC_DIR)/JvmOffsets.h
--- a/make/hotspot/gensrc/GensrcJfr.gmk	Fri Feb 01 12:29:52 2019 +0100
+++ b/make/hotspot/gensrc/GensrcJfr.gmk	Wed Feb 06 21:31:36 2019 +0100
@@ -57,11 +57,11 @@
 METADATA_XML := $(JFR_SRCDIR)/metadata.xml
 METADATA_XSD := $(JFR_SRCDIR)/metadata.xsd
 
-$(JFR_OUTPUTDIR)/jfrEventClasses.hpp: $(METADATA_XML) $(METADATA_XSD) \
-    $(BUILD_JFR_TOOLS)
-	$(call LogInfo, Generating $(@F))
-	$(call MakeDir, $(@D))
-	$(call ExecuteWithLog, $@, $(TOOL_JFR_GEN) $(METADATA_XML) $(METADATA_XSD) $(JFR_OUTPUTDIR))
-	test -f $@
+$(eval $(call SetupExecute, jfr_gen, \
+    INFO := Generating JFR header files, \
+    DEPS := $(METADATA_XML) $(METADATA_XSD), \
+    OUTPUT_DIR := $(JFR_OUTPUTDIR), \
+    COMMAND := $(TOOL_JFR_GEN) $(METADATA_XML) $(METADATA_XSD) $(JFR_OUTPUTDIR), \
+))
 
-TARGETS += $(JFR_OUTPUTDIR)/jfrEventClasses.hpp
+TARGETS += $(jfr_gen_TARGET)
--- a/make/hotspot/gensrc/GensrcJvmti.gmk	Fri Feb 01 12:29:52 2019 +0100
+++ b/make/hotspot/gensrc/GensrcJvmti.gmk	Wed Feb 06 21:31:36 2019 +0100
@@ -28,6 +28,7 @@
 ################################################################################
 # Build tools needed for the JVMTI source code generation
 
+# FIXME: jvmtiGen.java should move to make/src, jvmtiEnvFill.java should be removed.
 JVMTI_TOOLS_SRCDIR := $(TOPDIR)/src/hotspot/share/prims
 JVMTI_TOOLS_OUTPUTDIR := $(JVM_VARIANT_OUTPUTDIR)/tools/jvmti
 
@@ -64,16 +65,17 @@
 #   DEPS -- Additional dependencies
 SetupXslTransform = $(NamedParamsMacroTemplate)
 define SetupXslTransformBody
-  $$($1_OUTPUT_DIR)/$1: $$($1_XML_FILE) $$($1_XSL_FILE) $$($1_DEPS) $$(BUILD_JVMTI_TOOLS)
-	$$(call LogInfo, Generating $$(@F))
-	$$(call MakeDir, $$(@D))
-	$$(call ExecuteWithLog, $$@, $$(TOOL_JVMTI_GEN) -IN $$($1_XML_FILE) \
-	    -XSL $$($1_XSL_FILE) -OUT $$@ $$($1_ARGS))
-        # jvmtiGen does not return error code properly on fail.
-        # NOTE: We should really fix jvmtiGen.java instead.
-	test -f $$@
+  $1_OUTPUT_FILE := $$($1_OUTPUT_DIR)/$1
 
-  TARGETS += $$($1_OUTPUT_DIR)/$1
+  $$(eval $$(call SetupExecute, jvmti_gen_$1, \
+      INFO := Generating jvmti file $1, \
+      DEPS := $$($1_XML_FILE) $$($1_XSL_FILE) $$($1_DEPS) $$(BUILD_JVMTI_TOOLS), \
+      OUTPUT_FILE := $$($1_OUTPUT_FILE), \
+      COMMAND := $$(TOOL_JVMTI_GEN) -IN $$($1_XML_FILE) \
+          -XSL $$($1_XSL_FILE) -OUT $$($1_OUTPUT_FILE) $$($1_ARGS), \
+  ))
+
+  TARGETS += $$(jvmti_gen_$1_TARGET)
 endef
 
 ################################################################################
--- a/make/hotspot/ide/CreateVSProject.gmk	Fri Feb 01 12:29:52 2019 +0100
+++ b/make/hotspot/ide/CreateVSProject.gmk	Wed Feb 06 21:31:36 2019 +0100
@@ -144,14 +144,16 @@
   VCPROJ_VARDEPS_FILE := $(call DependOnVariable, VCPROJ_VARDEPS, \
     $(VCPROJ_FILE).vardeps)
 
-  $(VCPROJ_FILE): $(BUILD_PROJECT_CREATOR) $(VCPROJ_VARDEPS_FILE)
-	$(call MakeDir, $(@D))
-	$(call ExecuteWithLog, $@, \
-	    $(PROJECT_CREATOR_TOOL) $(PROJECT_CREATOR_CLASS) \
-	    $(PROJECT_CREATOR_ARGS) -projectFileName $(call FixPath, $@)) \
-	    $(LOG_INFO)
+  $(eval $(call SetupExecute, vcproj_file, \
+      INFO := Generating Visual Studio project file, \
+      DEPS := $(BUILD_PROJECT_CREATOR) $(VCPROJ_VARDEPS_FILE), \
+      OUTPUT_FILE := $(VCPROJ_FILE), \
+      COMMAND := $(PROJECT_CREATOR_TOOL) $(PROJECT_CREATOR_CLASS) \
+          $(PROJECT_CREATOR_ARGS) -projectFileName $(call FixPath, $(VCPROJ_FILE))) \
+          $(LOG_INFO), \
+  ))
 
-  TARGETS += $(VCPROJ_FILE)
+  TARGETS += $(vcproj_file_TARGET)
 
   all: $(TARGETS)