make/gensrc/GensrcCommonLangtools.gmk
author michaelm
Tue, 12 Nov 2019 15:07:15 +0000
branchunixdomainchannels
changeset 59030 8555f68967d1
parent 54380 e297c7bb6469
permissions -rw-r--r--
Added connection setup time benchmark
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     1
#
54380
e297c7bb6469 8189861: Refactor CacheFind
erikj
parents: 52804
diff changeset
     2
# Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     4
#
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     7
# published by the Free Software Foundation.  Oracle designates this
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     8
# particular file as subject to the "Classpath" exception as provided
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
     9
# by Oracle in the LICENSE file that accompanied this code.
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    10
#
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    15
# accompanied this code).
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    16
#
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    20
#
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    23
# questions.
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    24
#
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    25
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    26
# This must be the first rule
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    27
default: all
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    28
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    29
include $(SPEC)
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    30
include MakeBase.gmk
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    31
include JavaCompilation.gmk
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    32
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    33
################################################################################
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    34
# The compileprops tools compiles a properties file into a resource bundle.
41253
7a2422a5b481 8166965: Some small java build tools are still running with big JVM configuration
erikj
parents: 40233
diff changeset
    35
TOOL_COMPILEPROPS_CMD := $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/langtools_tools_classes \
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    36
    compileproperties.CompileProperties -quiet
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    37
28334
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
    38
################################################################################
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
    39
# The compileprops tools compiles a properties file into an enum-like class.
41253
7a2422a5b481 8166965: Some small java build tools are still running with big JVM configuration
erikj
parents: 40233
diff changeset
    40
TOOL_PARSEPROPS_CMD := $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/langtools_tools_classes \
28334
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
    41
    propertiesparser.PropertiesParser
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
    42
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    43
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    44
################################################################################
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    45
# Sets up a rule that creates a version.properties file in the gensrc output
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    46
# directory.
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    47
# Param 1 - Variable to add generated file name to
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    48
# Param 2 - Name of version.properties file including packages from the src
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    49
#           root.
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    50
define SetupVersionProperties
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    51
  $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/$$(strip $2):
52065
dea8a62cdfc3 8211724: Change mkdir -p to MakeDir macro where possible
erikj
parents: 50590
diff changeset
    52
	$$(call MakeTargetDir)
34070
792098bae87e 8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents: 28458
diff changeset
    53
	$(PRINTF) "jdk=$(VERSION_NUMBER)\nfull=$(VERSION_STRING)\nrelease=$(VERSION_SHORT)\n" \
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    54
	    > $$@
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    55
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    56
  $$(strip $1) += $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/$$(strip $2)
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    57
endef
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    58
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    59
################################################################################
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    60
# Finds all properties files in the module source and creates a rule that runs
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    61
# CompileProperties on them into the gensrc dir.
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    62
# Param 1 - Variable to add targets to
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    63
# Param 2 - Extra properties files to process
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    64
define SetupCompileProperties
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    65
  # Lookup the properties that need to be compiled into resource bundles.
28458
f20c5dd05e34 8069164: Fix langtools make build so that diagnostic framework can be used
mcimadamore
parents: 28334
diff changeset
    66
  PROPSOURCES := $2 \
54380
e297c7bb6469 8189861: Refactor CacheFind
erikj
parents: 52804
diff changeset
    67
      $$(call FindFiles, $(TOPDIR)/src/$(MODULE)/share/classes, *.properties)
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    68
50590
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 47217
diff changeset
    69
  # Filter out any excluded translations
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 47217
diff changeset
    70
  PROPSOURCES := $$(call FilterExcludedTranslations, $$(PROPSOURCES), .properties)
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 47217
diff changeset
    71
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    72
  # Convert .../src/<module>/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    73
  # to .../langtools/gensrc/<module>/com/sun/tools/javac/resources/javac_zh_CN.java
34070
792098bae87e 8085822: JEP 223: New Version-String Scheme (initial integration)
ihse
parents: 28458
diff changeset
    74
  # Strip away prefix and suffix, leaving for example only:
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    75
  # "<module>/share/classes/com/sun/tools/javac/resources/javac_zh_CN"
47217
72e3ae9a25eb 8187444: Forest Consolidation: Make build work
erikj
parents: 47216
diff changeset
    76
  PROPJAVAS := $$(patsubst $(TOPDIR)/src/%, \
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    77
      $(SUPPORT_OUTPUTDIR)/gensrc/%, \
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    78
      $$(patsubst %.properties, %.java, \
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    79
      $$(subst /share/classes,, $$(PROPSOURCES))))
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    80
28458
f20c5dd05e34 8069164: Fix langtools make build so that diagnostic framework can be used
mcimadamore
parents: 28334
diff changeset
    81
  # Generate the package dirs for the to be generated java files. Sort to remove
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    82
  # duplicates.
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    83
  PROPDIRS := $$(sort $$(dir $$(PROPJAVAS)))
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    84
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    85
  # Now generate a sequence of:
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    86
  # "-compile ...javac_zh_CN.properties ...javac_zh_CN.java java.util.ListResourceBundle"
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    87
  # suitable to be fed into the CompileProperties command.
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    88
  PROPCMDLINE := $$(subst _SPACE_, $(SPACE), \
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    89
      $$(join $$(addprefix -compile_SPACE_, $$(PROPSOURCES)), \
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    90
      $$(addsuffix _SPACE_java.util.ListResourceBundle, \
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    91
      $$(addprefix _SPACE_, $$(PROPJAVAS)))))
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    92
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    93
  # Now setup the rule for the generation of the resource bundles.
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    94
  $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/_the_props: $$(PROPSOURCES)
