jdk

Форк
0
/
MainSupport.gmk 
212 строк · 7.1 Кб
1
#
2
# Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
#
5
# This code is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 2 only, as
7
# published by the Free Software Foundation.  Oracle designates this
8
# particular file as subject to the "Classpath" exception as provided
9
# by Oracle in the LICENSE file that accompanied this code.
10
#
11
# This code is distributed in the hope that it will be useful, but WITHOUT
12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14
# version 2 for more details (a copy is included in the LICENSE file that
15
# accompanied this code).
16
#
17
# You should have received a copy of the GNU General Public License version
18
# 2 along with this work; if not, write to the Free Software Foundation,
19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
#
21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
# or visit www.oracle.com if you need additional information or have any
23
# questions.
24
#
25

26
################################################################################
27
# This file contains helper functions for Main.gmk.
28
################################################################################
29

30
ifndef _MAINSUPPORT_GMK
31
_MAINSUPPORT_GMK := 1
32

33
# Setup make rules for creating a top-level target.
34
# Parameter 1 is the name of the rule. This name is used as variable prefix.
35
#
36
# Remaining parameters are named arguments. These include:
37
#   MAKEFILE the makefile to delegate to
38
#   TARGET the makefile target
39
#   ARGS arguments to the makefile
40
#   DEPS the target(s) this new rule depends on
41
#   DIR the directory of the makefile (defaults to $(TOPDIR)/make)
42
#
43
SetupTarget = $(NamedParamsMacroTemplate)
44
define SetupTargetBody
45
  ifeq ($$($1_DIR), )
46
    $1_DIR := $(TOPDIR)/make
47
  endif
48

49
  $1:
50
	+($(CD) $$($1_DIR) && $(MAKE) $(MAKE_ARGS) -f $$($1_MAKEFILE).gmk $$($1_TARGET) $$($1_ARGS))
51

52
  ALL_TARGETS += $1
53

54
  ifneq ($(DEPS), none)
55
    $1: $$($1_DEPS)
56
  endif
57
endef
58

59
define CleanDocs
60
	@$(PRINTF) "Cleaning docs ..."
61
	@$(PRINTF) "\n" $(LOG_DEBUG)
62
	$(RM) -r $(SUPPORT_OUTPUTDIR)/docs
63
	$(RM) -r $(SUPPORT_OUTPUTDIR)/javadoc
64
	$(RM) -r $(IMAGES_OUTPUTDIR)/docs
65
	@$(PRINTF) " done\n"
66
endef
67

68
# Cleans the dir given as $1
69
define CleanDir
70
	@$(PRINTF) "Cleaning $(strip $1) build artifacts ..."
71
	@$(PRINTF) "\n" $(LOG_DEBUG)
72
	($(CD) $(OUTPUTDIR) && $(RM) -r $1)
73
	@$(PRINTF) " done\n"
74
endef
75

76
define CleanSupportDir
77
	@$(PRINTF) "Cleaning $(strip $1) build artifacts ..."
78
	@$(PRINTF) "\n" $(LOG_DEBUG)
79
	$(RM) -r $(SUPPORT_OUTPUTDIR)/$(strip $1)
80
	@$(PRINTF) " done\n"
81
endef
82

83
define CleanMakeSupportDir
84
	@$(PRINTF) "Cleaning $(strip $1) make support artifacts ..."
85
	@$(PRINTF) "\n" $(LOG_DEBUG)
86
	$(RM) -r $(MAKESUPPORT_OUTPUTDIR)/$(strip $1)
87
	@$(PRINTF) " done\n"
88
endef
89

90
define CleanTest
91
	@$(PRINTF) "Cleaning test $(strip $1) ..."
92
	@$(PRINTF) "\n" $(LOG_DEBUG)
93
	$(RM) -r $(SUPPORT_OUTPUTDIR)/test/$(strip $(subst -,/,$1))
94
        # Remove as much of the test directory structure as is empty
95
	$(RMDIR) -p $(dir $(SUPPORT_OUTPUTDIR)/test/$(strip $(subst -,/,$1))) 2> /dev/null || true
96
	@$(PRINTF) " done\n"
97
endef
98

99
define Clean-gensrc
100
	@$(PRINTF) "Cleaning gensrc $(if $1,for $(strip $1) )..."
101
	@$(PRINTF) "\n" $(LOG_DEBUG)
102
	$(RM) -r $(SUPPORT_OUTPUTDIR)/gensrc/$(strip $1)
103
	@$(PRINTF) " done\n"
104
endef
105

106
define Clean-java
107
	@$(PRINTF) "Cleaning java $(if $1,for $(strip $1) )..."
108
	@$(PRINTF) "\n" $(LOG_DEBUG)
109
	$(RM) -r $(JDK_OUTPUTDIR)/modules/$(strip $1)
110
	$(RM) -r $(SUPPORT_OUTPUTDIR)/special_classes/$(strip $1)
111
	$(PRINTF) " done\n"
