jdk/make/gensrc/GensrcProperties.gmk
author jmasa
Fri, 29 Aug 2014 08:14:19 -0700
changeset 26331 8f17e084029b
parent 25859 3317bb8137f4
child 26192 33b90e93e3bf
permissions -rw-r--r--
Merge

#
# Copyright (c) 2011, 2013, 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.
#

# Prepare the find cache.
$(eval $(call FillCacheFind, $(wildcard $(JDK_TOPDIR)/src/*/*/classes)))

# All .properties files to be compiled are appended to this variable.
ALL_COMPILED_PROPSOURCES :=
# All generated .java files from compilation are appended to this variable.
ALL_COMPILED_PROPJAVAS :=
# The (very long) command line for compilation, stored in a file, prior to use.
COMPILE_PROPCMDLINE :=

define add_properties_to_compile
  # $1 is the name of the properties group
  # $2 is the files belonging to this group
  # $3 is the super class for the generated java file.

  # Convert <root>/jdk/src/<module>/share/classes/sun/util/resources/CurrencyNames_sv.properties
  # to <build>/jdk/gensrc/<module/sun/util/resources/CurrencyNames_sv.java
  $1_PROPJAVAS := $$(patsubst $(JDK_TOPDIR)/src/%.properties, \
      $(JDK_OUTPUTDIR)/gensrc/%.java, \
      $$(subst /share/classes,, \
      $$(subst /$(OPENJDK_TARGET_OS_API_DIR)/classes,, \
      $$(subst /$(OPENJDK_TARGET_OS)/classes,, $2))))

  # Accumulate all found properties files.
  ALL_COMPILED_PROPSOURCES += $2

  # Generate the list of to be created java files.
  ALL_COMPILED_PROPJAVAS += $$($1_PROPJAVAS)

  # Now generate a sequence of 
  # "-compile ...CurrencyNames_sv.properties ...CurrencyNames_sv.java ListResourceBundle"
  # suitable to be fed into the CompileProperties command.
  COMPILE_PROPCMDLINE += $$(subst _SPACE_,$(SPACE),$$(join $$(addprefix -compile_SPACE_, $2), \
      $$(addsuffix _SPACE_$(strip $3), \
      $$(addprefix _SPACE_, $$($1_PROPJAVAS)))))
endef

################################################################################
# Some packages have properties that need to be converted to java source files.
COMPILE_PROP_SRC_FILES := \
    $(filter %.properties, $(call CacheFind, \
        $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/accessibility/internal/resources \
        $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/resources \
        $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/resources \
        $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/swing/internal/plaf/basic/resources \
        $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/swing/internal/plaf/metal/resources \
        $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/swing/internal/plaf/synth/resources \
        $(JDK_TOPDIR)/src/jdk.jdi/share/classes/com/sun/tools/jdi/resources \
        $(JDK_TOPDIR)/src/java.desktop/share/classes/sun/awt/resources \
        $(JDK_TOPDIR)/src/java.base/share/classes/sun/launcher/resources \
        $(JDK_TOPDIR)/src/java.management/share/classes/sun/management/resources \
        $(JDK_TOPDIR)/src/java.desktop/share/classes/sun/print/resources \
        $(JDK_TOPDIR)/src/jdk.dev/share/classes/sun/tools/jar/resources \
        $(JDK_TOPDIR)/src/jdk.dev/share/classes/jdk/jigsaw/tools/jlink/resources \
        $(JDK_TOPDIR)/src/java.logging/share/classes/sun/util/logging/resources)) \
    #

ifeq ($(OPENJDK_TARGET_OS), macosx)
  COMPILE_PROP_SRC_FILES += \
      $(filter %.properties, $(call CacheFind, \
          $(JDK_TOPDIR)/src/java.desktop/macosx/classes/com/apple/laf/resources \
          $(JDK_TOPDIR)/src/java.desktop/macosx/classes/sun/awt/resources)) \
      #
endif

