jdk/make/gensrc/GensrcProperties.gmk
author erikj
Fri, 07 Mar 2014 15:01:32 +0100
changeset 23236 7c5997f59e20
parent 23010 6dadb192ad81
child 23347 acb1d044a217
permissions -rw-r--r--
8036611: Cleanup of handling of properties and other java resources in the build Reviewed-by: tbell, ihse

#
# 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. This is only used on windows.
$(eval $(call FillCacheFind, $(JDK_TOPDIR)/src/share/classes $(JDK_TOPDIR)/src/windows/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.

  # Strip away prefix and suffix,
  # leaving for example: sun/util/resources/CurrencyNames_sv
  $1_PROPPATHS := $$(patsubst $(JDK_TOPDIR)/src/windows/classes/%.properties, %, \
      $$(patsubst $(JDK_TOPDIR)/src/macosx/classes/%.properties, %, \
      $$(patsubst $(JDK_TOPDIR)/src/share/classes/%.properties, %, $2)))

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

  # Generate the list of to be created java files.
  ALL_COMPILED_PROPJAVAS += $$(patsubst %, $(JDK_OUTPUTDIR)/gensrc/%.java, $$($1_PROPPATHS))

  # 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_$(JDK_OUTPUTDIR)/gensrc/, \
      $$(addsuffix .java, $$($1_PROPPATHS))))))
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/share/classes/com/sun/accessibility/internal/resources \
        $(JDK_TOPDIR)/src/share/classes/com/sun/java/swing/plaf/motif/resources \
        $(JDK_TOPDIR)/src/share/classes/com/sun/java/swing/plaf/windows/resources \
        $(JDK_TOPDIR)/src/share/classes/com/sun/swing/internal/plaf/basic/resources \
        $(JDK_TOPDIR)/src/share/classes/com/sun/swing/internal/plaf/metal/resources \
        $(JDK_TOPDIR)/src/share/classes/com/sun/swing/internal/plaf/synth/resources \
        $(JDK_TOPDIR)/src/share/classes/com/sun/tools/jdi/resources \
        $(JDK_TOPDIR)/src/share/classes/sun/awt/resources \
        $(JDK_TOPDIR)/src/share/classes/sun/launcher/resources \
        $(JDK_TOPDIR)/src/share/classes/sun/management/resources \
        $(JDK_TOPDIR)/src/share/classes/sun/print/resources \
        $(JDK_TOPDIR)/src/share/classes/sun/tools/jar/resources \
        $(JDK_TOPDIR)/src/share/classes/sun/util/logging/resources)) \
    #

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

ifeq ($(OPENJDK_TARGET_OS), windows)
  COMPILE_PROP_SRC_FILES += \
      $(filter %.properties, $(call CacheFind, \
          $(JDK_TOPDIR)/src/windows/classes/sun/awt/windows)) \
      #
else # ! windows
  COMPILE_PROP_SRC_FILES += \
      $(filter %.properties, $(call CacheFind, \
          $(JDK_TOPDIR)/src/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/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)
        # 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

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

$(JDK_OUTPUTDIR)/gensrc/%_zh_HK.java: $(JDK_OUTPUTDIR)/gensrc/%_zh_TW.java
	$(call convert_tw_to_hk)

ZH_HK_JAVA := sun/applet/resources/MsgAppletViewer_zh_HK.java \
    sun/misc/resources/Messages_zh_HK.java \
    sun/security/util/AuthResources_zh_HK.java \
    sun/security/util/Resources_zh_HK.java

ZH_HK_JAVA_FILES := $(addprefix $(JDK_OUTPUTDIR)/gensrc/, $(ZH_HK_JAVA)) \
    $(filter-out $(JDK_OUTPUTDIR)/gensrc/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)