< prev index next >

make/src/classes/build/tools/projectcreator/WinGammaPlatform.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 20,31 **** * or visit www.oracle.com if you need additional information or have any * questions. * */ ! import java.io.*; ! import java.util.*; abstract class HsArgHandler extends ArgHandler { static final int STRING = 1; static final int VECTOR = 2; static final int HASH = 3; --- 20,38 ---- * or visit www.oracle.com if you need additional information or have any * questions. * */ ! package build.tools.projectcreator; ! ! import java.io.File; ! import java.io.IOException; ! import java.io.PrintWriter; ! import java.util.Hashtable; ! import java.util.Iterator; ! import java.util.Stack; ! import java.util.Vector; abstract class HsArgHandler extends ArgHandler { static final int STRING = 1; static final int VECTOR = 2; static final int HASH = 3;
*** 130,143 **** --- 137,157 ---- System.err.println(" -projectFileName <full pathname to which project file " + "will be written; all parent directories must " + "already exist>"); System.err.println(" If any of the above are specified, "+ "they must all be."); + System.err.println(" Note: if '-altRelativeInclude' option below " + + "is used, then the '-relativeAltSrcInclude' " + + "option must be used to specify the alternate " + + "source dir, e.g., 'src\\closed'"); System.err.println(" Additional, optional arguments, which can be " + "specified multiple times:"); System.err.println(" -absoluteInclude <string containing absolute " + "path to include directory>"); + System.err.println(" -altRelativeInclude <string containing " + + "alternate include directory relative to " + + "-sourceBase>"); System.err.println(" -relativeInclude <string containing include " + "directory relative to -sourceBase>"); System.err.println(" -define <preprocessor flag to be #defined " + "(note: doesn't yet support " + "#define (flag) (value))>");
*** 209,288 **** } return false; } - /* This returns a String containing the full path to the passed - file name, or null if an error occurred. If the file was not - found or was a duplicate and couldn't be resolved using the - preferred paths, the file name is added to the appropriate - Vector of Strings. */ - private String findFileInDirectory(String fileName, - DirectoryTree directory, - Vector preferredPaths, - Vector filesNotFound, - Vector filesDuplicate) { - List locationsInTree = directory.findFile(fileName); - int rootNameLength = directory.getRootNodeName().length(); - String name = null; - if ((locationsInTree == null) || - (locationsInTree.size() == 0)) { - filesNotFound.add(fileName); - } else if (locationsInTree.size() > 1) { - // We shouldn't have duplicate file names in our workspace. - System.err.println(); - System.err.println("There are multiple files named as: " + fileName); - System.exit(-1); - // The following code could be safely removed if we don't need duplicate - // file names. - - // Iterate through them, trying to find one with a - // preferred path - search: - { - for (Iterator locIter = locationsInTree.iterator(); - locIter.hasNext(); ) { - DirectoryTreeNode node = - (DirectoryTreeNode) locIter.next(); - String tmpName = node.getName(); - for (Iterator prefIter = preferredPaths.iterator(); - prefIter.hasNext(); ) { - // We need to make sure the preferred path is - // found from the file path not including the root node name. - if (tmpName.indexOf((String)prefIter.next(), - rootNameLength) != -1) { - name = tmpName; - break search; - } - } - } - } - - if (name == null) { - filesDuplicate.add(fileName); - } - } else { - name = ((DirectoryTreeNode) locationsInTree.get(0)).getName(); - } - - return name; - } - - protected String envVarPrefixedFileName(String fileName, - int sourceBaseLen, - DirectoryTree tree, - Vector preferredPaths, - Vector filesNotFound, - Vector filesDuplicate) { - String fullName = findFileInDirectory(fileName, - tree, - preferredPaths, - filesNotFound, - filesDuplicate); - return fullName; - } - String getProjectName(String fullPath, String extension) throws IllegalArgumentException, IOException { File file = new File(fullPath).getCanonicalFile(); fullPath = file.getCanonicalPath(); String parent = file.getParent(); --- 223,232 ----
*** 327,337 **** String projectFileName = BuildConfig.getFieldString(null, "ProjectFileName"); String ext = getProjectExt(); String projectName = getProjectName(projectFileName, ext); ! writeProjectFile(projectFileName, projectName, createAllConfigs()); } protected void writePrologue(String[] args) { System.err.println("WinGammaPlatform platform-specific arguments:"); for (int i = 0; i < args.length; i++) { --- 271,281 ---- String projectFileName = BuildConfig.getFieldString(null, "ProjectFileName"); String ext = getProjectExt(); String projectName = getProjectName(projectFileName, ext); ! writeProjectFile(projectFileName, projectName, createAllConfigs(BuildConfig.getFieldString(null, "PlatformName"))); } protected void writePrologue(String[] args) { System.err.println("WinGammaPlatform platform-specific arguments:"); for (int i = 0; i < args.length; i++) {
*** 343,364 **** void parseArguments(String[] args) { new ArgsParser(args, new ArgRule[] { ! new HsArgRule("-sourceBase", ! "SourceBase", ! " (Did you set the HotSpotWorkSpace environment variable?)", ! HsArgHandler.STRING ), new HsArgRule("-buildBase", "BuildBase", " (Did you set the HotSpotBuildSpace environment variable?)", HsArgHandler.STRING ), new HsArgRule("-projectFileName", "ProjectFileName", null, HsArgHandler.STRING ), --- 287,344 ---- void parseArguments(String[] args) { new ArgsParser(args, new ArgRule[] { ! new ArgRule("-sourceBase", ! new HsArgHandler() { ! public void handle(ArgIterator it) { ! String cfg = getCfg(it.get()); ! if (nextNotKey(it)) { ! String sb = (String) it.get(); ! if (sb.endsWith(Util.sep)) { ! sb = sb.substring(0, sb.length() - 1); ! } ! BuildConfig.putField(cfg, "SourceBase", sb); ! it.next(); ! } else { ! empty("-sourceBase", null); ! } ! } ! } ), new HsArgRule("-buildBase", "BuildBase", " (Did you set the HotSpotBuildSpace environment variable?)", HsArgHandler.STRING ), + new HsArgRule("-buildSpace", + "BuildSpace", + null, + HsArgHandler.STRING + ), + + new HsArgRule("-makeBinary", + "MakeBinary", + null, + HsArgHandler.STRING + ), + + new HsArgRule("-makeOutput", + "MakeOutput", + null, + HsArgHandler.STRING + ), + + new HsArgRule("-platformName", + "PlatformName", + null, + HsArgHandler.STRING + ), + new HsArgRule("-projectFileName", "ProjectFileName", null, HsArgHandler.STRING ),
*** 373,400 **** "CompilerVersion", " (Did you set the VcVersion correctly?)", HsArgHandler.STRING ), ! new HsArgRule("-platform", ! "Platform", null, ! HsArgHandler.STRING ), ! new HsArgRule("-absoluteInclude", ! "AbsoluteInclude", null, HsArgHandler.VECTOR ), new HsArgRule("-relativeInclude", "RelativeInclude", null, HsArgHandler.VECTOR ), new HsArgRule("-define", "Define", null, HsArgHandler.VECTOR ), --- 353,398 ---- "CompilerVersion", " (Did you set the VcVersion correctly?)", HsArgHandler.STRING ), ! new HsArgRule("-absoluteInclude", ! "AbsoluteInclude", null, ! HsArgHandler.VECTOR ), ! new HsArgRule("-altRelativeInclude", ! "AltRelativeInclude", null, HsArgHandler.VECTOR ), new HsArgRule("-relativeInclude", "RelativeInclude", null, HsArgHandler.VECTOR ), + new HsArgRule("-absoluteSrcInclude", + "AbsoluteSrcInclude", + null, + HsArgHandler.VECTOR + ), + + new HsArgRule("-relativeAltSrcInclude", + "RelativeAltSrcInclude", + null, + HsArgHandler.STRING + ), + + new HsArgRule("-relativeSrcInclude", + "RelativeSrcInclude", + null, + HsArgHandler.VECTOR + ), + new HsArgRule("-define", "Define", null, HsArgHandler.VECTOR ),
*** 480,489 **** --- 478,493 ---- "IgnorePath", null, HsArgHandler.VECTOR ), + new HsArgRule("-hidePath", + "HidePath", + null, + HsArgHandler.VECTOR + ), + new HsArgRule("-additionalFile", "AdditionalFile", null, HsArgHandler.VECTOR ),
*** 510,520 **** new ArgRule("-prelink", new HsArgHandler() { public void handle(ArgIterator it) { if (nextNotKey(it)) { - String build = it.get(); if (nextNotKey(it)) { String description = it.get(); if (nextNotKey(it)) { String command = it.get(); BuildConfig.putField(null, "PrelinkDescription", description); --- 514,523 ----
*** 526,536 **** } empty(null, "** Error: wrong number of args to -prelink"); } } ! ) }, new ArgHandler() { public void handle(ArgIterator it) { throw new RuntimeException("Arg Parser: unrecognized option "+it.get()); --- 529,560 ---- } empty(null, "** Error: wrong number of args to -prelink"); } } ! ), ! ! new ArgRule("-postbuild", ! new HsArgHandler() { ! public void handle(ArgIterator it) { ! if (nextNotKey(it)) { ! if (nextNotKey(it)) { ! String description = it.get(); ! if (nextNotKey(it)) { ! String command = it.get(); ! BuildConfig.putField(null, "PostbuildDescription", description); ! BuildConfig.putField(null, "PostbuildCommand", command); ! it.next(); ! return; ! } ! } ! } ! ! empty(null, "** Error: wrong number of args to -postbuild"); ! } ! } ! ), }, new ArgHandler() { public void handle(ArgIterator it) { throw new RuntimeException("Arg Parser: unrecognized option "+it.get());
*** 542,687 **** BuildConfig.getField(null, "ProjectFileName") == null || BuildConfig.getField(null, "CompilerVersion") == null) { usage(); } - if (BuildConfig.getField(null, "UseToGeneratePch") == null) { - throw new RuntimeException("ERROR: need to specify one file to compute PCH, with -useToGeneratePch flag"); - } - BuildConfig.putField(null, "PlatformObject", this); } ! Vector createAllConfigs() { Vector allConfigs = new Vector(); allConfigs.add(new C1DebugConfig()); - - boolean b = true; - if (b) { allConfigs.add(new C1FastDebugConfig()); allConfigs.add(new C1ProductConfig()); - allConfigs.add(new C2DebugConfig()); - allConfigs.add(new C2FastDebugConfig()); - allConfigs.add(new C2ProductConfig()); - allConfigs.add(new TieredDebugConfig()); allConfigs.add(new TieredFastDebugConfig()); allConfigs.add(new TieredProductConfig()); - allConfigs.add(new CoreDebugConfig()); - allConfigs.add(new CoreFastDebugConfig()); - allConfigs.add(new CoreProductConfig()); - - allConfigs.add(new KernelDebugConfig()); - allConfigs.add(new KernelFastDebugConfig()); - allConfigs.add(new KernelProductConfig()); - } - return allConfigs; } ! class FileAttribute { ! int numConfigs; ! Vector configs; ! String shortName; ! boolean noPch, pchRoot; ! ! FileAttribute(String shortName, BuildConfig cfg, int numConfigs) { ! this.shortName = shortName; ! this.noPch = (cfg.lookupHashFieldInContext("DisablePch", shortName) != null); ! this.pchRoot = shortName.equals(BuildConfig.getFieldString(null, "UseToGeneratePch")); ! this.numConfigs = numConfigs; ! configs = new Vector(); ! add(cfg.get("Name")); } ! void add(String confName) { ! configs.add(confName); ! // if presented in all configs ! if (configs.size() == numConfigs) { ! configs = null; ! } ! } } ! class FileInfo implements Comparable { ! String full; ! FileAttribute attr; ! FileInfo(String full, FileAttribute attr) { ! this.full = full; ! this.attr = attr; } - - public int compareTo(Object o) { - FileInfo oo = (FileInfo)o; - // Don't squelch identical short file names where the full - // paths are different - if (!attr.shortName.equals(oo.attr.shortName)) - return attr.shortName.compareTo(oo.attr.shortName); - return full.compareTo(oo.full); } ! boolean isHeader() { ! return attr.shortName.endsWith(".h") || attr.shortName.endsWith(".hpp"); } } ! TreeSet sortFiles(Hashtable allFiles) { ! TreeSet rv = new TreeSet(); ! Enumeration e = allFiles.keys(); ! while (e.hasMoreElements()) { ! String fullPath = (String)e.nextElement(); ! rv.add(new FileInfo(fullPath, (FileAttribute)allFiles.get(fullPath))); } ! return rv; } ! Hashtable computeAttributedFiles(Vector allConfigs) { ! Hashtable ht = new Hashtable(); ! int numConfigs = allConfigs.size(); ! ! for (Iterator i = allConfigs.iterator(); i.hasNext(); ) { ! BuildConfig bc = (BuildConfig)i.next(); ! Hashtable confFiles = (Hashtable)bc.getSpecificField("AllFilesHash"); ! String confName = bc.get("Name"); ! ! for (Enumeration e=confFiles.keys(); e.hasMoreElements(); ) { ! String filePath = (String)e.nextElement(); ! FileAttribute fa = (FileAttribute)ht.get(filePath); ! ! if (fa == null) { ! fa = new FileAttribute((String)confFiles.get(filePath), bc, numConfigs); ! ht.put(filePath, fa); ! } else { ! fa.add(confName); } } } ! return ht; } ! Hashtable computeAttributedFiles(BuildConfig bc) { ! Hashtable ht = new Hashtable(); ! Hashtable confFiles = (Hashtable)bc.getSpecificField("AllFilesHash"); ! for (Enumeration e = confFiles.keys(); e.hasMoreElements(); ) { ! String filePath = (String)e.nextElement(); ! ht.put(filePath, new FileAttribute((String)confFiles.get(filePath), bc, 1)); } ! return ht; } - PrintWriter printWriter; - public void writeProjectFile(String projectFileName, String projectName, - Vector allConfigs) throws IOException { - throw new RuntimeException("use compiler version specific version"); - } } --- 566,685 ---- BuildConfig.getField(null, "ProjectFileName") == null || BuildConfig.getField(null, "CompilerVersion") == null) { usage(); } BuildConfig.putField(null, "PlatformObject", this); } ! Vector createAllConfigs(String platform) { Vector allConfigs = new Vector(); allConfigs.add(new C1DebugConfig()); allConfigs.add(new C1FastDebugConfig()); allConfigs.add(new C1ProductConfig()); allConfigs.add(new TieredDebugConfig()); allConfigs.add(new TieredFastDebugConfig()); allConfigs.add(new TieredProductConfig()); return allConfigs; } ! PrintWriter printWriter; ! public void writeProjectFile(String projectFileName, String projectName, ! Vector<BuildConfig> allConfigs) throws IOException { ! throw new RuntimeException("use compiler version specific version"); } ! int indent; ! private Stack<String> tagStack = new Stack<String>(); ! private void startTagPrim(String name, String[] attrs, boolean close) { ! startTagPrim(name, attrs, close, true); } ! private void startTagPrim(String name, String[] attrs, boolean close, ! boolean newline) { ! doIndent(); ! printWriter.print("<" + name); ! indent++; ! if (attrs != null && attrs.length > 0) { ! for (int i = 0; i < attrs.length; i += 2) { ! printWriter.print(" " + attrs[i] + "=\"" + attrs[i + 1] + "\""); ! if (i < attrs.length - 2) { ! } } } ! if (close) { ! indent--; ! printWriter.print(" />"); ! } else { ! // TODO push tag name, and change endTag to pop and print. ! tagStack.push(name); ! printWriter.print(">"); ! } ! if (newline) { ! printWriter.println(); } } + void startTag(String name, String... attrs) { + startTagPrim(name, attrs, false); + } ! void startTagV(String name, Vector attrs) { ! String s[] = new String[attrs.size()]; ! for (int i = 0; i < attrs.size(); i++) { ! s[i] = (String) attrs.elementAt(i); } ! startTagPrim(name, s, false); } ! void endTag() { ! String name = tagStack.pop(); ! indent--; ! doIndent(); ! printWriter.println("</" + name + ">"); } + + private void endTagNoIndent() { + String name = tagStack.pop(); + indent--; + printWriter.println("</" + name + ">"); } + + void tag(String name, String... attrs) { + startTagPrim(name, attrs, true); } ! void tagData(String name, String data) { ! startTagPrim(name, null, false, false); ! printWriter.print(data); ! endTagNoIndent(); } ! void tagData(String name, String data, String... attrs) { ! startTagPrim(name, attrs, false, false); ! printWriter.print(data); ! endTagNoIndent(); ! } ! void tagV(String name, Vector attrs) { ! String s[] = new String[attrs.size()]; ! for (int i = 0; i < attrs.size(); i++) { ! s[i] = (String) attrs.elementAt(i); ! } ! startTagPrim(name, s, true); } ! void doIndent() { ! for (int i = 0; i < indent; i++) { ! printWriter.print(" "); ! } } }
< prev index next >