ifeq ($(OPENJDK_TARGET_OS), windows)
  COMPILE_PROP_SRC_FILES += \
      $(filter %.properties, $(call CacheFind, \
          $(JDK_TOPDIR)/src/java.desktop/windows/classes/sun/awt/windows)) \
      #
else # ! windows
  COMPILE_PROP_SRC_FILES += \
      $(filter %.properties, $(call CacheFind, \
          $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/resources)) \
      #
endif

$(eval $(call add_properties_to_compile,LIST_RESOURCE_BUNDLE, \
    $(COMPILE_PROP_SRC_FILES), ListResourceBundle))

# sun/util/resources
$(eval $(call add_properties_to_compile,SUN_UTIL, \
    $(filter %.properties, \
        $(call CacheFind, $(JDK_TOPDIR)/src/java.base/share/classes/sun/util/resources) \
        $(call CacheFind, $(JDK_TOPDIR)/src/jdk.localedata/share/classes/sun/util/resources)), \
    sun.util.resources.LocaleNamesBundle))

################################################################################
# Now setup the rule for the generation of the resource bundles.
$(JDK_OUTPUTDIR)/gensrc/_the.compiled_properties: $(ALL_COMPILED_PROPSOURCES) $(BUILD_TOOLS_JDK)
        # Generate all output directories in advance since the build tool does not do that...
	$(MKDIR) -p $(sort $(dir $(ALL_COMPILED_PROPJAVAS)))
	$(ECHO) Compiling $(words $(ALL_COMPILED_PROPSOURCES)) properties into resource bundles
	$(call ListPathsSafely,COMPILE_PROPCMDLINE,\n, >> $(JDK_OUTPUTDIR)/gensrc/_the.cmdline)
	$(TOOL_COMPILEPROPERTIES) -quiet @$(JDK_OUTPUTDIR)/gensrc/_the.cmdline
	$(TOUCH) $@

$(ALL_COMPILED_PROPJAVAS): $(JDK_OUTPUTDIR)/gensrc/_the.compiled_properties

################################################################################
# Some zh_HK resources are just copies of zh_TW

define convert_tw_to_hk
  $(MKDIR) -p $(@D)
  $(CAT) $< | $(SED) -e '/class/s/_zh_TW/_zh_HK/' > $@
endef

# Some are copies of existing sources
$(JDK_OUTPUTDIR)/gensrc/java.desktop/%_zh_HK.java: \
    $(JDK_TOPDIR)/src/java.desktop/share/classes/%_zh_TW.java
	$(call convert_tw_to_hk)

$(JDK_OUTPUTDIR)/gensrc/java.base/%_zh_HK.java: \
    $(JDK_TOPDIR)/src/java.base/share/classes/%_zh_TW.java
	$(call convert_tw_to_hk)

# Others are copies of sources generated by this makefile
$(JDK_OUTPUTDIR)/gensrc/%_zh_HK.java: $(JDK_OUTPUTDIR)/gensrc/%_zh_TW.java
	$(call convert_tw_to_hk)

# The existing sources
ZH_HK_JAVA := java.desktop/sun/applet/resources/MsgAppletViewer_zh_HK.java \
    java.base/sun/misc/resources/Messages_zh_HK.java \
    java.base/sun/security/util/AuthResources_zh_HK.java \
    java.base/sun/security/util/Resources_zh_HK.java

ZH_HK_JAVA_FILES := $(addprefix $(JDK_OUTPUTDIR)/gensrc/, $(ZH_HK_JAVA)) \
    $(filter-out $(JDK_OUTPUTDIR)/gensrc/jdk.localedata/sun/util/resources/zh/%, \
    $(subst _zh_TW,_zh_HK,$(filter %_zh_TW.java, $(ALL_COMPILED_PROPJAVAS))))

################################################################################

GENSRC_PROPERTIES := $(ALL_COMPILED_PROPJAVAS) $(ZH_HK_JAVA_FILES)