8033236: Update GensrcCharsetMapping.gmk to build-infra standards

Reviewed-by: erikj, mduigou, sherman
This commit is contained in:
Magnus Ihse Bursie 2014-02-04 10:00:24 +01:00
parent a80e3ed0ee
commit 6c54a7ef11
7 changed files with 184 additions and 201 deletions

View File

@ -29,6 +29,7 @@ include $(SPEC)
include MakeBase.gmk
include JavaCompilation.gmk
include NativeCompilation.gmk
include TextFileProcessing.gmk
# Setup the java compilers for the JDK build.
include Setup.gmk

View File

@ -102,7 +102,7 @@ TOOL_JDWPGEN = $(JAVA) -cp $(JDK_OUTPUTDIR)/btclasses build.tools.jdwpgen.Main
# TODO: Lots of files in jdk/make/tools/CharsetMapping dir
TOOL_CHARSETMAPPING = $(JAVA) -cp $(JDK_OUTPUTDIR)/btclasses \
build.tools.charsetmapping.Main
build.tools.charsetmapping.Main $(LOG_INFO)
TOOL_SPP = $(JAVA) -cp $(JDK_OUTPUTDIR)/btclasses build.tools.spp.Spp

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2000, 2014, 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
@ -34,11 +34,6 @@
# compared to the charsets packaged in "ExtendedCharsets" provider,
# which is lazy initialized.
# This year should only change if the generated source is modified.
copyright 2000, 2007,
package sun.nio.cs
class StandardCharsets
charset US-ASCII US_ASCII
# IANA aliases

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2014, 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
@ -25,80 +25,151 @@
GENSRC_CHARSETMAPPING :=
GENSRC_TMP := $(JDK_OUTPUTDIR)/gensrc
GENSRC_DST := $(JDK_OUTPUTDIR)/gensrc/sun/nio/cs
GENSRC_DATA := $(JDK_TOPDIR)/make/data/charsetmapping
GENSRC_JAVA_SRC := $(JDK_TOPDIR)/make/src/classes/build/tools/charsetmapping
GENSRC_TEMPLATES := $(GENSRC_DATA)/SingleByte-X.java.template $(GENSRC_DATA)/DoubleByte-X.java.template
CHARSET_DATA_DIR := $(JDK_TOPDIR)/make/data/charsetmapping
###
$(GENSRC_TMP)/_the.charsetmapping.dir:
$(ECHO) Generating charsetmapping classes
$(MKDIR) -p $(GENSRC_DST)/ext
$(TOUCH) $@
### Generate files using the charsetmapping tool
###
GENSRC_SB := $(GENSRC_TMP)/_the.charsetmapping.sbcs
CHARSET_GENSRC_JAVA_DIR := $(JDK_OUTPUTDIR)/gensrc/sun/nio/cs
CHARSET_DONE := $(CHARSET_GENSRC_JAVA_DIR)/_the.charsetmapping
CHARSET_COPYRIGHT_HEADER_BASE := $(JDK_TOPDIR)/make/src/classes/build/tools/charsetmapping
CHARSET_TEMPLATES := \
$(CHARSET_DATA_DIR)/SingleByte-X.java.template \
$(CHARSET_DATA_DIR)/DoubleByte-X.java.template
$(GENSRC_SB): $(GENSRC_DATA)/sbcs $(GENSRC_TEMPLATES) $(GENSRC_TMP)/_the.charsetmapping.dir
$(TOOL_CHARSETMAPPING) $(LOG_INFO) $(GENSRC_DATA) $(GENSRC_DST) sbcs
$(TOUCH) $@
# This target should be referenced using the order-only operator (|)
$(CHARSET_GENSRC_JAVA_DIR)/ext:
$(ECHO) "Generating charset mappings"
$(MKDIR) -p $(CHARSET_GENSRC_JAVA_DIR)/ext
GENSRC_CHARSETMAPPING += $(GENSRC_SB)
$(CHARSET_DONE)-sbcs: $(CHARSET_DATA_DIR)/sbcs \
$(CHARSET_TEMPLATES) $(BUILD_TOOLS) | $(CHARSET_GENSRC_JAVA_DIR)/ext
$(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR) sbcs
$(TOUCH) '$@'
$(CHARSET_DONE)-extsbcs: $(CHARSET_DATA_DIR)/extsbcs \
$(CHARSET_DONE)-sbcs $(CHARSET_TEMPLATES) $(BUILD_TOOLS)
$(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR)/ext extsbcs
$(TOUCH) '$@'
$(CHARSET_DONE)-dbcs: $(CHARSET_DATA_DIR)/dbcs \
$(CHARSET_DONE)-sbcs $(CHARSET_TEMPLATES) $(BUILD_TOOLS)
$(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR)/ext dbcs
$(TOUCH) '$@'
$(CHARSET_DONE)-hkscs: $(CHARSET_COPYRIGHT_HEADER_BASE)/HKSCS.java \
$(CHARSET_DONE)-sbcs $(BUILD_TOOLS)
$(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR)/ext hkscs '$<'
$(TOUCH) '$@'
$(CHARSET_DONE)-euctw: $(CHARSET_COPYRIGHT_HEADER_BASE)/EUC_TW.java \
$(CHARSET_DONE)-sbcs $(BUILD_TOOLS)
$(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR)/ext euctw '$<'
$(TOUCH) '$@'
$(CHARSET_GENSRC_JAVA_DIR)/ext/sjis0213.dat: $(CHARSET_DATA_DIR)/sjis0213.map \
$(CHARSET_DONE)-sbcs $(BUILD_TOOLS)
$(TOOL_CHARSETMAPPING) '$<' '$@' sjis0213
GENSRC_CHARSETMAPPING += \
$(CHARSET_DONE)-sbcs \
$(CHARSET_DONE)-extsbcs \
$(CHARSET_DONE)-dbcs \
$(CHARSET_DONE)-hkscs \
$(CHARSET_DONE)-euctw \
$(CHARSET_GENSRC_JAVA_DIR)/ext/sjis0213.dat \
#
###
$(GENSRC_DST)/ext/sjis0213.dat: $(GENSRC_DATA)/sjis0213.map $(GENSRC_SB)
$(TOOL_CHARSETMAPPING) $(LOG_INFO) $< $@ sjis0213
GENSRC_CHARSETMAPPING += $(GENSRC_DST)/ext/sjis0213.dat
### Generate the sun/nio/cs/StandardCharsets.java file
###
$(GENSRC_DST)/ext/EUC_TWMapping.java: $(GENSRC_JAVA_SRC)/EUC_TW.java $(GENSRC_SB)
$(TOOL_CHARSETMAPPING) $(LOG_INFO) $(GENSRC_DATA) $(GENSRC_DST)/ext euctw $(GENSRC_JAVA_SRC)/EUC_TW.java
CHARSET_STANDARD_GENSRC_DIR := $(JDK_OUTPUTDIR)/gensrc/standardcharsets
CHARSET_STANDARD_DATA := $(CHARSET_DATA_DIR)/standard-charsets
CHARSET_STANDARD_JAVA := sun/nio/cs/StandardCharsets.java
GENSRC_CHARSETMAPPING += $(GENSRC_DST)/ext/EUC_TWMapping.java
CHARSET_ALIASES_TABLES_AWK := ' \
BEGIN { n = 1; m = 1; } \
/^[ \t]*charset / { \
csn = $$2; cln = $$3; \
lcsn = tolower(csn); \
lcsns[n++] = lcsn; \
csns[lcsn] = csn; \
classMap[lcsn] = cln; \
if (n > 2) \
printf " };\n\n"; \
printf " static final String[] aliases_%s = new String[] {\n", cln; \
} \
/^[ \t]*alias / { \
acsns[m++] = tolower($$2); \
aliasMap[tolower($$2)] = lcsn; \
printf " \"%s\",\n", $$2; \
} \
END { \
printf " };\n\n"; \
} '
###
CHARSET_ALIASES_MAP_AWK := ' \
/^[ \t]*charset / { \
csn = $$2; \
lcsn = tolower(csn); \
} \
/^[ \t]*alias / { \
an = tolower($$2); \
printf "%-20s \"%s\"\n", an, lcsn; \
} '
$(GENSRC_DST)/ext/HKSCSMapping.java: $(GENSRC_JAVA_SRC)/HKSCS.java $(GENSRC_SB)
$(TOOL_CHARSETMAPPING) $(LOG_INFO) $(GENSRC_DATA) $(GENSRC_DST)/ext hkscs $(GENSRC_JAVA_SRC)/HKSCS.java
CHARSET_CLASSES_MAP_AWK := ' \
/^[ \t]*charset / { \
csn = $$2; cln = $$3; \
lcsn = tolower(csn); \
printf "%-20s \"%s\"\n", lcsn, cln; \
} '
GENSRC_CHARSETMAPPING += $(GENSRC_DST)/ext/HKSCSMapping.java
# This target should be referenced using the order-only operator (|)
$(CHARSET_STANDARD_GENSRC_DIR):
$(MKDIR) -p '$@'
###
$(CHARSET_STANDARD_GENSRC_DIR)/aliases-tables.java.snippet: $(CHARSET_STANDARD_DATA) \
| $(CHARSET_STANDARD_GENSRC_DIR)
$(NAWK) < '$<' > '$@' $(CHARSET_ALIASES_TABLES_AWK)
$(GENSRC_TMP)/gensrc_the.charsetmapping.extsbcs: $(GENSRC_DATA)/extsbcs $(GENSRC_TEMPLATES) $(GENSRC_SB)
$(TOOL_CHARSETMAPPING) $(GENSRC_DATA) $(LOG_INFO) $(GENSRC_DST)/ext extsbcs
$(TOUCH) $@
$(CHARSET_STANDARD_GENSRC_DIR)/aliases-map: $(CHARSET_STANDARD_DATA) \
| $(CHARSET_STANDARD_GENSRC_DIR)
$(NAWK) < '$<' > '$@' $(CHARSET_ALIASES_MAP_AWK)
GENSRC_CHARSETMAPPING += $(GENSRC_TMP)/gensrc_the.charsetmapping.extsbcs
$(CHARSET_STANDARD_GENSRC_DIR)/classes-map: $(CHARSET_STANDARD_DATA) \
| $(CHARSET_STANDARD_GENSRC_DIR)
$(NAWK) < '$<' > '$@' $(CHARSET_CLASSES_MAP_AWK)
###
$(CHARSET_STANDARD_GENSRC_DIR)/aliases-map.java.snippet: $(CHARSET_STANDARD_GENSRC_DIR)/aliases-map \
$(BUILD_TOOLS) | $(CHARSET_STANDARD_GENSRC_DIR)
$(TOOL_HASHER) -i Aliases < '$<' > '$@'
$(GENSRC_TMP)/gensrc_the.charsetmapping.dbcs: $(GENSRC_DATA)/dbcs $(GENSRC_TEMPLATES) $(GENSRC_SB)
$(TOOL_CHARSETMAPPING) $(GENSRC_DATA) $(LOG_INFO) $(GENSRC_DST)/ext dbcs
$(TOUCH) $@
$(CHARSET_STANDARD_GENSRC_DIR)/classes-map.java.snippet: $(CHARSET_STANDARD_GENSRC_DIR)/classes-map \
$(BUILD_TOOLS) | $(CHARSET_STANDARD_GENSRC_DIR)
$(TOOL_HASHER) -i Classes < '$<' > '$@'
GENSRC_CHARSETMAPPING += $(GENSRC_TMP)/gensrc_the.charsetmapping.dbcs
$(CHARSET_STANDARD_GENSRC_DIR)/cache-map.java.snippet: $(CHARSET_STANDARD_GENSRC_DIR)/classes-map \
$(BUILD_TOOLS) | $(CHARSET_STANDARD_GENSRC_DIR)
$(TOOL_HASHER) -i -e Cache -t Charset < '$<' > '$@'
###
$(eval $(call SetupTextFileProcessing, BUILD_CHARSET_STANDARD, \
SOURCE_FILES := $(JDK_TOPDIR)/src/share/classes/$(CHARSET_STANDARD_JAVA).template, \
OUTPUT_FILE := $(JDK_OUTPUTDIR)/gensrc/$(CHARSET_STANDARD_JAVA), \
INCLUDES := \
_INCLUDE_ALIASES_TABLES_ => $(CHARSET_STANDARD_GENSRC_DIR)/aliases-tables.java.snippet ; \
_INCLUDE_ALIASES_MAP_ => $(CHARSET_STANDARD_GENSRC_DIR)/aliases-map.java.snippet ; \
_INCLUDE_CLASSES_MAP_ => $(CHARSET_STANDARD_GENSRC_DIR)/classes-map.java.snippet ; \
_INCLUDE_CACHE_MAP_ => $(CHARSET_STANDARD_GENSRC_DIR)/cache-map.java.snippet ; , \
))
GENSRC_CHARSET_PROVIDER_CMD := $(JDK_TOPDIR)/make/scripts/genCharsetProvider.sh
# Processing of template depends on the snippets being generated first
$(BUILD_CHARSET_STANDARD): \
$(CHARSET_STANDARD_GENSRC_DIR)/aliases-tables.java.snippet \
$(CHARSET_STANDARD_GENSRC_DIR)/aliases-map.java.snippet \
$(CHARSET_STANDARD_GENSRC_DIR)/classes-map.java.snippet \
$(CHARSET_STANDARD_GENSRC_DIR)/cache-map.java.snippet
$(GENSRC_DST)/StandardCharsets.java: $(JDK_TOPDIR)/src/share/classes/sun/nio/cs/standard-charsets \
$(GENSRC_CHARSET_PROVIDER_CMD) \
$(GENSRC_TMP)/_the.charsetmapping.dir
NAWK="$(NAWK)" TEMPDIR="$(GENSRC_TMP)" SH="$(SH)" \
HASHER="$(TOOL_HASHER)" \
SCRIPTS="$(JDK_TOPDIR)/make/scripts" \
$(SH) -e $(GENSRC_CHARSET_PROVIDER_CMD) $(LOG_INFO) $< $(@D)
GENSRC_CHARSETMAPPING += $(GENSRC_DST)/StandardCharsets.java
$(GENSRC_CHARSETMAPPING): $(BUILD_TOOLS)
GENSRC_CHARSETMAPPING += $(BUILD_CHARSET_STANDARD)