112
	$(PRINTF) "Cleaning headers $(if $1,for $(strip $1)) ..."
113
	$(RM) -r $(SUPPORT_OUTPUTDIR)/headers/$(strip $1)
114
	@$(PRINTF) " done\n"
115
endef
116

117
define Clean-native
118
	@$(PRINTF) "Cleaning native $(if $1,for $(strip $1) )..."
119
	@$(PRINTF) "\n" $(LOG_DEBUG)
120
	$(RM) -r $(SUPPORT_OUTPUTDIR)/native/$(strip $1)
121
	$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_libs/$(strip $1)
122
	$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_cmds/$(strip $1)
123
	@$(PRINTF) " done\n"
124
endef
125

126
define Clean-include
127
	@$(PRINTF) "Cleaning include $(if $1,for $(strip $1) )..."
128
	@$(PRINTF) "\n" $(LOG_DEBUG)
129
	$(RM) -r $(SUPPORT_OUTPUTDIR)/modules_include/$(strip $1)
130
	@$(PRINTF) " done\n"
131
endef
132

133
define CleanModule
134
  $(call Clean-gensrc, $1)
135
  $(call Clean-java, $1)
136
  $(call Clean-native, $1)
137
  $(call Clean-include, $1)
138
endef
139

140

141
################################################################################
142

143
PHASE_MAKEDIRS := $(TOPDIR)/make
144

145
# Helper macro for DeclareRecipesForPhase
146
# Declare a recipe for calling the module and phase specific makefile.
147
# If there are multiple makefiles to call, create a rule for each topdir
148
# that contains a makefile with the target $module-$suffix-$repodir,
149
# (i.e: java.base-gensrc-src)
150
# Normally there is only one makefile, and the target will just be
151
# $module-$suffix
152
# Param 1: Name of list to add targets to
153
# Param 2: Module name
154
define DeclareRecipeForModuleMakefile
155
  $2-$$($1_TARGET_SUFFIX):
156
	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) \
157
	    -f ModuleWrapper.gmk -I $$(TOPDIR)/make/common/modules  \
158
	    $$(patsubst %,-I%/modules/$2,$$(PHASE_MAKEDIRS)) \
159
	    MODULE=$2 MAKEFILE_PREFIX=$$($1_FILE_PREFIX) $$($1_EXTRA_ARGS))
160

161
endef
162

163
# Helper macro for DeclareRecipesForPhase
164
# Param 1: Name of list to add targets to
165
# Param 2: Module name
166
define DeclareRecipesForPhaseAndModule
167
  $1_$2_MAKEFILES := $$(strip $$(wildcard \
168
      $$(addsuffix /modules/$2/$$($1_FILE_PREFIX).gmk, $$(PHASE_MAKEDIRS))))
169

170
  # Only declare recipes if there are makefiles to call
171
  ifneq ($$($1_$2_MAKEFILES), )
172
    # Add the top dir specific target to target list regardless of if recipe
173
    # generation is disabled.
174
    ifeq ($$($1_MULTIPLE_MAKEFILES), true)
175
      $$(foreach d, $$($1_$2_TOPDIRS), \
176
        $$(eval $1 += $2-$$($1_TARGET_SUFFIX)-$$(notdir $$d)))
177
    endif
178
    ifeq ($(NO_RECIPES),)
179
      $$(eval $$(call DeclareRecipeForModuleMakefile,$1,$2))
180
    endif
181
    $1 += $2-$$($1_TARGET_SUFFIX)
182
    $1_MODULES += $2
183
  endif
184
endef
185

186
# Declare recipes for a specific module and build phase if there are makefiles
187
# present for the specific combination.
188
# Param 1: Name of list to add targets to
189
# Named params:
190
# TARGET_SUFFIX : Suffix of target to create for recipe
191
# FILE_PREFIX : File prefix for this build phase
192
# CHECK_MODULES : List of modules to try
193
# MULTIPLE_MAKEFILES : Set to true to handle makefiles for the same module and
194
#                      phase in multiple repos
195
# EXTRA_ARGS : Add extra make args to each makefile call
196
# Exported variables:
197
# $1_MODULES : All modules that had rules generated
198
# $1_TARGETS : All targets generated
199
define DeclareRecipesForPhase
200
  $(foreach i,2 3 4 5 6 7 8, $(if $(strip $($i)),$(strip $1)_$(strip $($i)))$(NEWLINE))
201
  $(if $(9),$(error Internal makefile error: Too many arguments to \
202
      DeclareRecipesForPhase, please update MakeHelper.gmk))
203

204
  $$(foreach m, $$($(strip $1)_CHECK_MODULES), \
205
      $$(eval $$(call DeclareRecipesForPhaseAndModule,$(strip $1),$$m)))
206

207
  $(strip $1)_TARGETS := $$($(strip $1))
208
endef
209

210
################################################################################
211

212
endif # _MAINSUPPORT_GMK
213

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.