jdk/makefiles/scripts/genCharsetProvider.sh
author amurillo
Wed, 15 Aug 2012 16:49:38 -0700
changeset 13465 d3fc5d192448
parent 12892 3ef14bab6254
child 14342 8435a30053c1
permissions -rw-r--r--
7191765: make jdk8 the default jprt release for hs24 Reviewed-by: jcoomes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12892
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
     1
#! /bin/sh
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
     2
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
     3
#
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
     4
# Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
     5
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
     6
#
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
     7
# This code is free software; you can redistribute it and/or modify it
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
     8
# under the terms of the GNU General Public License version 2 only, as
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
     9
# published by the Free Software Foundation.  Oracle designates this
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    10
# particular file as subject to the "Classpath" exception as provided
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    11
# by Oracle in the LICENSE file that accompanied this code.
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    12
#
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    13
# This code is distributed in the hope that it will be useful, but WITHOUT
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    14
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    15
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    16
# version 2 for more details (a copy is included in the LICENSE file that
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    17
# accompanied this code).
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    18
#
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    19
# You should have received a copy of the GNU General Public License version
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    20
# 2 along with this work; if not, write to the Free Software Foundation,
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    21
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    22
#
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    23
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    24
# or visit www.oracle.com if you need additional information or have any
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    25
# questions.
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    26
#
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    27
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    28
# Generate a charset provider class
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    29
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    30
# Required environment variables
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    31
#   NAWK	awk tool
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    32
#   TEMPDIR      temporary directory
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    33
#   HASHER	Hasher program
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    34
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    35
SPEC=$1; shift
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    36
DST=$1; shift
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    37
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    38
eval `$NAWK <$SPEC '
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    39
  /^[ \t]*copyright / { printf "COPYRIGHT_YEARS=\"%s %s\"\n", $2, $3; }
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    40
  /^[ \t]*package / { printf "PKG=%s\n", $2; }
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    41
  /^[ \t]*class / { printf "CLASS=%s\n", $2; }
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    42
'`
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    43
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    44
OUT=$DST/$CLASS.java
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    45
echo '-->' $OUT
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    46
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    47
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    48
# Header
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    49
#
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    50
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    51
$SH ${SCRIPTS}/addNotices.sh "$COPYRIGHT_YEARS" > $OUT
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    52
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    53
cat <<__END__ >>$OUT
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    54
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    55
// -- This file was mechanically generated: Do not edit! -- //
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    56
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    57
package $PKG;
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    58
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    59
import java.nio.charset.*;
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    60
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    61
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    62
public class $CLASS
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    63
    extends FastCharsetProvider
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    64
{
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    65
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    66
__END__
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    67
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    68
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    69
# Alias tables
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    70
#
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    71
$NAWK <$SPEC >>$OUT '
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    72
  BEGIN { n = 1; m = 1; }
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    73
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    74
  /^[ \t]*charset / {
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    75
    csn = $2; cln = $3;
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    76
    lcsn = tolower(csn);
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    77
    lcsns[n++] = lcsn;
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    78
    csns[lcsn] = csn;
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    79
    classMap[lcsn] = cln;
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    80
    if (n > 2)
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    81
      printf "    };\n\n";
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    82
    printf "    static final String[] aliases_%s = new String[] {\n", cln;
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    83
  }
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    84
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    85
  /^[ \t]*alias / {
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    86
    acsns[m++] = tolower($2);
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    87
    aliasMap[tolower($2)] = lcsn; 
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    88
    printf "        \"%s\",\n", $2;
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    89
  }
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    90
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    91
  END {
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    92
    printf "    };\n\n";
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    93
  }
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    94
'
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    95
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    96
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    97
# Prehashed alias and class maps
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    98
#
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    99
$NAWK <$SPEC >$TEMPDIR/aliases '
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   100
  /^[ \t]*charset / {
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   101
    csn = $2;
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   102
    lcsn = tolower(csn);
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   103
  }
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   104
  /^[ \t]*alias / {
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   105
    an = tolower($2);
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   106
    printf "%-20s \"%s\"\n", an, lcsn;
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   107
  }
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   108
'
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   109
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   110
$NAWK <$SPEC >$TEMPDIR/classes '
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   111
  /^[ \t]*charset / {
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   112
    csn = $2; cln = $3;
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   113
    lcsn = tolower(csn);
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   114
    printf "%-20s \"%s\"\n", lcsn, cln;
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   115
  }
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   116
'
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   117
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   118
${HASHER} -i Aliases <$TEMPDIR/aliases >>$OUT
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   119
${HASHER} -i Classes <$TEMPDIR/classes >>$OUT
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   120
${HASHER} -i -e Cache -t Charset <$TEMPDIR/classes >>$OUT
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   121
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   122
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   123
# Constructor
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   124
#
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   125
cat <<__END__ >>$OUT
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   126
    public $CLASS() {
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   127
        super("$PKG", new Aliases(), new Classes(), new Cache());
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   128
    }
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   129
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   130
}
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
   131
__END__