View File

@ -1,131 +0,0 @@
#! /bin/sh
#
# Copyright (c) 2004, 2012, 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.
#
# Generate a charset provider class
# Required environment variables
# NAWK awk tool
# TEMPDIR temporary directory
# HASHER Hasher program
SPEC=$1; shift
DST=$1; shift
eval `$NAWK <$SPEC '
/^[ \t]*copyright / { printf "COPYRIGHT_YEARS=\"%s %s\"\n", $2, $3; }
/^[ \t]*package / { printf "PKG=%s\n", $2; }
/^[ \t]*class / { printf "CLASS=%s\n", $2; }
'`
OUT=$DST/$CLASS.java
echo '-->' $OUT
# Header
#
$SH ${SCRIPTS}/addNotices.sh "$COPYRIGHT_YEARS" > $OUT
cat <<__END__ >>$OUT
// -- This file was mechanically generated: Do not edit! -- //
package $PKG;
import java.nio.charset.*;
public class $CLASS
extends FastCharsetProvider
{
__END__
# Alias tables
#
$NAWK <$SPEC >>$OUT '
BEGIN { n = 1; m = 1; }
/^[ \t]*charset / {
csn = $2; cln = $3;
lcsn = tolower(csn);
lcsns[n++] = lcsn;
csns[lcsn] = csn;
classMap[lcsn] = cln;
if (n > 2)
printf " };\n\n";
printf " static final String[] aliases_%s = new String[] {\n", cln;
}
/^[ \t]*alias / {
acsns[m++] = tolower($2);
aliasMap[tolower($2)] = lcsn;
printf " \"%s\",\n", $2;
}
END {
printf " };\n\n";
}
'
# Prehashed alias and class maps
#
$NAWK <$SPEC >$TEMPDIR/aliases '
/^[ \t]*charset / {
csn = $2;
lcsn = tolower(csn);
}
/^[ \t]*alias / {
an = tolower($2);
printf "%-20s \"%s\"\n", an, lcsn;
}
'
$NAWK <$SPEC >$TEMPDIR/classes '
/^[ \t]*charset / {
csn = $2; cln = $3;
lcsn = tolower(csn);
printf "%-20s \"%s\"\n", lcsn, cln;
}
'
${HASHER} -i Aliases <$TEMPDIR/aliases >>$OUT
${HASHER} -i Classes <$TEMPDIR/classes >>$OUT
${HASHER} -i -e Cache -t Charset <$TEMPDIR/classes >>$OUT
# Constructor
#
cat <<__END__ >>$OUT
public $CLASS() {
super("$PKG", new Aliases(), new Classes(), new Cache());
}
}
__END__

