jdk

Форк
0
/
GensrcProperties.gmk 
144 строки · 5.8 Кб
1
#
2
# Copyright (c) 2011, 2022, 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
# This file defines macros that sets up rules for generating java classes
27
# from resource bundle properties files.
28

29
include JavaCompilation.gmk
30

31
################################################################################
32
# Helper macro for SetupCopy-zh_HK.
33
define SetupOneCopy-zh_HK
34
  $1_$2_TARGET := $$(patsubst $(TOPDIR)/src/$(MODULE)/share/classes/%, \
35
      $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/%, \
36
      $$(subst _zh_TW,_zh_HK, $2))
37

38
  $$($1_$2_TARGET): $2
39
	$$(call MakeTargetDir)
40
	$(CAT) $$< | $(SED) -e '/class/s/_zh_TW/_zh_HK/' > $$@
41

42
  $1 += $$($1_$2_TARGET)
43
endef
44

45
################################################################################
46
# Creates rules for copying zh_TW resources to zh_HK.
47
# Param 1 - Variable to add targets to
48
# Param 2 - Files to copy from
49
define SetupCopy-zh_HK
50
  $$(foreach f, $2, $$(eval $$(call SetupOneCopy-zh_HK,$1,$$f)))
51
endef
52

53
################################################################################
54
# Setup make rules that runs CompileProperties on a set of properties files.
55
#
56
# Parameter 1 is the name of the rule. This name is used as variable prefix,
57
# and the targets generated are listed in a variable by that name.
58
#
59
# Remaining parameters are named arguments. These include:
60
# SRC_DIRS   Directories containing properties files to process.
61
# EXTRA_FILES Also include these specifically named files
62
# EXCLUDE   Exclude files matching this pattern.
63
# CLASS   The super class for the generated classes.
64
# TYPE    Whether to use "langtools" or normal compiler.
65
# MODULE_PATH_ROOT   Module path root, defaults to $(TOPDIR)/src.
66
# KEEP_ALL_TRANSLATIONS Set to true to skip filtering of excluded translations.
67
SetupCompileProperties = $(NamedParamsMacroTemplate)
68
define SetupCompilePropertiesBody
69
  # Set default value unless overridden
70
  ifeq ($$($1_MODULE_PATH_ROOT), )
71
    $1_MODULE_PATH_ROOT := $(TOPDIR)/src
72
  endif
73

74
  # Locate all properties files in the given source dirs.
75
  $1_SRC_FILES := $$(call FindFiles, $$($1_SRC_DIRS), *.properties)
76

77
  $1_SRC_FILES += $$($1_EXTRA_FILES)
78

79
  ifneq ($$($1_EXCLUDE), )
80
    $1_SRC_FILES := $$(filter-out $$($1_EXCLUDE), $$($1_SRC_FILES))
81
  endif
82

83
  # Filter out any excluded translations
84
  ifneq ($$($1_KEEP_ALL_TRANSLATIONS), true)
85
    $1_SRC_FILES := $$(call FilterExcludedTranslations, $$($1_SRC_FILES), .properties)
86
  endif
87

88
  # Convert .../src/<module>/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties
89
  # to .../support/gensrc/<module>/com/sun/tools/javac/resources/javac_zh_CN.java
90
  $1_JAVAS := $$(patsubst $$($1_MODULE_PATH_ROOT)/%, \
91
      $(SUPPORT_OUTPUTDIR)/gensrc/%, \
92
      $$(patsubst %.properties, %.java, \
93
      $$(subst /$(OPENJDK_TARGET_OS)/classes,, \
94
      $$(subst /$(OPENJDK_TARGET_OS_TYPE)/classes,, \
95
      $$(subst /share/classes,, $$($1_SRC_FILES))))))
96

97
  # Generate the package dirs for the to be generated java files. Sort to remove
98
  # duplicates.
99
  $1_DIRS := $$(sort $$(dir $$($1_JAVAS)))
100

101
  # Now generate a sequence of:
102
  # "-compile ...javac_zh_CN.properties ...javac_zh_CN.java java.util.ListResourceBundle"
103
  # suitable to be fed into the CompileProperties command.
104
  $1_CMDLINE := $$(subst _SPACE_, $(SPACE), \
105
      $$(join $$(addprefix -compile_SPACE_, $$($1_SRC_FILES)), \
106
      $$(addsuffix _SPACE_$$($1_CLASS), \
107
      $$(addprefix _SPACE_, $$($1_JAVAS)))))
108

109
  $1_TARGET := $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/_the.$1.marker
110
  $1_CMDLINE_FILE := $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/_the.$1.cmdline
111
  $1_EXEC_MARKER := $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/_the.$1.exec
112

113
  ifeq ($$($1_TYPE), langtools)
114
    $1_TOOL := -cp $(BUILDTOOLS_OUTPUTDIR)/langtools_tools_classes \
115
    compileproperties.CompileProperties
116
    $1_TOOL_DEPS := $(BUILD_TOOLS_LANGTOOLS)
117
  else
118
    $1_TOOL := -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes \
119
    build.tools.compileproperties.CompileProperties
120
    $1_TOOL_DEPS := $(BUILD_TOOLS_JDK)
121
  endif
122

123
  ifeq ($(findstring $(LOG_LEVEL), debug trace), )
124
    $1_QUIET := -quiet
125
  endif
126

127
  # Now setup the rule for the generation of the resource bundles.
128
  $$($1_TARGET): $$($1_SRC_FILES) $$($1_JAVAS) $$($1_TOOL_DEPS)
129
	$$(call LogWarn, Compiling $$(words $$($1_SRC_FILES)) properties into resource bundles for $(MODULE))
130
	$$(call MakeDir, $$(@D) $$($1_DIRS))
131
	$$(eval $$(call ListPathsSafely, $1_CMDLINE, $$($1_CMDLINE_FILE)))
132
	$$(call ExecuteWithLog, $$($1_EXEC_MARKER), \
133
	    $(JAVA_SMALL) $$($1_TOOL) $$($1_QUIET) @$$($1_CMDLINE_FILE))
134
	$(TOUCH) $$@
135

136
  $$($1_JAVAS): $$($1_SRC_FILES)
137

138
  # Create zh_HK versions of all zh_TW files created above
139
  $$(eval $$(call SetupCopy-zh_HK,$1_HK,$$(filter %_zh_TW.java, $$($1_JAVAS))))
140
  # The zh_HK copy must wait for the compile properties tool to run
141
  $$($1_HK): $$($1_TARGET)
142

143
  $1 += $$($1_JAVAS) $$($1_TARGET) $$($1_HK)
144
endef
145

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

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

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

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