annotate make/MainSupport.gmk @ 44697:ae11efc5ed76

Merge
author lana
date Sat, 22 Apr 2017 00:21:19 +0000
parents 4f71f07b30d1
children 822ca950ddaa
rev   line source
erikj@13133 1 #
erikj@41260 2 # Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
erikj@13133 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
erikj@13133 4 #
erikj@13133 5 # This code is free software; you can redistribute it and/or modify it
erikj@13133 6 # under the terms of the GNU General Public License version 2 only, as
erikj@13133 7 # published by the Free Software Foundation. Oracle designates this
erikj@13133 8 # particular file as subject to the "Classpath" exception as provided
erikj@13133 9 # by Oracle in the LICENSE file that accompanied this code.
erikj@13133 10 #
erikj@13133 11 # This code is distributed in the hope that it will be useful, but WITHOUT
erikj@13133 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
erikj@13133 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
erikj@13133 14 # version 2 for more details (a copy is included in the LICENSE file that
erikj@13133 15 # accompanied this code).
erikj@13133 16 #
erikj@13133 17 # You should have received a copy of the GNU General Public License version
erikj@13133 18 # 2 along with this work; if not, write to the Free Software Foundation,
erikj@13133 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
erikj@13133 20 #
erikj@13133 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
erikj@13133 22 # or visit www.oracle.com if you need additional information or have any
erikj@13133 23 # questions.
erikj@13133 24 #
erikj@13133 25
ihse@29662 26 ################################################################################
ihse@29662 27 # This file contains helper functions for Main.gmk.
ihse@29662 28 ################################################################################
erikj@13133 29
ihse@29662 30 ifndef _MAINSUPPORT_GMK
ihse@29662 31 _MAINSUPPORT_GMK := 1
erikj@13133 32
ehelin@37974 33 # Run the tests specified by $1, with PRODUCT_HOME specified by $2
erikj@41047 34 # JT_JAVA is picked up by the jtreg launcher and used to run Jtreg itself.
ihse@29156 35 define RunTests
ihse@29156 36 ($(CD) $(SRC_ROOT)/test && $(MAKE) $(MAKE_ARGS) -j1 -k MAKEFLAGS= \
ehelin@37974 37 JT_HOME=$(JT_HOME) PRODUCT_HOME=$(strip $2) \
ihse@29156 38 TEST_IMAGE_DIR=$(TEST_IMAGE_DIR) \
ehelin@34594 39 ALT_OUTPUTDIR=$(OUTPUT_ROOT) TEST_JOBS=$(TEST_JOBS) \
erikj@41047 40 JT_JAVA=$(BOOT_JDK) \
ehelin@34594 41 JOBS=$(JOBS) $1) || true
ihse@29156 42 endef
ihse@29156 43
ihse@41652 44 define CleanDocs
ihse@41652 45 @$(PRINTF) "Cleaning docs ..."
ihse@41652 46 @$(PRINTF) "\n" $(LOG_DEBUG)
ihse@41652 47 $(RM) -r $(SUPPORT_OUTPUTDIR)/docs
ihse@41652 48 $(RM) -r $(SUPPORT_OUTPUTDIR)/javadoc
ihse@41652 49 $(RM) -r $(IMAGES_OUTPUTDIR)/docs
ihse@41652 50 @$(PRINTF) " done\n"
ihse@41652 51 endef
ihse@41652 52
chegar@27560 53 # Cleans the dir given as $1
chegar@27560 54 define CleanDir
chegar@25854 55 @$(PRINTF) "Cleaning $(strip $1) build artifacts ..."
erikj@29790 56 @$(PRINTF) "\n" $(LOG_DEBUG)
erikj@29790 57 ($(CD) $(OUTPUT_ROOT) && $(RM) -r $1)
ihse@20363 58 @$(PRINTF) " done\n"
ohair@13697 59 endef
ohair@13697 60
ihse@33437 61 define CleanSupportDir
ihse@33437 62 @$(PRINTF) "Cleaning $(strip $1) build artifacts ..."
ihse@33437 63 @$(PRINTF) "\n" $(LOG_DEBUG)
ihse@33437 64 $(RM) -r $(SUPPORT_OUTPUTDIR)/$(strip $1)
ihse@33437 65 @$(PRINTF) " done\n"
ihse@33437 66 endef
ihse@33437 67
ihse@29156 68 define CleanTest
ihse@29156 69 @$(PRINTF) "Cleaning test $(strip $1) ..."
erikj@29790 70 @$(PRINTF) "\n" $(LOG_DEBUG)
erikj@29790 71 $(RM) -r $(SUPPORT_OUTPUTDIR)/test/$(strip $(subst -,/,$1))
ihse@33052 72 # Remove as much of the test directory structure as is empty
ihse@33052 73 $(RMDIR) -p $(dir $(SUPPORT_OUTPUTDIR)/test/$(strip $(subst -,/,$1))) 2> /dev/null || true
ihse@29156 74 @$(PRINTF) " done\n"
ihse@29156 75 endef
ihse@29156 76
chegar@27560 77 define Clean-gensrc
chegar@27560 78 @$(PRINTF) "Cleaning gensrc $(if $1,for $(strip $1) )..."
erikj@29790 79 @$(PRINTF) "\n" $(LOG_DEBUG)
erikj@29790 80 $(RM) -r $(SUPPORT_OUTPUTDIR)/gensrc/$(strip $1)
chegar@27560 81 @$(PRINTF) " done\n"
chegar@27560 82 endef
chegar@27560 83
chegar@27560 84 define Clean-java
chegar@27560 85 @$(PRINTF) "Cleaning java $(if $1,for $(strip $1) )..."
erikj@29790 86 @$(PRINTF) "\n" $(LOG_DEBUG)
erikj@29790 87 $(RM) -r $(JDK_OUTPUTDIR)/modules/$(strip $1)
erikj@31310 88 $(RM) -r $(SUPPORT_OUTPUTDIR)/special_classes/$(strip $1)
erikj@29790 89 $(PRINTF) " done\n"
erikj@29790 90 $(PRINTF) "Cleaning headers $(if $1,for $(strip $1)) ..."
erikj@29790 91 $(RM) -r $(SUPPORT_OUTPUTDIR)/headers/$(strip $1)
chegar@27560 92 @$(PRINTF) " done\n"
chegar@27560 93 endef
chegar@27560 94
chegar@27560 95 define Clean-native
chegar@27560 96 @$(PRINTF) "Cleaning native $(if $1,for $(strip $1) )..."
erikj@29790 97 @$(PRINTF) "\n" $(LOG_DEBUG)
erikj@29790 98 $(RM) -r $(SUPPORT_OUTPUTDIR)/native/$(strip $1)
erikj@29790 99 $(RM) -r $(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1)
erikj@29790 100 $(RM) -r $(SUPPORT_OUTPUTDIR)/modules_cmds/$(strip $1)
chegar@27560 101 @$(PRINTF) " done\n"
chegar@27560 102 endef
chegar@27560 103
chegar@27560 104 define Clean-include
chegar@27560 105 @$(PRINTF) "Cleaning include $(if $1,for $(strip $1) )..."
erikj@29790 106 @$(PRINTF) "\n" $(LOG_DEBUG)
erikj@29790 107 $(RM) -r $(SUPPORT_OUTPUTDIR)/modules_include/$(strip $1)
erikj@29790 108 @$(PRINTF) " done\n"
erikj@29790 109 endef
erikj@29790 110
chegar@27560 111 define CleanModule
chegar@27560 112 $(call Clean-gensrc, $1)
chegar@27560 113 $(call Clean-java, $1)
chegar@27560 114 $(call Clean-native, $1)
chegar@27560 115 $(call Clean-include, $1)
chegar@27560 116 endef
chegar@27560 117
chegar@27560 118
erikj@26116 119 ################################################################################
erikj@26116 120
twisti@33045 121 MAKE_TOPDIR_LIST := $(JDK_TOPDIR) $(CORBA_TOPDIR) $(LANGTOOLS_TOPDIR) \
twisti@33045 122 $(HOTSPOT_TOPDIR)
chegar@27560 123 MAKE_MAKEDIR_LIST := make
erikj@26116 124
chegar@27560 125 # Helper macro for DeclareRecipesForPhase
chegar@27560 126 # Declare a recipe for calling the module and phase specific makefile.
chegar@27560 127 # If there are multiple makefiles to call, create a rule for each topdir
ihse@28356 128 # that contains a makefile with the target $module-$suffix-$repodir,
chegar@27560 129 # (i.e: java.base-gensrc-jdk)
chegar@27560 130 # Normally there is only one makefile, and the target will just be
chegar@27560 131 # $module-$suffix
chegar@27560 132 # Param 1: Name of list to add targets to
chegar@27560 133 # Param 2: Module name
chegar@27560 134 # Param 3: Topdir
chegar@27560 135 define DeclareRecipeForModuleMakefile
chegar@27560 136 ifeq ($$($1_MULTIPLE_MAKEFILES), true)
chegar@27560 137 $2-$$($1_TARGET_SUFFIX): $2-$$($1_TARGET_SUFFIX)-$$(notdir $3)
erikj@26116 138
chegar@27560 139 $2-$$($1_TARGET_SUFFIX)-$$(notdir $3):
chegar@27560 140 else
chegar@27560 141 $2-$$($1_TARGET_SUFFIX):
chegar@27560 142 endif
chegar@27560 143 ifeq ($$($1_USE_WRAPPER), true)
chegar@27560 144 +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \
chegar@27560 145 -f ModuleWrapper.gmk \
chegar@27560 146 $$(addprefix -I, $$(wildcard $$(addprefix $3/, $(MAKE_MAKEDIR_LIST)) \
chegar@27560 147 $$(addsuffix /$$($1_MAKE_SUBDIR), $$(addprefix $3/, $(MAKE_MAKEDIR_LIST))))) \
chegar@27560 148 MODULE=$2 MAKEFILE_PREFIX=$$($1_FILE_PREFIX))
chegar@27560 149 else
chegar@27560 150 +($(CD) $$(dir $$(firstword $$(wildcard $$(patsubst %, \
chegar@27560 151 $3/%/$$($1_MAKE_SUBDIR)/$$($1_FILE_PREFIX)-$2.gmk, $(MAKE_MAKEDIR_LIST))))) \
erikj@26116 152 && $(MAKE) $(MAKE_ARGS) \
chegar@27560 153 -f $$($1_FILE_PREFIX)-$2.gmk \
chegar@27560 154 $$(addprefix -I, $$(wildcard $$(addprefix $3/, $(MAKE_MAKEDIR_LIST)) \
erikj@29060 155 $$(addsuffix /$$($1_MAKE_SUBDIR), $$(addprefix $3/, $(MAKE_MAKEDIR_LIST))))) \
chegar@27560 156 MODULE=$2)
chegar@27560 157 endif
chegar@27560 158
chegar@27560 159 endef
chegar@27560 160
chegar@27560 161 # Helper macro for DeclareRecipesForPhase
chegar@27560 162 # Param 1: Name of list to add targets to
chegar@27560 163 # Param 2: Module name
chegar@27560 164 define DeclareRecipesForPhaseAndModule
chegar@27560 165 $1_$2_TOPDIRS := $$(strip $$(sort $$(foreach d, $(MAKE_TOPDIR_LIST), \
chegar@27560 166 $$(patsubst $$d/%, $$d, $$(filter $$d/%, \
chegar@27560 167 $$(wildcard $$(patsubst %, %/$$($1_MAKE_SUBDIR)/$$($1_FILE_PREFIX)-$2.gmk, \
chegar@27560 168 $$(foreach s, $(MAKE_MAKEDIR_LIST), \
chegar@27560 169 $$(addsuffix /$$s, $(MAKE_TOPDIR_LIST))))))))))
chegar@27560 170
chegar@27560 171 # Only declare recipes if there are makefiles to call
chegar@27560 172 ifneq ($$($1_$2_TOPDIRS), )
erikj@41172 173 # Add the top dir specific target to target list regardless of if recipe
erikj@41172 174 # generation is disabled.
erikj@41172 175 ifeq ($$($1_MULTIPLE_MAKEFILES), true)
erikj@41172 176 $$(foreach d, $$($1_$2_TOPDIRS), \
erikj@41172 177 $$(eval $1 += $2-$$($1_TARGET_SUFFIX)-$$(notdir $$d)))
erikj@41172 178 endif
ihse@29662 179 ifeq ($(NO_RECIPES),)
ihse@29662 180 $$(foreach d, $$($1_$2_TOPDIRS), \
ihse@29662 181 $$(eval $$(call DeclareRecipeForModuleMakefile,$1,$2,$$d)))
ihse@29662 182 endif
chegar@27560 183 $1 += $2-$$($1_TARGET_SUFFIX)
chegar@27560 184 $1_MODULES += $2
chegar@27560 185 endif
chegar@27560 186 endef
chegar@27560 187
chegar@27560 188 # Declare recipes for a specific module and build phase if there are makefiles
chegar@27560 189 # present for the specific combination.
chegar@27560 190 # Param 1: Name of list to add targets to
chegar@27560 191 # Named params:
chegar@27560 192 # TARGET_SUFFIX : Suffix of target to create for recipe
chegar@27560 193 # MAKE_SUBDIR : Subdir for this build phase
chegar@27560 194 # FILE_PREFIX : File prefix for this build phase
chegar@27560 195 # USE_WRAPPER : Set to true to use ModuleWrapper.gmk
chegar@27560 196 # CHECK_MODULES : List of modules to try
twisti@33045 197 # MULTIPLE_MAKEFILES : Set to true to handle makefiles for the same module and
chegar@27560 198 # phase in multiple repos
chegar@27560 199 # Exported variables:
chegar@27560 200 # $1_MODULES : All modules that had rules generated
chegar@27560 201 # $1_TARGETS : All targets generated
chegar@27560 202 define DeclareRecipesForPhase
chegar@27560 203 $(foreach i,2 3 4 5 6 7, $(if $($i),$(strip $1)_$(strip $($i)))$(NEWLINE))
chegar@27560 204 $(if $(8),$(error Internal makefile error: Too many arguments to \
chegar@27560 205 DeclareRecipesForPhase, please update MakeHelper.gmk))
chegar@27560 206
chegar@27560 207 $$(foreach m, $$($(strip $1)_CHECK_MODULES), \
chegar@27560 208 $$(eval $$(call DeclareRecipesForPhaseAndModule,$(strip $1),$$m)))
chegar@27560 209
chegar@27560 210 $(strip $1)_TARGETS := $$($(strip $1))
erikj@26116 211 endef
erikj@26116 212
erikj@26116 213 ################################################################################
erikj@26116 214
ihse@29662 215 endif # _MAINSUPPORT_GMK