View File

@ -43,9 +43,6 @@ import java.util.*;
public class Hasher {
// This class cannot, sadly, make use of 1.5 features since it must be
// compiled and run with the bootstrap JDK, which is 1.4.2.
static final PrintStream out = System.out;
static final PrintStream err = System.err;
@ -184,11 +181,13 @@ public class Hasher {
if (md <= maxDepth) {
// Success
out.flush();
if (cln != null)
err.print(cln + ": ");
err.println("Table size " + (1 << nb) + " (" + nb + " bits)"
+ ", shift " + shift
+ ", max chain depth " + md);
if (verbose) {
if (cln != null)
err.print(cln + ": ");
err.println("Table size " + (1 << nb) + " (" + nb + " bits)"
+ ", shift " + shift
+ ", max chain depth " + md);
}
return this;
}
}

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 2000, 2014, 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.
*
*/
// -- This file was mechanically generated: Do not edit! -- //
package sun.nio.cs;
import java.nio.charset.*;
public class StandardCharsets
extends FastCharsetProvider
{
_INCLUDE_ALIASES_TABLES_
_INCLUDE_ALIASES_MAP_
_INCLUDE_CLASSES_MAP_
_INCLUDE_CACHE_MAP_
public StandardCharsets() {
super("sun.nio.cs", new Aliases(), new Classes(), new Cache());
}
}