52065
dea8a62cdfc3 8211724: Change mkdir -p to MakeDir macro where possible
erikj
parents: 50590
diff changeset
    95
	$$(call MakeDir, $$(@D) $$(PROPDIRS))
28458
f20c5dd05e34 8069164: Fix langtools make build so that diagnostic framework can be used
mcimadamore
parents: 28334
diff changeset
    96
	$(FIND) $$(@D) -name "*.java" -a ! -name "*Properties.java" $(FIND_DELETE)
27579
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    97
	$(ECHO) Compiling $$(words $$(PROPSOURCES)) properties into resource bundles for $(MODULE)
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    98
	$(TOOL_COMPILEPROPS_CMD) $$(PROPCMDLINE)
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
    99
	$(TOUCH) $$@
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   100
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   101
  $$(strip $1) += $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/_the_props
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   102
endef
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   103
d1a63c99cdd5 8049367: Modular Run-Time Images
chegar
parents:
diff changeset
   104
################################################################################
28334
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
   105
# Parse property files in given location and generate a Java-like enum in the gensrc folder.
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
   106
# Param 1 - Variable to add targets to
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
   107
# Param 2 - Extra properties files to process
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
   108
define SetupParseProperties
28458
f20c5dd05e34 8069164: Fix langtools make build so that diagnostic framework can be used
mcimadamore
parents: 28334
diff changeset
   109
  # property files to process
47217
72e3ae9a25eb 8187444: Forest Consolidation: Make build work
erikj
parents: 47216
diff changeset
   110
  PARSEPROPSOURCES := $$(addprefix $(TOPDIR)/src/$(MODULE)/share/classes/, $2)
50590
5fa19bad622d 8204973: Add build support for filtering translations
erikj
parents: 47217
diff changeset
   111
  PARSEPROPSOURCES := $$(call FilterExcludedTranslations, $$(PARSEPROPSOURCES), .properties)
28334
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
   112
47217
72e3ae9a25eb 8187444: Forest Consolidation: Make build work
erikj
parents: 47216
diff changeset
   113
  PARSEPROPALLDIRS := $$(patsubst $(TOPDIR)/src/$(MODULE)/share/classes/%, \
28458
f20c5dd05e34 8069164: Fix langtools make build so that diagnostic framework can be used
mcimadamore
parents: 28334
diff changeset
   114
      $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/%, \
28334
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
   115
      $$(dir $$(PARSEPROPSOURCES)))
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
   116
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
   117
  PARSEPROPDIRS := $$(sort $$(PARSEPROPALLDIRS))
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
   118
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
   119
  PARSEPROPCMDLINE := $$(subst _SPACE_, $$(SPACE), \
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
   120
    $$(join $$(foreach var,$$(PARSEPROPSOURCES),$$(addprefix -compile_SPACE_,$$(var))), \
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
   121
    $$(addprefix _SPACE_, $$(PARSEPROPALLDIRS))))
28458
f20c5dd05e34 8069164: Fix langtools make build so that diagnostic framework can be used
mcimadamore
parents: 28334
diff changeset
   122
28334
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
   123
  # Now setup the rule for the generation of the resource bundles.
40233
286c12601bad 8157100: missing dependency in build system
erikj
parents: 34070
diff changeset
   124
  $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/_the_parsed_props: $$(PARSEPROPSOURCES)
52065
dea8a62cdfc3 8211724: Change mkdir -p to MakeDir macro where possible
erikj
parents: 50590
diff changeset
   125
	$$(call MakeDir, $$(@D) $$(PARSEPROPDIRS))
28458
f20c5dd05e34 8069164: Fix langtools make build so that diagnostic framework can be used
mcimadamore
parents: 28334
diff changeset
   126
	$(FIND) $$(@D) -name "*Properties.java" $(FIND_DELETE)
28334
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
   127
	$(ECHO) Parsing $$(words $$(PARSEPROPSOURCES)) properties into enum-like class for $(MODULE)
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
   128
	$(TOOL_PARSEPROPS_CMD) $$(PARSEPROPCMDLINE)
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
   129
	$(TOUCH) $$@
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
   130
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
   131
  $$(strip $1) += $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/_the_parsed_props
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
   132
endef
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
   133
1633de6070ae 8058542: Devise scheme for better diagnostic creation
mcimadamore
parents: 27579
diff changeset
   134
################################################################################