hotspot/src/share/tools/ProjectCreator/WinGammaPlatform.java
author stefank
Tue, 23 Nov 2010 13:22:55 -0800
changeset 7397 5b173b4ca846
parent 5547 hotspot/src/share/tools/MakeDeps/WinGammaPlatform.java@f4b087cbb361
child 7452 b3fa838286de
permissions -rw-r--r--
6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
import java.io.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
import java.util.*;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
abstract class HsArgHandler extends ArgHandler {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
    static final int STRING = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
    static final int VECTOR = 2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
    static final int HASH   = 3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
    boolean nextNotKey(ArgIterator it) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
        if (it.next()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
            String s = it.get();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
            return (s.length() == 0) || (s.charAt(0) != '-');
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
            return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
    void empty(String key, String message) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
        if (key != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
            System.err.println("** Error: empty " + key);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
        if (message != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
            System.err.println(message);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
        WinGammaPlatform.usage();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
    static String getCfg(String val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
        int under = val.indexOf('_');
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
        int len = val.length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
        if (under != -1 && under < len - 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
            return val.substring(under+1, len);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
            return null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
class ArgRuleSpecific extends ArgRule {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
    ArgRuleSpecific(String arg, ArgHandler handler) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
        super(arg, handler);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    boolean match(String rulePattern, String arg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
        return rulePattern.startsWith(arg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
class SpecificHsArgHandler extends HsArgHandler {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    String message, argKey, valKey;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    int type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    public void handle(ArgIterator it) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
        String cfg = getCfg(it.get());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
        if (nextNotKey(it)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
            String val = it.get();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
            switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
            case VECTOR:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
                BuildConfig.addFieldVector(cfg, valKey, val);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
                break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
            case HASH:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
                BuildConfig.putFieldHash(cfg, valKey, val, "1");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
                break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
            case STRING:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
                BuildConfig.putField(cfg, valKey, val);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
                break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
            default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
                empty(valKey, "Unknown type: "+type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
            it.next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
            empty(argKey, message);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    SpecificHsArgHandler(String argKey, String valKey, String message, int type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
        this.argKey = argKey;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
        this.valKey = valKey;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
        this.message = message;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
        this.type = type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
class HsArgRule extends ArgRuleSpecific {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    HsArgRule(String argKey, String valKey, String message, int type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
        super(argKey, new SpecificHsArgHandler(argKey, valKey, message, type));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   120
public abstract class WinGammaPlatform {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    public boolean fileNameStringEquality(String s1, String s2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
        return s1.equalsIgnoreCase(s2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    static void usage() throws IllegalArgumentException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
        System.err.println("WinGammaPlatform platform-specific options:");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
        System.err.println("  -sourceBase <path to directory (workspace) " +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
                           "containing source files; no trailing slash>");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
        System.err.println("  -projectFileName <full pathname to which project file " +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
                           "will be written; all parent directories must " +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
                           "already exist>");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
        System.err.println("  If any of the above are specified, "+
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
                           "they must all be.");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
        System.err.println("  Additional, optional arguments, which can be " +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
                           "specified multiple times:");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
        System.err.println("    -absoluteInclude <string containing absolute " +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
                           "path to include directory>");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
        System.err.println("    -relativeInclude <string containing include " +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
                           "directory relative to -sourceBase>");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
        System.err.println("    -define <preprocessor flag to be #defined " +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
                           "(note: doesn't yet support " +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
                           "#define (flag) (value))>");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
        System.err.println("    -startAt <subdir of sourceBase>");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
        System.err.println("    -additionalFile <file not in database but " +
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   146
                           "which should show up in project file>");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
        System.err.println("    -additionalGeneratedFile <absolute path to " +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
                           "directory containing file; no trailing slash> " +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
                           "<name of file generated later in the build process>");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
        throw new IllegalArgumentException();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    public void addPerFileLine(Hashtable table,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
                               String fileName,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
                               String line) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
        Vector v = (Vector) table.get(fileName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
        if (v != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
            v.add(line);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
            v = new Vector();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
            v.add(line);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
            table.put(fileName, v);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
    protected static class PerFileCondData {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
        public String releaseString;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
        public String debugString;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    protected void addConditionalPerFileLine(Hashtable table,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
                                           String fileName,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
                                           String releaseLine,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
                                           String debugLine) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
        PerFileCondData data = new PerFileCondData();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
        data.releaseString = releaseLine;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
        data.debugString = debugLine;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
        Vector v = (Vector) table.get(fileName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
        if (v != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
            v.add(data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
            v = new Vector();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
            v.add(data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
            table.put(fileName, v);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
    protected static class PrelinkCommandData {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
      String description;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
      String commands;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
    protected void addPrelinkCommand(Hashtable table,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
                                     String build,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
                                     String description,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
                                     String commands) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
      PrelinkCommandData data = new PrelinkCommandData();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
      data.description = description;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
      data.commands = commands;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
      table.put(build, data);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
    public boolean findString(Vector v, String s) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
        for (Iterator iter = v.iterator(); iter.hasNext(); ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
            if (((String) iter.next()).equals(s)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
                return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
        return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
    /* This returns a String containing the full path to the passed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
       file name, or null if an error occurred. If the file was not
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
       found or was a duplicate and couldn't be resolved using the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
       preferred paths, the file name is added to the appropriate
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
       Vector of Strings. */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
    private String findFileInDirectory(String fileName,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
                                       DirectoryTree directory,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
                                       Vector preferredPaths,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
                                       Vector filesNotFound,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
                                       Vector filesDuplicate) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
        List locationsInTree = directory.findFile(fileName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
        int  rootNameLength = directory.getRootNodeName().length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
        String name = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
        if ((locationsInTree == null) ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
            (locationsInTree.size() == 0)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
            filesNotFound.add(fileName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
        } else if (locationsInTree.size() > 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
            // We shouldn't have duplicate file names in our workspace.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
            System.err.println();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
            System.err.println("There are multiple files named as: " + fileName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
            System.exit(-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
            // The following code could be safely removed if we don't need duplicate
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
            // file names.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
            // Iterate through them, trying to find one with a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
            // preferred path
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
        search:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
            {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
                for (Iterator locIter = locationsInTree.iterator();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
                     locIter.hasNext(); ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
                    DirectoryTreeNode node =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
                        (DirectoryTreeNode) locIter.next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
                    String tmpName = node.getName();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
                    for (Iterator prefIter = preferredPaths.iterator();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
                         prefIter.hasNext(); ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
                        // We need to make sure the preferred path is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
                        // found from the file path not including the root node name.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
                        if (tmpName.indexOf((String)prefIter.next(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
                                            rootNameLength) != -1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
                            name = tmpName;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
                            break search;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
                        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
                    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
            if (name == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
                filesDuplicate.add(fileName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
            name = ((DirectoryTreeNode) locationsInTree.get(0)).getName();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
        return name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
    protected String envVarPrefixedFileName(String fileName,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
                                            int sourceBaseLen,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
                                            DirectoryTree tree,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
                                            Vector preferredPaths,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
                                            Vector filesNotFound,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
                                            Vector filesDuplicate) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
        String fullName = findFileInDirectory(fileName,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
                                              tree,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
                                              preferredPaths,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
                                              filesNotFound,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
                                              filesDuplicate);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
        return fullName;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
     String getProjectName(String fullPath, String extension)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
        throws IllegalArgumentException, IOException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
        File file = new File(fullPath).getCanonicalFile();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
        fullPath = file.getCanonicalPath();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
        String parent = file.getParent();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
        if (!fullPath.endsWith(extension)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
            throw new IllegalArgumentException("project file name \"" +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
                                               fullPath +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
                                               "\" does not end in "+extension);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
        if ((parent != null) &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
            (!fullPath.startsWith(parent))) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
            throw new RuntimeException(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
                "Internal error: parent of file name \"" + parent +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
                "\" does not match file name \"" + fullPath + "\""
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
            );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
        int len = parent.length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
        if (!parent.endsWith(Util.sep)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
            len += Util.sep.length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
        int end = fullPath.length() - extension.length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
        if (len == end) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
            throw new RuntimeException(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
                "Internal error: file name was empty"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
            );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
        return fullPath.substring(len, end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
    protected abstract String getProjectExt();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   322
    public void createVcproj(String[] args)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
        throws IllegalArgumentException, IOException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
        parseArguments(args);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
        String projectFileName = BuildConfig.getFieldString(null, "ProjectFileName");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
        String ext = getProjectExt();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
        String projectName = getProjectName(projectFileName, ext);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
        writeProjectFile(projectFileName, projectName, createAllConfigs());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
    protected void writePrologue(String[] args) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
        System.err.println("WinGammaPlatform platform-specific arguments:");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
        for (int i = 0; i < args.length; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
            System.err.print(args[i] + " ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
        System.err.println();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
    void parseArguments(String[] args) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
        new ArgsParser(args,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
                       new ArgRule[]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
            {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
                new HsArgRule("-sourceBase",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
                              "SourceBase",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
                              "   (Did you set the HotSpotWorkSpace environment variable?)",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
                              HsArgHandler.STRING
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
                              ),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
                new HsArgRule("-buildBase",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
                              "BuildBase",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
                              "   (Did you set the HotSpotBuildSpace environment variable?)",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
                              HsArgHandler.STRING
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
                              ),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
                new HsArgRule("-projectFileName",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
                              "ProjectFileName",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
                              null,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
                              HsArgHandler.STRING
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
                              ),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
                new HsArgRule("-jdkTargetRoot",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
                              "JdkTargetRoot",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
                              "   (Did you set the HotSpotJDKDist environment variable?)",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
                              HsArgHandler.STRING
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
                              ),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
                new HsArgRule("-compiler",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
                              "CompilerVersion",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
                              "   (Did you set the VcVersion correctly?)",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
                              HsArgHandler.STRING
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
                              ),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
                new HsArgRule("-platform",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
                              "Platform",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
                              null,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
                              HsArgHandler.STRING
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
                              ),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
                new HsArgRule("-absoluteInclude",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
                              "AbsoluteInclude",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
                              null,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
                              HsArgHandler.VECTOR
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
                              ),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
                new HsArgRule("-relativeInclude",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
                              "RelativeInclude",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
                              null,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
                              HsArgHandler.VECTOR
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
                              ),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
                new HsArgRule("-define",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
                              "Define",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
                              null,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
                              HsArgHandler.VECTOR
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
                              ),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
                new HsArgRule("-useToGeneratePch",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
                              "UseToGeneratePch",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
                              null,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
                              HsArgHandler.STRING
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
                              ),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
                new ArgRuleSpecific("-perFileLine",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
                            new HsArgHandler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
                                public void handle(ArgIterator it) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
                                    String cfg = getCfg(it.get());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
                                    if (nextNotKey(it)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
                                        String fileName = it.get();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
                                        if (nextNotKey(it)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
                                            String line = it.get();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
                                            BuildConfig.putFieldHash(cfg, "PerFileLine", fileName, line);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
                                            it.next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
                                            return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
                                        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
                                    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
                                    empty(null, "** Error: wrong number of args to -perFileLine");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
                                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
                            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
                            ),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
                new ArgRuleSpecific("-conditionalPerFileLine",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
                            new HsArgHandler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
                                public void handle(ArgIterator it) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
                                    String cfg = getCfg(it.get());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
                                    if (nextNotKey(it)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
                                        String fileName = it.get();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
                                        if (nextNotKey(it)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
                                            String productLine = it.get();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
                                            if (nextNotKey(it)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
                                                String debugLine = it.get();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
                                                BuildConfig.putFieldHash(cfg+"_debug", "CondPerFileLine",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
                                                                         fileName, debugLine);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
                                                BuildConfig.putFieldHash(cfg+"_product", "CondPerFileLine",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
                                                                         fileName, productLine);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
                                                it.next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
                                                return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
                                            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
                                        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
                                    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
                                    empty(null, "** Error: wrong number of args to -conditionalPerFileLine");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
                                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
                            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
                            ),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
                new HsArgRule("-disablePch",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
                              "DisablePch",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
                              null,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
                              HsArgHandler.HASH
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
                              ),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
                new ArgRule("-startAt",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
                            new HsArgHandler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
                                public void handle(ArgIterator it) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
                                    if (BuildConfig.getField(null, "StartAt") != null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
                                        empty(null, "** Error: multiple -startAt");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
                                    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
                                    if (nextNotKey(it)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
                                        BuildConfig.putField(null, "StartAt", it.get());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
                                        it.next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
                                    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
                                        empty("-startAt", null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
                                    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
                                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
                            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
                            ),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
                new HsArgRule("-ignoreFile",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
                                      "IgnoreFile",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
                                      null,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
                                      HsArgHandler.HASH
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
                                      ),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   479
                new HsArgRule("-ignorePath",
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   480
                              "IgnorePath",
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   481
                              null,
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   482
                              HsArgHandler.VECTOR
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   483
                              ),
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   484
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
                new HsArgRule("-additionalFile",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
                              "AdditionalFile",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
                              null,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
                              HsArgHandler.VECTOR
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
                              ),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
                new ArgRuleSpecific("-additionalGeneratedFile",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
                            new HsArgHandler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
                                public void handle(ArgIterator it) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
                                    String cfg = getCfg(it.get());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
                                    if (nextNotKey(it)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
                                        String dir = it.get();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
                                        if (nextNotKey(it)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
                                            String fileName = it.get();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
                                            BuildConfig.putFieldHash(cfg, "AdditionalGeneratedFile",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
                                                                     Util.normalize(dir + Util.sep + fileName),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
                                                                     fileName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
                                            it.next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
                                            return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
                                        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
                                    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
                                    empty(null, "** Error: wrong number of args to -additionalGeneratedFile");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
                                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
                            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
                            ),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
                new ArgRule("-prelink",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
                            new HsArgHandler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
                                public void handle(ArgIterator it) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
                                    if (nextNotKey(it)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
                                        String build = it.get();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
                                        if (nextNotKey(it)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
                                            String description = it.get();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
                                            if (nextNotKey(it)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
                                                String command = it.get();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
                                                BuildConfig.putField(null, "PrelinkDescription", description);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
                                                BuildConfig.putField(null, "PrelinkCommand", command);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
                                                it.next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
                                                return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
                                            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
                                        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
                                    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
                                    empty(null,  "** Error: wrong number of args to -prelink");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
                                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
                            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
                            )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
            },
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
                                       new ArgHandler() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
                                           public void handle(ArgIterator it) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
                                               throw new RuntimeException("Arg Parser: unrecognized option "+it.get());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
                                           }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
                                       }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
                                       );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
        if (BuildConfig.getField(null, "SourceBase") == null      ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
            BuildConfig.getField(null, "BuildBase") == null       ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
            BuildConfig.getField(null, "ProjectFileName") == null ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
            BuildConfig.getField(null, "CompilerVersion") == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
            usage();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
        if (BuildConfig.getField(null, "UseToGeneratePch") == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
            throw new RuntimeException("ERROR: need to specify one file to compute PCH, with -useToGeneratePch flag");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
        BuildConfig.putField(null, "PlatformObject", this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
    Vector createAllConfigs() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
        Vector allConfigs = new Vector();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
        allConfigs.add(new C1DebugConfig());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
        boolean b = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
        if (b) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
            allConfigs.add(new C1FastDebugConfig());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
            allConfigs.add(new C1ProductConfig());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
            allConfigs.add(new C2DebugConfig());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
            allConfigs.add(new C2FastDebugConfig());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
            allConfigs.add(new C2ProductConfig());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
            allConfigs.add(new TieredDebugConfig());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
            allConfigs.add(new TieredFastDebugConfig());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
            allConfigs.add(new TieredProductConfig());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
            allConfigs.add(new CoreDebugConfig());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
            allConfigs.add(new CoreFastDebugConfig());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
            allConfigs.add(new CoreProductConfig());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
            allConfigs.add(new KernelDebugConfig());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
            allConfigs.add(new KernelFastDebugConfig());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
            allConfigs.add(new KernelProductConfig());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
        return allConfigs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
    class FileAttribute {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
        int     numConfigs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
        Vector  configs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
        String  shortName;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
        boolean noPch, pchRoot;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
        FileAttribute(String shortName, BuildConfig cfg, int numConfigs) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
            this.shortName = shortName;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
            this.noPch =  (cfg.lookupHashFieldInContext("DisablePch", shortName) != null);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
            this.pchRoot = shortName.equals(BuildConfig.getFieldString(null, "UseToGeneratePch"));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
            this.numConfigs = numConfigs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
            configs = new Vector();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
            add(cfg.get("Name"));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
        void add(String confName) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
            configs.add(confName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
            // if presented in all configs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
            if (configs.size() == numConfigs) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
                configs = null;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
    class FileInfo implements Comparable {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
        String        full;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
        FileAttribute attr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
        FileInfo(String full, FileAttribute  attr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
            this.full = full;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
            this.attr = attr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
        public int compareTo(Object o) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
            FileInfo oo = (FileInfo)o;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
            // Don't squelch identical short file names where the full
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
            // paths are different
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
            if (!attr.shortName.equals(oo.attr.shortName))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
              return attr.shortName.compareTo(oo.attr.shortName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
            return full.compareTo(oo.full);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
        boolean isHeader() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
            return attr.shortName.endsWith(".h") || attr.shortName.endsWith(".hpp");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
    TreeSet sortFiles(Hashtable allFiles) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
        TreeSet rv = new TreeSet();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
        Enumeration e = allFiles.keys();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
        while (e.hasMoreElements()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
            String fullPath = (String)e.nextElement();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
            rv.add(new FileInfo(fullPath, (FileAttribute)allFiles.get(fullPath)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
        return rv;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
    Hashtable computeAttributedFiles(Vector allConfigs) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
        Hashtable ht = new Hashtable();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
        int numConfigs = allConfigs.size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
        for (Iterator i = allConfigs.iterator(); i.hasNext(); ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
            BuildConfig bc = (BuildConfig)i.next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
            Hashtable  confFiles = (Hashtable)bc.getSpecificField("AllFilesHash");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
            String confName = bc.get("Name");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
            for (Enumeration e=confFiles.keys(); e.hasMoreElements(); ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
                String filePath = (String)e.nextElement();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
                FileAttribute fa = (FileAttribute)ht.get(filePath);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
                if (fa == null) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
                    fa = new FileAttribute((String)confFiles.get(filePath), bc, numConfigs);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
                    ht.put(filePath, fa);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
                } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
                    fa.add(confName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
                }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
            }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
        return ht;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
     Hashtable computeAttributedFiles(BuildConfig bc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
        Hashtable ht = new Hashtable();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
        Hashtable confFiles = (Hashtable)bc.getSpecificField("AllFilesHash");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
        for (Enumeration e = confFiles.keys(); e.hasMoreElements(); ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
            String filePath = (String)e.nextElement();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
            ht.put(filePath,  new FileAttribute((String)confFiles.get(filePath), bc, 1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
        return ht;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
    PrintWriter printWriter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
    public void writeProjectFile(String projectFileName, String projectName,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
                                 Vector allConfigs) throws IOException {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
        throw new RuntimeException("use compiler version specific version");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
}