jdk/makefiles/scripts/genCharsetProvider.sh
author ihse
Thu, 10 Oct 2013 15:06:21 +0200
changeset 20547 453837141fac
parent 14342 8435a30053c1
permissions -rw-r--r--
8001931: The new build system whitespace cleanup Reviewed-by: tbell, simonis, erikj
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
#
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 12892
diff changeset
     4
# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
12892
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
20547
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    31
#   NAWK    awk tool
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    32
#   TEMPDIR temporary directory
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    33
#   HASHER  Hasher program
12892
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 '
20547
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    39
    /^[ \t]*copyright / { printf "COPYRIGHT_YEARS=\"%s %s\"\n", $2, $3; }
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    40
    /^[ \t]*package / { printf "PKG=%s\n", $2; }
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    41
    /^[ \t]*class / { printf "CLASS=%s\n", $2; }
12892
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 '
20547
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    72
    BEGIN { n = 1; m = 1; }
12892
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    73
20547
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    74
    /^[ \t]*charset / {
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    75
      csn = $2; cln = $3;
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    76
      lcsn = tolower(csn);
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    77
      lcsns[n++] = lcsn;
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    78
      csns[lcsn] = csn;
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    79
      classMap[lcsn] = cln;
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    80
      if (n > 2)
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    81
        printf "    };\n\n";
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    82
      printf "    static final String[] aliases_%s = new String[] {\n", cln;
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    83
    }
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    84
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    85
    /^[ \t]*alias / {
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    86
      acsns[m++] = tolower($2);
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    87
      aliasMap[tolower($2)] = lcsn;
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    88
      printf "        \"%s\",\n", $2;
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    89
    }
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    90
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    91
    END {
12892
3ef14bab6254 7170079: Adjustments to build-infra makefiles
erikj
parents:
diff changeset
    92
      printf "    };\n\n";
20547
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
    93
    }
12892
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 '
20547
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
   100
    /^[ \t]*charset / {
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
   101
      csn = $2;
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
   102
      lcsn = tolower(csn);
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
   103
    }
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
   104
    /^[ \t]*alias / {
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
   105
      an = tolower($2);
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
   106
      printf "%-20s \"%s\"\n", an, lcsn;
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
   107
    }
12892
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 '
20547
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
   111
    /^[ \t]*charset / {
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
   112
      csn = $2; cln = $3;
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
   113
      lcsn = tolower(csn);
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
   114
      printf "%-20s \"%s\"\n", lcsn, cln;
453837141fac 8001931: The new build system whitespace cleanup
ihse
parents: 14342
diff changeset
   115
    }
12892
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__