Initial implementation and test case of SetupExecute.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/make/common/Execute.gmk Fri Feb 01 12:29:52 2019 +0100
@@ -0,0 +1,80 @@
+#
+# Copyright (c) 2019, 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
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+ifeq (,$(_MAKEBASE_GMK))
+ $(error You must include MakeBase.gmk prior to including Execute.gmk)
+endif
+
+################################################################################
+#
+# Code for handling the SetupExecute macro.
+#
+################################################################################
+
+
+################################################################################
+# Setup make rules for executing an arbitrary command.
+#
+# Parameter 1 is the name of the rule. This name is used as variable prefix,
+# and the targets generated are listed in a variable by that name.
+#
+# Remaining parameters are named arguments. These include:
+# COMMAND : The command to execute
+# 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))
+# INFO : Message to display at LOG=info level when running command (optional).
+# DEPS : Dependencies for the execution to take place
+#
+
+# Setup make rules for copying files, with an option to do more complex
+SetupExecute = $(NamedParamsMacroTemplate)
+define SetupExecuteBody
+ ifeq ($$($1_COMMAND), )
+ $$(error COMMAND is missing in SetupExecute $1)
+ endif
+
+ ifeq ($$($1_OUTPUT_DIR), )
+ $$(error OUTPUT_DIR is missing in SetupExecute $1)
+ endif
+
+ ifeq ($$($1_INFO), )
+ $1_INFO := Running commands for $1
+ endif
+
+ $1_BASE := $$($1_OUTPUT_DIR)/_$1
+
+ $1_MARKER := $$($1_BASE).marker
+
+ $$($1_MARKER): $$($1_DEPS)
+ $$(call LogInfo, $$($1_INFO))
+ $$(call MakeDir, $$($1_OUTPUT_DIR))
+ $$(call ExecuteWithLog, $$($1_BASE), \
+ $$($1_COMMAND))
+ $$(TOUCH) $$@
+
+ # Export our generated targets in $1, and also $1_TARGET for clarity.
+ $1 := $$($1_MARKER)
+ $1_TARGET := $$($1)
+endef
--- a/make/hotspot/gensrc/GenerateSources.gmk Fri Feb 01 11:14:45 2019 +0100
+++ b/make/hotspot/gensrc/GenerateSources.gmk Fri Feb 01 12:29:52 2019 +0100
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2019, 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
@@ -27,6 +27,7 @@
include $(SPEC)
include MakeBase.gmk
+include Execute.gmk
include JavaCompilation.gmk
include NativeCompilation.gmk
include TextFileProcessing.gmk
--- a/make/hotspot/gensrc/GensrcAdlc.gmk Fri Feb 01 11:14:45 2019 +0100
+++ b/make/hotspot/gensrc/GensrcAdlc.gmk Fri Feb 01 12:29:52 2019 +0100
@@ -166,18 +166,16 @@
##############################################################################
# Run the adlc tool on the single concatenated ad source file, and store the
# output in support/adlc for further processing.
- ADLC_RUN_MARKER := $(ADLC_SUPPORT_DIR)/_adlc_run.marker
-
- $(ADLC_RUN_MARKER): $(BUILD_ADLC) $(SINGLE_AD_SRCFILE)
- $(call LogInfo, Generating adlc files)
- $(call MakeDir, $(@D))
- $(call ExecuteWithLog, $(ADLC_SUPPORT_DIR)/adlc_run, \
- $(FIXPATH) $(ADLC_TOOL) $(ADLCFLAGS) $(SINGLE_AD_SRCFILE) \
- -c$(ADLC_SUPPORT_DIR)/ad_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
- -h$(ADLC_SUPPORT_DIR)/ad_$(HOTSPOT_TARGET_CPU_ARCH).hpp \
- -a$(ADLC_SUPPORT_DIR)/dfa_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
- -v$(ADLC_SUPPORT_DIR)/adGlobals_$(HOTSPOT_TARGET_CPU_ARCH).hpp)
- $(TOUCH) $@
+ $(eval $(call SetupExecute, adlc_run, \
+ INFO := Generating adlc files, \
+ DEPS := $(BUILD_ADLC) $(SINGLE_AD_SRCFILE), \
+ OUTPUT_DIR := $(ADLC_SUPPORT_DIR), \
+ COMMAND := $(FIXPATH) $(ADLC_TOOL) $(ADLCFLAGS) $(SINGLE_AD_SRCFILE) \
+ -c$(ADLC_SUPPORT_DIR)/ad_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
+ -h$(ADLC_SUPPORT_DIR)/ad_$(HOTSPOT_TARGET_CPU_ARCH).hpp \
+ -a$(ADLC_SUPPORT_DIR)/dfa_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
+ -v$(ADLC_SUPPORT_DIR)/adGlobals_$(HOTSPOT_TARGET_CPU_ARCH).hpp, \
+ ))
##############################################################################
# Finally copy the generated files from support/adlc into gensrc/adfiles,
@@ -197,7 +195,7 @@
dfa_$(HOTSPOT_TARGET_CPU_ARCH).cpp \
)
- $(JVM_VARIANT_OUTPUTDIR)/gensrc/adfiles/%: $(ADLC_RUN_MARKER)
+ $(JVM_VARIANT_OUTPUTDIR)/gensrc/adfiles/%: $(adlc_run_TARGET)
$(call LogInfo, Postprocessing adlc file $*)
$(call MakeDir, $(@D))
$(NAWK) \