aboutsummaryrefslogtreecommitdiff
path: root/src/share/tools
diff options
context:
space:
mode:
authorneliasso <none@none>2012-03-29 16:43:21 +0200
committerneliasso <none@none>2012-03-29 16:43:21 +0200
commite82f1fd972374ee9a1d7f40f094b73e0ebaba938 (patch)
treea5f60b2eb7e9786e60c595dde63254113a6669b7 /src/share/tools
parentc90c1109b43bf3716869619a76117fbfd748e47d (diff)
downloadjdk8u_hotspot-e82f1fd972374ee9a1d7f40f094b73e0ebaba938.tar.gz
7163863: Updated projectcreator
Summary: Enable source browsing for all platform dependent code Reviewed-by: brutisso, coleenp
Diffstat (limited to 'src/share/tools')
-rw-r--r--src/share/tools/ProjectCreator/BuildConfig.java185
-rw-r--r--src/share/tools/ProjectCreator/DirectoryTree.java287
-rw-r--r--src/share/tools/ProjectCreator/DirectoryTreeNode.java36
-rw-r--r--src/share/tools/ProjectCreator/FileFormatException.java35
-rw-r--r--src/share/tools/ProjectCreator/FileTreeCreator.java72
-rw-r--r--src/share/tools/ProjectCreator/FileTreeCreatorVC10.java142
-rw-r--r--src/share/tools/ProjectCreator/FileTreeCreatorVC7.java156
-rw-r--r--src/share/tools/ProjectCreator/ProjectCreator.java135
-rw-r--r--src/share/tools/ProjectCreator/Util.java13
-rw-r--r--src/share/tools/ProjectCreator/WinGammaPlatform.java248
-rw-r--r--src/share/tools/ProjectCreator/WinGammaPlatformVC10.java273
-rw-r--r--src/share/tools/ProjectCreator/WinGammaPlatformVC6.java297
-rw-r--r--src/share/tools/ProjectCreator/WinGammaPlatformVC7.java1040
13 files changed, 977 insertions, 1942 deletions
diff --git a/src/share/tools/ProjectCreator/BuildConfig.java b/src/share/tools/ProjectCreator/BuildConfig.java
index 92fbf7746..00441dfb2 100644
--- a/src/share/tools/ProjectCreator/BuildConfig.java
+++ b/src/share/tools/ProjectCreator/BuildConfig.java
@@ -22,15 +22,14 @@
*
*/
-import java.io.File;
import java.util.Enumeration;
import java.util.Hashtable;
-import java.util.Iterator;
import java.util.Vector;
class BuildConfig {
+ @SuppressWarnings("rawtypes")
Hashtable vars;
- Vector basicNames, basicPaths;
+ Vector<String> basicNames, basicPaths;
String[] context;
static CompilerInterface ci;
@@ -47,6 +46,7 @@ class BuildConfig {
return ci;
}
+ @SuppressWarnings("rawtypes")
protected void initNames(String flavour, String build, String outDll) {
if (vars == null) vars = new Hashtable();
@@ -63,26 +63,28 @@ class BuildConfig {
// ones mentioned above were needed to expand format
String buildBase = expandFormat(getFieldString(null, "BuildBase"));
String sourceBase = getFieldString(null, "SourceBase");
+ String buildSpace = getFieldString(null, "BuildSpace");
String outDir = buildBase;
put("Id", flavourBuild);
put("OutputDir", outDir);
put("SourceBase", sourceBase);
put("BuildBase", buildBase);
+ put("BuildSpace", buildSpace);
put("OutputDll", outDir + Util.sep + outDll);
context = new String [] {flavourBuild, flavour, build, null};
}
- protected void init(Vector includes, Vector defines) {
+ protected void init(Vector<String> includes, Vector<String> defines) {
initDefaultDefines(defines);
initDefaultCompilerFlags(includes);
initDefaultLinkerFlags();
- handleDB();
+ //handleDB();
}
- protected void initDefaultCompilerFlags(Vector includes) {
+ protected void initDefaultCompilerFlags(Vector<String> includes) {
Vector compilerFlags = new Vector();
compilerFlags.addAll(getCI().getBaseCompilerFlags(getV("Define"),
@@ -100,143 +102,48 @@ class BuildConfig {
put("LinkerFlags", linkerFlags);
}
- DirectoryTree getSourceTree(String sourceBase, String startAt) {
- DirectoryTree tree = new DirectoryTree();
-
- tree.addSubdirToIgnore("Codemgr_wsdata");
- tree.addSubdirToIgnore("deleted_files");
- tree.addSubdirToIgnore("SCCS");
- tree.setVerbose(true);
- if (startAt != null) {
- tree.readDirectory(sourceBase + File.separator + startAt);
- } else {
- tree.readDirectory(sourceBase);
- }
-
- return tree;
- }
-
-
- Vector getPreferredPaths() {
- Vector preferredPaths = new Vector();
-
- // In the case of multiple files with the same name in
- // different subdirectories, prefer these versions
- preferredPaths.add("windows");
- preferredPaths.add("x86");
- preferredPaths.add("closed");
-
- // Also prefer "opto" over "adlc" for adlcVMDeps.hpp
- preferredPaths.add("opto");
-
- return preferredPaths;
- }
-
-
- void handleDB() {
- WinGammaPlatform platform = (WinGammaPlatform)getField(null, "PlatformObject");
-
- putSpecificField("AllFilesHash", computeAllFiles(platform));
- }
-
-
- private boolean matchesIgnoredPath(String prefixedName) {
- Vector rv = new Vector();
+ public boolean matchesIgnoredPath(String path) {
+ Vector<String> rv = new Vector<String>();
collectRelevantVectors(rv, "IgnorePath");
- for (Iterator i = rv.iterator(); i.hasNext(); ) {
- String pathPart = (String) i.next();
- if (prefixedName.contains(Util.normalize(pathPart))) {
+ for (String pathPart : rv) {
+ if (path.contains(pathPart)) {
return true;
}
}
return false;
}
- void addAll(Iterator i, Hashtable hash,
- WinGammaPlatform platform, DirectoryTree tree,
- Vector preferredPaths, Vector filesNotFound, Vector filesDuplicate) {
- for (; i.hasNext(); ) {
- String fileName = (String) i.next();
- if (lookupHashFieldInContext("IgnoreFile", fileName) == null) {
- String prefixedName = platform.envVarPrefixedFileName(fileName,
- 0, /* ignored */
- tree,
- preferredPaths,
- filesNotFound,
- filesDuplicate);
- if (prefixedName != null) {
- prefixedName = Util.normalize(prefixedName);
- if (!matchesIgnoredPath(prefixedName)) {
- addTo(hash, prefixedName, fileName);
- }
- }
+ public boolean matchesHidePath(String path) {
+ Vector<String> rv = new Vector<String>();
+ collectRelevantVectors(rv, "HidePath");
+ for (String pathPart : rv) {
+ if (path.contains(Util.normalize(pathPart))) {
+ return true;
}
}
+ return false;
}
- void addTo(Hashtable ht, String key, String value) {
- ht.put(expandFormat(key), expandFormat(value));
- }
-
- Hashtable computeAllFiles(WinGammaPlatform platform) {
- Hashtable rv = new Hashtable();
- DirectoryTree tree = getSourceTree(get("SourceBase"), getFieldString(null, "StartAt"));
- Vector preferredPaths = getPreferredPaths();
-
- // Hold errors until end
- Vector filesNotFound = new Vector();
- Vector filesDuplicate = new Vector();
+ public Vector<String> matchesAdditionalGeneratedPath(String fullPath) {
+ Vector<String> rv = new Vector<String>();
+ Hashtable<String, String> v = (Hashtable<String, String>)BuildConfig.getField(this.toString(), "AdditionalGeneratedFile");
+ if (v != null) {
+ for (Enumeration<String> e=v.keys(); e.hasMoreElements(); ) {
+ String key = e.nextElement();
+ String val = v.get(key);
- Vector includedFiles = new Vector();
-
- // find all files
- Vector dirs = getSourceIncludes();
- for (Iterator i = dirs.iterator(); i.hasNext(); ) {
- String dir = (String)i.next();
- DirectoryTree subtree = getSourceTree(dir, null);
- for (Iterator fi = subtree.getFileIterator(); fi.hasNext(); ) {
- String name = ((File)fi.next()).getName();
- includedFiles.add(name);
- }
- }
- addAll(includedFiles.iterator(), rv,
- platform, tree,
- preferredPaths, filesNotFound, filesDuplicate);
-
- Vector addFiles = new Vector();
- collectRelevantVectors(addFiles, "AdditionalFile");
- addAll(addFiles.iterator(), rv,
- platform, tree,
- preferredPaths, filesNotFound, filesDuplicate);
-
- collectRelevantHashes(rv, "AdditionalGeneratedFile");
-
- if ((filesNotFound.size() != 0) ||
- (filesDuplicate.size() != 0)) {
- System.err.println("Error: some files were not found or " +
- "appeared in multiple subdirectories of " +
- "directory " + get("SourceBase") + " and could not " +
- "be resolved with os_family and arch.");
- if (filesNotFound.size() != 0) {
- System.err.println("Files not found:");
- for (Iterator iter = filesNotFound.iterator();
- iter.hasNext(); ) {
- System.err.println(" " + (String) iter.next());
- }
- }
- if (filesDuplicate.size() != 0) {
- System.err.println("Duplicate files:");
- for (Iterator iter = filesDuplicate.iterator();
- iter.hasNext(); ) {
- System.err.println(" " + (String) iter.next());
+ if (fullPath.endsWith(expandFormat(key))) {
+ rv.add(expandFormat(val));
}
}
- throw new RuntimeException();
}
-
return rv;
}
+ void addTo(Hashtable ht, String key, String value) {
+ ht.put(expandFormat(key), expandFormat(value));
+ }
+
void initDefaultDefines(Vector defines) {
Vector sysDefines = new Vector();
sysDefines.add("WIN32");
@@ -324,20 +231,19 @@ class BuildConfig {
}
void collectRelevantVectors(Vector rv, String field) {
- for (int i = 0; i < context.length; i++) {
- Vector v = getFieldVector(context[i], field);
+ for (String ctx : context) {
+ Vector<String> v = getFieldVector(ctx, field);
if (v != null) {
- for (Iterator j=v.iterator(); j.hasNext(); ) {
- String val = (String)j.next();
- rv.add(expandFormat(val));
+ for (String val : v) {
+ rv.add(expandFormat(val).replace('/', '\\'));
}
}
}
}
void collectRelevantHashes(Hashtable rv, String field) {
- for (int i = 0; i < context.length; i++) {
- Hashtable v = (Hashtable)getField(context[i], field);
+ for (String ctx : context) {
+ Hashtable v = (Hashtable)getField(ctx, field);
if (v != null) {
for (Enumeration e=v.keys(); e.hasMoreElements(); ) {
String key = (String)e.nextElement();
@@ -357,21 +263,17 @@ class BuildConfig {
Vector getIncludes() {
Vector rv = new Vector();
-
collectRelevantVectors(rv, "AbsoluteInclude");
-
rv.addAll(getSourceIncludes());
-
return rv;
}
private Vector getSourceIncludes() {
- Vector rv = new Vector();
- Vector ri = new Vector();
+ Vector<String> rv = new Vector<String>();
+ Vector<String> ri = new Vector<String>();
String sourceBase = getFieldString(null, "SourceBase");
collectRelevantVectors(ri, "RelativeInclude");
- for (Iterator i = ri.iterator(); i.hasNext(); ) {
- String f = (String)i.next();
+ for (String f : ri) {
rv.add(sourceBase + Util.sep + f);
}
return rv;
@@ -604,7 +506,6 @@ class TieredFastDebugConfig extends GenericDebugNonKernelConfig {
}
}
-
abstract class ProductConfig extends BuildConfig {
protected void init(Vector includes, Vector defines) {
defines.add("NDEBUG");
@@ -638,7 +539,6 @@ class TieredProductConfig extends ProductConfig {
}
}
-
class CoreDebugConfig extends GenericDebugNonKernelConfig {
String getOptFlag() {
return getCI().getNoOptFlag();
@@ -650,7 +550,6 @@ class CoreDebugConfig extends GenericDebugNonKernelConfig {
}
}
-
class CoreFastDebugConfig extends GenericDebugNonKernelConfig {
String getOptFlag() {
return getCI().getOptFlag();
@@ -662,7 +561,6 @@ class CoreFastDebugConfig extends GenericDebugNonKernelConfig {
}
}
-
class CoreProductConfig extends ProductConfig {
CoreProductConfig() {
initNames("core", "product", "jvm.dll");
@@ -700,6 +598,7 @@ class KernelProductConfig extends ProductConfig {
init(getIncludes(), getDefines());
}
}
+
abstract class CompilerInterface {
abstract Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir);
abstract Vector getBaseLinkerFlags(String outDir, String outDll, String platformName);
diff --git a/src/share/tools/ProjectCreator/DirectoryTree.java b/src/share/tools/ProjectCreator/DirectoryTree.java
deleted file mode 100644
index 76a5e4668..000000000
--- a/src/share/tools/ProjectCreator/DirectoryTree.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-/** Encapsulates a notion of a directory tree. Designed to allow fast
- querying of full paths for unique filenames in the hierarchy. */
-
-import java.io.*;
-import java.util.*;
-
-public class DirectoryTree {
-
- /** The root of the read directoryTree */
- private Node rootNode;
-
- /** Subdirs to ignore; Vector of Strings */
- private Vector subdirsToIgnore;
-
- /** This maps file names to Lists of nodes. */
- private Hashtable nameToNodeListTable;
-
- /** Output "."'s as directories are read. Defaults to false. */
- private boolean verbose;
-
- public DirectoryTree() {
- subdirsToIgnore = new Vector();
- verbose = false;
- }
-
- public void addSubdirToIgnore(String subdir) {
- subdirsToIgnore.add(subdir);
- }
-
- private class FileIterator implements Iterator {
- private Vector nodes = new Vector();
-
- public FileIterator(Node rootNode) {
- if(rootNode == null) {
- return;
- }
- nodes.add(rootNode);
- prune();
- }
- public boolean hasNext() {
- return nodes.size() > 0;
- }
- public Object next() {
- Node last = (Node)nodes.remove(nodes.size() - 1);
- prune();
- return new File(last.getName());
- }
-
- public void remove() {
- throw new RuntimeException();
- }
-
- private void prune() {
- while (nodes.size() > 0) {
- Node last = (Node)nodes.get(nodes.size() - 1);
-
- if (last.isDirectory()) {
- nodes.remove(nodes.size() - 1);
- nodes.addAll(last.children);
- } else {
- // Is at file
- return;
- }
- }
- }
- }
-
- public Iterator getFileIterator() {
- return new FileIterator(rootNode);
- }
-
- /** Output "."'s to System.out as directories are read. Defaults
- to false. */
- public void setVerbose(boolean newValue) {
- verbose = newValue;
- }
-
- public boolean getVerbose() {
- return verbose;
- }
-
- public String getRootNodeName() {
- return rootNode.getName();
- }
-
- /** Takes an absolute path to the root directory of this
- DirectoryTree. Throws IllegalArgumentException if the given
- string represents a plain file or nonexistent directory. */
-
- public void readDirectory(String baseDirectory)
- throws IllegalArgumentException {
- File root = new File(Util.normalize(baseDirectory));
- if (!root.isDirectory()) {
- return;
- }
- try {
- root = root.getCanonicalFile();
- }
- catch (IOException e) {
- throw new RuntimeException(e.toString());
- }
- rootNode = new Node(root);
- readDirectory(rootNode, root);
- }
-
- /** Queries the DirectoryTree for a file or directory name. Takes
- only the name of the file or directory itself (i.e., no parent
- directory information should be in the passed name). Returns a
- List of DirectoryTreeNodes specifying the full paths of all of
- the files or directories of this name in the DirectoryTree.
- Returns null if the directory tree has not been read from disk
- yet or if the file was not found in the tree. */
- public List findFile(String name) {
- if (rootNode == null) {
- return null;
- }
-
- if (nameToNodeListTable == null) {
- nameToNodeListTable = new Hashtable();
- try {
- buildNameToNodeListTable(rootNode);
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
- }
-
- return (List) nameToNodeListTable.get(name);
- }
-
- private void buildNameToNodeListTable(Node curNode)
- throws IOException {
- String fullName = curNode.getName();
- String parent = curNode.getParent();
- String separator = System.getProperty("file.separator");
-
- if (parent != null) {
- if (!fullName.startsWith(parent)) {
- throw new RuntimeException(
- "Internal error: parent of file name \"" + fullName +
- "\" does not match file name \"" + parent + "\""
- );
- }
-
- int len = parent.length();
- if (!parent.endsWith(separator)) {
- len += separator.length();
- }
-
- String fileName = fullName.substring(len);
-
- if (fileName == null) {
- throw new RuntimeException(
- "Internal error: file name was empty"
- );
- }
-
- List nodeList = (List) nameToNodeListTable.get(fileName);
- if (nodeList == null) {
- nodeList = new Vector();
- nameToNodeListTable.put(fileName, nodeList);
- }
-
- nodeList.add(curNode);
- } else {
- if (curNode != rootNode) {
- throw new RuntimeException(
- "Internal error: parent of file + \"" + fullName + "\"" +
- " was null"
- );
- }
- }
-
- if (curNode.isDirectory()) {
- Iterator iter = curNode.getChildren();
- if (iter != null) {
- while (iter.hasNext()) {
- buildNameToNodeListTable((Node) iter.next());
- }
- }
- }
- }
-
- /** Reads all of the files in the given directory and adds them as
- children of the directory tree node. Requires that the passed
- node represents a directory. */
-
- private void readDirectory(Node parentNode, File parentDir) {
- File[] children = parentDir.listFiles();
- if (children == null)
- return;
- if (verbose) {
- System.out.print(".");
- System.out.flush();
- }
- for (int i = 0; i < children.length; i++) {
- File child = children[i];
- children[i] = null;
- boolean isDir = child.isDirectory();
- boolean mustSkip = false;
- if (isDir) {
- for (Iterator iter = subdirsToIgnore.iterator();
- iter.hasNext(); ) {
- if (child.getName().equals((String) iter.next())) {
- mustSkip = true;
- break;
- }
- }
- }
- if (!mustSkip) {
- Node childNode = new Node(child);
- parentNode.addChild(childNode);
- if (isDir) {
- readDirectory(childNode, child);
- }
- }
- }
- }
-
- private class Node implements DirectoryTreeNode {
- private File file;
- private Vector children;
-
- /** file must be a canonical file */
- Node(File file) {
- this.file = file;
- children = new Vector();
- }
-
- public boolean isFile() {
- return file.isFile();
- }
-
- public boolean isDirectory() {
- return file.isDirectory();
- }
-
- public String getName() {
- return file.getPath();
- }
-
- public String getParent() {
- return file.getParent();
- }
-
- public void addChild(Node n) {
- children.add(n);
- }
-
- public Iterator getChildren() throws IllegalArgumentException {
- return children.iterator();
- }
-
- public int getNumChildren() throws IllegalArgumentException {
- return children.size();
- }
-
- public DirectoryTreeNode getChild(int i)
- throws IllegalArgumentException, ArrayIndexOutOfBoundsException {
- return (DirectoryTreeNode) children.get(i);
- }
- }
-}
diff --git a/src/share/tools/ProjectCreator/DirectoryTreeNode.java b/src/share/tools/ProjectCreator/DirectoryTreeNode.java
deleted file mode 100644
index f198dc24b..000000000
--- a/src/share/tools/ProjectCreator/DirectoryTreeNode.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-import java.util.*;
-
-public interface DirectoryTreeNode {
- public boolean isFile();
- public boolean isDirectory();
- public String getName();
- public String getParent();
- public Iterator getChildren() throws IllegalArgumentException;
- public int getNumChildren() throws IllegalArgumentException;
- public DirectoryTreeNode getChild(int i)
- throws IllegalArgumentException, ArrayIndexOutOfBoundsException;
-}
diff --git a/src/share/tools/ProjectCreator/FileFormatException.java b/src/share/tools/ProjectCreator/FileFormatException.java
deleted file mode 100644
index 077886f85..000000000
--- a/src/share/tools/ProjectCreator/FileFormatException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 1999, 2011, 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-@SuppressWarnings("serial")
-public class FileFormatException extends Exception {
-
- public FileFormatException() {
- super();
- }
-
- public FileFormatException(String s) {
- super(s);
- }
-}
diff --git a/src/share/tools/ProjectCreator/FileTreeCreator.java b/src/share/tools/ProjectCreator/FileTreeCreator.java
new file mode 100644
index 000000000..3643c572e
--- /dev/null
+++ b/src/share/tools/ProjectCreator/FileTreeCreator.java
@@ -0,0 +1,72 @@
+import java.nio.file.FileSystems;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.util.HashSet;
+import java.util.Stack;
+import java.util.Vector;
+
+public class FileTreeCreator extends SimpleFileVisitor<Path>
+{
+ Path vcProjLocation;
+ Path startDir;
+ final int startDirLength;
+ Stack<DirAttributes> attributes = new Stack<DirAttributes>();
+ Vector<BuildConfig> allConfigs;
+ WinGammaPlatformVC10 wg;
+
+ public FileTreeCreator(Path startDir, Vector<BuildConfig> allConfigs, WinGammaPlatformVC10 wg) {
+ super();
+ this.wg = wg;
+ this.allConfigs = allConfigs;
+ this.startDir = startDir;
+ startDirLength = startDir.toAbsolutePath().toString().length();
+ vcProjLocation = FileSystems.getDefault().getPath(allConfigs.firstElement().get("BuildSpace"));
+ attributes.push(new DirAttributes());
+ }
+
+ public class DirAttributes {
+
+ private HashSet<BuildConfig> ignores;
+ private HashSet<BuildConfig> disablePch;
+
+ public DirAttributes() {
+ ignores = new HashSet<BuildConfig>();
+ disablePch = new HashSet<BuildConfig>();
+ }
+
+ public DirAttributes(HashSet<BuildConfig> excludes2, HashSet<BuildConfig> disablePch2) {
+ ignores = excludes2;
+ disablePch = disablePch2;
+ }
+
+ @SuppressWarnings("unchecked")
+ public DirAttributes clone() {
+ return new DirAttributes((HashSet<BuildConfig>)this.ignores.clone(), (HashSet<BuildConfig>)this.disablePch.clone());
+ }
+
+ public void setIgnore(BuildConfig conf) {
+ ignores.add(conf);
+ }
+
+ public boolean hasIgnore(BuildConfig cfg) {
+ return ignores.contains(cfg);
+ }
+
+ public void removeFromIgnored(BuildConfig cfg) {
+ ignores.remove(cfg);
+ }
+
+ public void setDisablePch(BuildConfig conf) {
+ disablePch.add(conf);
+ }
+
+ public boolean hasDisablePch(BuildConfig cfg) {
+ return disablePch.contains(cfg);
+ }
+
+ public void removeFromDisablePch(BuildConfig cfg) {
+ disablePch.remove(cfg);
+ }
+
+ }
+}
diff --git a/src/share/tools/ProjectCreator/FileTreeCreatorVC10.java b/src/share/tools/ProjectCreator/FileTreeCreatorVC10.java
new file mode 100644
index 000000000..837eef1a5
--- /dev/null
+++ b/src/share/tools/ProjectCreator/FileTreeCreatorVC10.java
@@ -0,0 +1,142 @@
+import static java.nio.file.FileVisitResult.CONTINUE;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.Stack;
+import java.util.Vector;
+
+public class FileTreeCreatorVC10 extends FileTreeCreator {
+
+ public FileTreeCreatorVC10(Path startDir, Vector<BuildConfig> allConfigs, WinGammaPlatformVC10 wg) {
+ super(startDir, allConfigs, wg);
+ }
+
+ @Override
+ public FileVisitResult visitFile(Path file, BasicFileAttributes attr) {
+ DirAttributes currentFileAttr = attributes.peek().clone();
+ boolean usePch = false;
+ boolean disablePch = false;
+ boolean useIgnore = false;
+ String fileName = file.getFileName().toString();
+
+ // TODO hideFile
+
+ // usePch applies to all configs for a file.
+ if (fileName.equals(BuildConfig.getFieldString(null, "UseToGeneratePch"))) {
+ usePch = true;
+ }
+
+ for (BuildConfig cfg : allConfigs) {
+ if (cfg.lookupHashFieldInContext("IgnoreFile", fileName) != null) {
+ useIgnore = true;
+ currentFileAttr.setIgnore(cfg);
+ } else if (cfg.matchesIgnoredPath(file.toAbsolutePath().toString())) {
+ useIgnore = true;
+ currentFileAttr.setIgnore(cfg);
+ }
+
+ if (cfg.lookupHashFieldInContext("DisablePch", fileName) != null) {
+ disablePch = true;
+ currentFileAttr.setDisablePch(cfg);
+ }
+
+ Vector<String> rv = new Vector<String>();
+ cfg.collectRelevantVectors(rv, "AdditionalFile");
+ for(String addFile : rv) {
+ if (addFile.equals(fileName)) {
+ // supress any ignore
+ // TODO - may need some adjustments
+ if (file.toAbsolutePath().toString().contains(cfg.get("Flavour"))) {
+ currentFileAttr.removeFromIgnored(cfg);
+ }
+ }
+ }
+ }
+
+ String tagName = wg.getFileTagFromSuffix(fileName);
+ String fileLoc = vcProjLocation.relativize(file).toString();
+
+ if (!useIgnore && !disablePch && !usePch) {
+ wg.tag(tagName, new String[] { "Include", fileLoc});
+ } else {
+ wg.startTag(
+ tagName,
+ new String[] { "Include", fileLoc});
+
+ for (BuildConfig cfg : allConfigs) {
+ boolean ignore = currentFileAttr.hasIgnore(cfg);
+ if (ignore) {
+ wg.tagData("ExcludedFromBuild", "true", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'");
+ }
+ if (usePch) {
+ wg.tagData("PrecompiledHeader", "Create", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'");
+ }
+ if (disablePch) {
+ wg.tag("PrecompiledHeader", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'");
+ }
+ }
+ wg.endTag();
+ }
+
+ String filter = startDir.relativize(file.getParent().toAbsolutePath()).toString();
+ wg.addFilterDependency(fileLoc, filter);
+
+ return CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs)
+ throws IOException {
+ Boolean hide = false;
+ // TODO remove attrs, if path is matched in this dir, then it is too in every subdir.
+ // And we will check anyway
+ DirAttributes newAttr = attributes.peek().clone();
+
+ // check per config ignorePaths!
+ for (BuildConfig cfg : allConfigs) {
+ if (cfg.matchesIgnoredPath(path.toAbsolutePath().toString())) {
+ newAttr.setIgnore(cfg);
+ }
+
+ // Hide is always on all configs. And additional files are never hiddden
+ if (cfg.matchesHidePath(path.toAbsolutePath().toString())) {
+ hide = true;
+ break;
+ }
+ }
+
+ if (!hide) {
+ String name = startDir.relativize(path.toAbsolutePath()).toString();
+ if (!"".equals(name)) {
+ wg.addFilter(name);
+ }
+
+ attributes.push(newAttr);
+ return super.preVisitDirectory(path, attrs);
+ } else {
+ return FileVisitResult.SKIP_SUBTREE;
+ }
+ }
+
+ @Override
+ public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
+ //end matching attributes set by ignorepath
+ attributes.pop();
+ return CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult visitFileFailed(Path file, IOException exc) {
+ return CONTINUE;
+ }
+
+ public void writeFileTree() throws IOException {
+ Files.walkFileTree(this.startDir, this);
+ }
+
+
+ } \ No newline at end of file
diff --git a/src/share/tools/ProjectCreator/FileTreeCreatorVC7.java b/src/share/tools/ProjectCreator/FileTreeCreatorVC7.java
new file mode 100644
index 000000000..b36e0121f
--- /dev/null
+++ b/src/share/tools/ProjectCreator/FileTreeCreatorVC7.java
@@ -0,0 +1,156 @@
+import static java.nio.file.FileVisitResult.CONTINUE;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.Stack;
+import java.util.Vector;
+
+public class FileTreeCreatorVC7 extends FileTreeCreator {
+
+ public FileTreeCreatorVC7(Path startDir, Vector<BuildConfig> allConfigs, WinGammaPlatform wg) {
+ super(startDir, allConfigs, null);
+ }
+
+ @Override
+ public FileVisitResult visitFile(Path file, BasicFileAttributes attr) {
+ DirAttributes currentFileAttr = attributes.peek().clone();
+ boolean usePch = false;
+ boolean disablePch = false;
+ boolean useIgnore = false;
+ String fileName = file.getFileName().toString();
+
+ // usePch applies to all configs for a file.
+ if (fileName.equals(BuildConfig.getFieldString(null, "UseToGeneratePch"))) {
+ usePch = true;
+ }
+
+ for (BuildConfig cfg : allConfigs) {
+ if (cfg.lookupHashFieldInContext("IgnoreFile", fileName) != null) {
+ useIgnore = true;
+ currentFileAttr.setIgnore(cfg);
+ } else if (cfg.matchesIgnoredPath(file.toAbsolutePath().toString())) {
+ useIgnore = true;
+ currentFileAttr.setIgnore(cfg);
+ }
+
+ if (cfg.lookupHashFieldInContext("DisablePch", fileName) != null) {
+ disablePch = true;
+ currentFileAttr.setDisablePch(cfg);
+ }
+
+ Vector<String> rv = new Vector<String>();
+ cfg.collectRelevantVectors(rv, "AdditionalFile");
+ for(String addFile : rv) {
+ if (addFile.equals(fileName)) {
+ // supress any ignore
+ currentFileAttr.removeFromIgnored(cfg);
+ }
+ }
+ }
+
+ if (!useIgnore && !disablePch && !usePch) {
+ wg.tag("File", new String[] { "RelativePath", vcProjLocation.relativize(file).toString()});
+ } else {
+ wg.startTag(
+ "File",
+ new String[] { "RelativePath", vcProjLocation.relativize(file).toString()});
+
+ for (BuildConfig cfg : allConfigs) {
+ boolean ignore = currentFileAttr.hasIgnore(cfg);
+ String [] fileConfAttr;
+
+ if (ignore) {
+ fileConfAttr = new String[] {"Name", cfg.get("Name"), "ExcludedFromBuild", "TRUE" };
+ } else {
+ fileConfAttr = new String[] {"Name", cfg.get("Name")};
+ }
+
+ if (!disablePch && !usePch && !ignore) {
+ continue;
+ } else if (!disablePch && !usePch) {
+ wg.tag("FileConfiguration", fileConfAttr);
+ } else {
+ wg.startTag("FileConfiguration", fileConfAttr);
+ if (usePch) {
+ // usePch always applies to all configs, might not always be so.
+ wg.tag("Tool", new String[] {
+ "Name", "VCCLCompilerTool", "UsePrecompiledHeader",
+ "1" });
+ assert(!disablePch);
+ }
+ if (disablePch) {
+ if (currentFileAttr.hasDisablePch(cfg)) {
+ wg.tag("Tool", new String[] {
+ "Name", "VCCLCompilerTool", "UsePrecompiledHeader",
+ "0" });
+ }
+ assert(!usePch);
+ }
+ wg.endTag();
+ }
+ }
+ wg.endTag();
+ }
+
+ return CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs)
+ throws IOException {
+ Boolean hide = false;
+ DirAttributes newAttr = attributes.peek().clone();
+
+ String rPath;
+ if (path.toAbsolutePath().toString().equals(this.startDir.toAbsolutePath().toString())){
+ rPath = startDir.toString();
+ } else {
+ rPath = path.getFileName().toString();
+ }
+
+ // check per config ignorePaths!
+ for (BuildConfig cfg : allConfigs) {
+ if (cfg.matchesIgnoredPath(path.toAbsolutePath().toString())) {
+ newAttr.setIgnore(cfg);
+ }
+
+ // Hide is always on all configs. And additional files are never hiddden
+ if (cfg.matchesHidePath(path.toAbsolutePath().toString())) {
+ hide = true;
+ break;
+ }
+ }
+
+ if (!hide) {
+ wg.startTag("Filter", new String[] {
+ "Name", rPath});
+
+ attributes.push(newAttr);
+ return super.preVisitDirectory(path, attrs);
+ } else {
+ return FileVisitResult.SKIP_SUBTREE;
+ }
+ }
+
+ @Override
+ public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
+ //end matching attributes set by ignorepath
+ wg.endTag();
+ attributes.pop();
+
+ return CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult visitFileFailed(Path file, IOException exc) {
+ return CONTINUE;
+ }
+
+ public void writeFileTree() throws IOException {
+ Files.walkFileTree(this.startDir, this);
+ }
+ } \ No newline at end of file
diff --git a/src/share/tools/ProjectCreator/ProjectCreator.java b/src/share/tools/ProjectCreator/ProjectCreator.java
index 5203c5a36..93a7b1dca 100644
--- a/src/share/tools/ProjectCreator/ProjectCreator.java
+++ b/src/share/tools/ProjectCreator/ProjectCreator.java
@@ -24,75 +24,76 @@
public class ProjectCreator {
- public static void usage() {
- System.out.println("ProjectCreator options:");
- System.err.println("WinGammaPlatform platform-specific options:");
- System.err.println(" -sourceBase <path to directory (workspace) " +
- "containing source files; no trailing slash>");
- System.err.println(" -dspFileName <full pathname to which .dsp file " +
- "will be written; all parent directories must " +
- "already exist>");
- System.err.println(" -envVar <environment variable to be inserted " +
- "into .dsp file, substituting for path given in " +
- "-sourceBase. Example: HotSpotWorkSpace>");
- System.err.println(" -dllLoc <path to directory in which to put " +
- "jvm.dll and jvm_g.dll; no trailing slash>");
- System.err.println(" If any of the above are specified, "+
- "they must all be.");
- 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(" -relativeInclude <string containing include " +
- "directory relative to -envVar>");
- System.err.println(" -define <preprocessor flag to be #defined " +
- "(note: doesn't yet support " +
- "#define (flag) (value))>");
- System.err.println(" -perFileLine <file> <line>");
- System.err.println(" -conditionalPerFileLine <file> <line for " +
- "release build> <line for debug build>");
- System.err.println(" (NOTE: To work around a bug in nmake, where " +
- "you can't have a '#' character in a quoted " +
- "string, all of the lines outputted have \"#\"" +
- "prepended)");
- System.err.println(" -startAt <subdir of sourceBase>");
- System.err.println(" -ignoreFile <file which won't be able to be " +
- "found in the sourceBase because it's generated " +
- "later>");
- System.err.println(" -additionalFile <file not in database but " +
- "which should show up in .dsp file>");
- System.err.println(" -additionalGeneratedFile <environment variable of " +
- "generated file's location> <relative path to " +
- "directory containing file; no trailing slash> " +
- "<name of file generated later in the build process>");
- System.err.println(" -prelink <build> <desc> <cmds>:");
- System.err.println(" Generate a set of prelink commands for the given BUILD");
- System.err.println(" (\"Debug\" or \"Release\"). The prelink description and commands");
- System.err.println(" are both quoted strings.");
- System.err.println(" Default includes: \".\"");
- System.err.println(" Default defines: WIN32, _WINDOWS, \"HOTSPOT_BUILD_USER=$(USERNAME)\"");
- }
+ public static void usage() {
+ System.out.println("ProjectCreator options:");
+ System.err.println("WinGammaPlatform platform-specific options:");
+ System.err.println(" -sourceBase <path to directory (workspace) "
+ + "containing source files; no trailing slash>");
+ System.err.println(" -dspFileName <full pathname to which .dsp file "
+ + "will be written; all parent directories must "
+ + "already exist>");
+ System.err.println(" -envVar <environment variable to be inserted "
+ + "into .dsp file, substituting for path given in "
+ + "-sourceBase. Example: HotSpotWorkSpace>");
+ System.err.println(" -dllLoc <path to directory in which to put "
+ + "jvm.dll and jvm_g.dll; no trailing slash>");
+ System.err.println(" If any of the above are specified, "
+ + "they must all be.");
+ 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(" -relativeInclude <string containing include "
+ + "directory relative to -envVar>");
+ System.err.println(" -define <preprocessor flag to be #defined "
+ + "(note: doesn't yet support " + "#define (flag) (value))>");
+ System.err.println(" -perFileLine <file> <line>");
+ System.err.println(" -conditionalPerFileLine <file> <line for "
+ + "release build> <line for debug build>");
+ System.err.println(" (NOTE: To work around a bug in nmake, where "
+ + "you can't have a '#' character in a quoted "
+ + "string, all of the lines outputted have \"#\"" + "prepended)");
+ System.err.println(" -startAt <subdir of sourceBase>");
+ System.err.println(" -ignoreFile <file which won't be able to be "
+ + "found in the sourceBase because it's generated " + "later>");
+ System.err.println(" -additionalFile <file not in database but "
+ + "which should show up in .dsp file>");
+ System.err
+ .println(" -additionalGeneratedFile <environment variable of "
+ + "generated file's location> <relative path to "
+ + "directory containing file; no trailing slash> "
+ + "<name of file generated later in the build process>");
+ System.err.println(" -prelink <build> <desc> <cmds>:");
+ System.err
+ .println(" Generate a set of prelink commands for the given BUILD");
+ System.err
+ .println(" (\"Debug\" or \"Release\"). The prelink description and commands");
+ System.err.println(" are both quoted strings.");
+ System.err.println(" Default includes: \".\"");
+ System.err
+ .println(" Default defines: WIN32, _WINDOWS, \"HOTSPOT_BUILD_USER=$(USERNAME)\"");
+ }
- public static void main(String[] args) {
- try {
- if (args.length < 3) {
- usage();
- System.exit(1);
- }
+ public static void main(String[] args) {
+ try {
+ if (args.length < 3) {
+ usage();
+ System.exit(1);
+ }
- String platformName = args[0];
- Class platformClass = Class.forName(platformName);
- WinGammaPlatform platform = (WinGammaPlatform) platformClass.newInstance();
+ String platformName = args[0];
+ Class platformClass = Class.forName(platformName);
+ WinGammaPlatform platform = (WinGammaPlatform) platformClass
+ .newInstance();
- String[] platformArgs = new String[args.length - 1];
- System.arraycopy(args, 1, platformArgs, 0, platformArgs.length);
+ String[] platformArgs = new String[args.length - 1];
+ System.arraycopy(args, 1, platformArgs, 0, platformArgs.length);
- // Allow the platform to write platform-specific files
- platform.createVcproj(platformArgs);
- }
- catch (Exception e) {
- e.printStackTrace();
- System.exit(1);
- }
- }
+ // Allow the platform to write platform-specific files
+ platform.createVcproj(platformArgs);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
}
diff --git a/src/share/tools/ProjectCreator/Util.java b/src/share/tools/ProjectCreator/Util.java
index 466a09974..b8fe156e7 100644
--- a/src/share/tools/ProjectCreator/Util.java
+++ b/src/share/tools/ProjectCreator/Util.java
@@ -26,18 +26,19 @@ import java.util.*;
import java.io.File;
public class Util {
- static String join(String padder, Vector v) {
+
+ static String join(String padder, Vector<String> v) {
return join(padder, v, false);
}
- static String join(String padder, Vector v, boolean quoted) {
+ static String join(String padder, Vector<String> v, boolean quoted) {
StringBuffer sb = new StringBuffer();
- for (Iterator iter = v.iterator(); iter.hasNext(); ) {
+ for (Iterator<String> iter = v.iterator(); iter.hasNext(); ) {
if (quoted) {
sb.append('"');
}
- sb.append((String)iter.next());
+ sb.append(iter.next());
if (quoted) {
sb.append('"');
}
@@ -48,10 +49,10 @@ public class Util {
}
- static String prefixed_join(String padder, Vector v, boolean quoted) {
+ static String prefixed_join(String padder, Vector<String> v, boolean quoted) {
StringBuffer sb = new StringBuffer();
- for (Iterator iter = v.iterator(); iter.hasNext(); ) {
+ for (Iterator<String> iter = v.iterator(); iter.hasNext(); ) {
sb.append(padder);
if (quoted) {
diff --git a/src/share/tools/ProjectCreator/WinGammaPlatform.java b/src/share/tools/ProjectCreator/WinGammaPlatform.java
index 7c4dc53e2..41deb5238 100644
--- a/src/share/tools/ProjectCreator/WinGammaPlatform.java
+++ b/src/share/tools/ProjectCreator/WinGammaPlatform.java
@@ -29,6 +29,7 @@ import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
+import java.util.Stack;
import java.util.TreeSet;
import java.util.Vector;
@@ -218,69 +219,6 @@ public abstract class WinGammaPlatform {
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) {
- // 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();
@@ -369,6 +307,12 @@ public abstract class WinGammaPlatform {
HsArgHandler.STRING
),
+ new HsArgRule("-buildSpace",
+ "BuildSpace",
+ null,
+ HsArgHandler.STRING
+ ),
+
new HsArgRule("-platformName",
"PlatformName",
null,
@@ -405,6 +349,18 @@ public abstract class WinGammaPlatform {
HsArgHandler.VECTOR
),
+ new HsArgRule("-absoluteSrcInclude",
+ "AbsoluteSrcInclude",
+ null,
+ HsArgHandler.VECTOR
+ ),
+
+ new HsArgRule("-relativeSrcInclude",
+ "RelativeSrcInclude",
+ null,
+ HsArgHandler.VECTOR
+ ),
+
new HsArgRule("-define",
"Define",
null,
@@ -494,6 +450,12 @@ public abstract class WinGammaPlatform {
HsArgHandler.VECTOR
),
+ new HsArgRule("-hidePath",
+ "HidePath",
+ null,
+ HsArgHandler.VECTOR
+ ),
+
new HsArgRule("-additionalFile",
"AdditionalFile",
null,
@@ -611,107 +573,101 @@ public abstract class WinGammaPlatform {
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);
+ PrintWriter printWriter;
- // if presented in all configs
- if (configs.size() == numConfigs) {
- configs = null;
- }
- }
+ public void writeProjectFile(String projectFileName, String projectName,
+ Vector<BuildConfig> allConfigs) throws IOException {
+ throw new RuntimeException("use compiler version specific version");
}
- 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;
- return full.compareTo(oo.full);
- }
-
- boolean isHeader() {
- return attr.shortName.endsWith(".h") || attr.shortName.endsWith(".hpp");
- }
+ int indent;
+ private Stack<String> tagStack = new Stack<String>();
- boolean isCpp() {
- return attr.shortName.endsWith(".cpp");
- }
+ 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();
+ }
+ }
- 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;
+ void startTag(String name, String... attrs) {
+ startTagPrim(name, attrs, false);
}
- Hashtable computeAttributedFiles(Vector allConfigs) {
- Hashtable ht = new Hashtable();
- int numConfigs = allConfigs.size();
+ 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);
+ }
- for (Iterator i = allConfigs.iterator(); i.hasNext(); ) {
- BuildConfig bc = (BuildConfig)i.next();
- Hashtable confFiles = (Hashtable)bc.getSpecificField("AllFilesHash");
- String confName = bc.get("Name");
+ void endTag() {
+ String name = tagStack.pop();
+ indent--;
+ doIndent();
+ printWriter.println("</" + name + ">");
+ }
- for (Enumeration e=confFiles.keys(); e.hasMoreElements(); ) {
- String filePath = (String)e.nextElement();
- FileAttribute fa = (FileAttribute)ht.get(filePath);
+ private void endTagNoIndent() {
+ String name = tagStack.pop();
+ indent--;
+ printWriter.println("</" + name + ">");
+ }
- if (fa == null) {
- fa = new FileAttribute((String)confFiles.get(filePath), bc, numConfigs);
- ht.put(filePath, fa);
- } else {
- fa.add(confName);
- }
- }
- }
+ void tag(String name, String... attrs) {
+ startTagPrim(name, attrs, true);
+ }
- return ht;
+ void tagData(String name, String data) {
+ startTagPrim(name, null, false, false);
+ printWriter.print(data);
+ endTagNoIndent();
}
- Hashtable computeAttributedFiles(BuildConfig bc) {
- Hashtable ht = new Hashtable();
- Hashtable confFiles = (Hashtable)bc.getSpecificField("AllFilesHash");
+ void tagData(String name, String data, String... attrs) {
+ startTagPrim(name, attrs, false, false);
+ printWriter.print(data);
+ endTagNoIndent();
+ }
- for (Enumeration e = confFiles.keys(); e.hasMoreElements(); ) {
- String filePath = (String)e.nextElement();
- ht.put(filePath, new FileAttribute((String)confFiles.get(filePath), bc, 1));
- }
+ 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);
+ }
- return ht;
+ void doIndent() {
+ for (int i = 0; i < indent; i++) {
+ printWriter.print(" ");
+ }
}
- PrintWriter printWriter;
- public void writeProjectFile(String projectFileName, String projectName,
- Vector<BuildConfig> allConfigs) throws IOException {
- throw new RuntimeException("use compiler version specific version");
- }
}
diff --git a/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java b/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java
index 4a96981e7..137abdc30 100644
--- a/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java
+++ b/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java
@@ -3,14 +3,18 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
-import java.util.Hashtable;
+import java.nio.file.FileSystems;
import java.util.Iterator;
-import java.util.TreeSet;
+import java.util.LinkedList;
import java.util.UUID;
import java.util.Vector;
public class WinGammaPlatformVC10 extends WinGammaPlatformVC7 {
+
+ LinkedList <String>filters = new LinkedList<String>();
+ LinkedList <String[]>filterDeps = new LinkedList<String[]>();
+
@Override
protected String getProjectExt() {
return ".vcxproj";
@@ -37,15 +41,15 @@ public class WinGammaPlatformVC10 extends WinGammaPlatformVC7 {
"Include", cfg.get("Name"));
tagData("Configuration", cfg.get("Id"));
tagData("Platform", cfg.get("PlatformName"));
- endTag("ProjectConfiguration");
+ endTag();
}
- endTag("ItemGroup");
+ endTag();
startTag("PropertyGroup", "Label", "Globals");
tagData("ProjectGuid", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}");
tag("SccProjectName");
tag("SccLocalPath");
- endTag("PropertyGroup");
+ endTag();
tag("Import", "Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props");
@@ -53,19 +57,19 @@ public class WinGammaPlatformVC10 extends WinGammaPlatformVC7 {
startTag(cfg, "PropertyGroup", "Label", "Configuration");
tagData("ConfigurationType", "DynamicLibrary");
tagData("UseOfMfc", "false");
- endTag("PropertyGroup");
+ endTag();
}
tag("Import", "Project", "$(VCTargetsPath)\\Microsoft.Cpp.props");
startTag("ImportGroup", "Label", "ExtensionSettings");
- endTag("ImportGroup");
+ endTag();
for (BuildConfig cfg : allConfigs) {
startTag(cfg, "ImportGroup", "Label", "PropertySheets");
tag("Import",
"Project", "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props",
"Condition", "exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')",
"Label", "LocalAppDataPlatform");
- endTag("ImportGroup");
+ endTag();
}
tag("PropertyGroup", "Label", "UserMacros");
@@ -82,38 +86,38 @@ public class WinGammaPlatformVC10 extends WinGammaPlatformVC7 {
tag(cfg, "CodeAnalysisRules");
tag(cfg, "CodeAnalysisRuleAssemblies");
}
- endTag("PropertyGroup");
+ endTag();
for (BuildConfig cfg : allConfigs) {
startTag(cfg, "ItemDefinitionGroup");
startTag("ClCompile");
tagV(cfg.getV("CompilerFlags"));
- endTag("ClCompile");
+ endTag();
startTag("Link");
tagV(cfg.getV("LinkerFlags"));
- endTag("Link");
+ endTag();
startTag("PostBuildEvent");
tagData("Message", BuildConfig.getFieldString(null, "PostbuildDescription"));
tagData("Command", cfg.expandFormat(BuildConfig.getFieldString(null, "PostbuildCommand").replace("\t", "\r\n")));
- endTag("PostBuildEvent");
+ endTag();
startTag("PreLinkEvent");
tagData("Message", BuildConfig.getFieldString(null, "PrelinkDescription"));
tagData("Command", cfg.expandFormat(BuildConfig.getFieldString(null, "PrelinkCommand").replace("\t", "\r\n")));
- endTag("PreLinkEvent");
+ endTag();
- endTag("ItemDefinitionGroup");
+ endTag();
}
writeFiles(allConfigs, projDir);
tag("Import", "Project", "$(VCTargetsPath)\\Microsoft.Cpp.targets");
startTag("ImportGroup", "Label", "ExtensionTargets");
- endTag("ImportGroup");
+ endTag();
- endTag("Project");
+ endTag();
printWriter.close();
System.out.println(" Done.");
@@ -138,14 +142,22 @@ public class WinGammaPlatformVC10 extends WinGammaPlatformVC7 {
for (BuildConfig cfg : allConfigs) {
startTag(cfg, "PropertyGroup");
tagData("LocalDebuggerCommand", "$(TargetDir)/hotspot.exe");
- endTag("PropertyGroup");
+ endTag();
}
- endTag("Project");
+ endTag();
printWriter.close();
System.out.println(" Done.");
}
+ public void addFilter(String rPath) {
+ filters.add(rPath);
+ }
+
+ public void addFilterDependency(String fileLoc, String filter) {
+ filterDeps.add(new String[] {fileLoc, filter});
+ }
+
private void writeFilterFile(String projectFileName, String projectName,
Vector<BuildConfig> allConfigs, String base) throws FileNotFoundException, UnsupportedEncodingException {
String filterFileName = projectFileName + ".filters";
@@ -157,210 +169,92 @@ public class WinGammaPlatformVC10 extends WinGammaPlatformVC7 {
"ToolsVersion", "4.0",
"xmlns", "http://schemas.microsoft.com/developer/msbuild/2003");
- Hashtable<String, FileAttribute> allFiles = computeAttributedFiles(allConfigs);
- TreeSet<FileInfo> sortedFiles = sortFiles(allFiles);
- Vector<NameFilter> filters = makeFilters(sortedFiles);
-
- // first all filters
startTag("ItemGroup");
- for (NameFilter filter : filters) {
- doWriteFilter(filter, "");
+ for (String filter : filters) {
+ startTag("Filter", "Include",filter);
+ UUID uuid = UUID.randomUUID();
+ tagData("UniqueIdentifier", "{" + uuid.toString() + "}");
+ endTag();
}
startTag("Filter", "Include", "Resource Files");
UUID uuid = UUID.randomUUID();
tagData("UniqueIdentifier", "{" + uuid.toString() + "}");
tagData("Extensions", "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe");
- endTag("Filter");
- endTag("ItemGroup");
+ endTag();
+ endTag();
- // then all cpp files
- startTag("ItemGroup");
- for (NameFilter filter : filters) {
- doWriteFiles(sortedFiles, filter, "", "ClCompile", new Evaluator() {
- public boolean pick(FileInfo fi) {
- return fi.isCpp();
- }
- }, base);
- }
- endTag("ItemGroup");
+ //TODO - do I need to split cpp and hpp files?
- // then all header files
+ // then all files
startTag("ItemGroup");
- for (NameFilter filter : filters) {
- doWriteFiles(sortedFiles, filter, "", "ClInclude", new Evaluator() {
- public boolean pick(FileInfo fi) {
- return fi.isHeader();
- }
- }, base);
- }
- endTag("ItemGroup");
+ for (String[] dep : filterDeps) {
+ String tagName = getFileTagFromSuffix(dep[0]);
- // then all other files
- startTag("ItemGroup");
- for (NameFilter filter : filters) {
- doWriteFiles(sortedFiles, filter, "", "None", new Evaluator() {
- public boolean pick(FileInfo fi) {
- return true;
- }
- }, base);
+ startTag(tagName, "Include", dep[0]);
+ tagData("Filter", dep[1]);
+ endTag();
}
- endTag("ItemGroup");
+ endTag();
- endTag("Project");
+ endTag();
printWriter.close();
System.out.println(" Done.");
}
-
- private void doWriteFilter(NameFilter filter, String start) {
- startTag("Filter", "Include", start + filter.fname);
- UUID uuid = UUID.randomUUID();
- tagData("UniqueIdentifier", "{" + uuid.toString() + "}");
- endTag("Filter");
- if (filter instanceof ContainerFilter) {
- Iterator i = ((ContainerFilter)filter).babies();
- while (i.hasNext()) {
- doWriteFilter((NameFilter)i.next(), start + filter.fname + "\\");
- }
- }
+ public String getFileTagFromSuffix(String fileName) {
+ if (fileName.endsWith(".cpp")) {
+ return"ClCompile";
+ } else if (fileName.endsWith(".c")) {
+ return "ClCompile";
+ } else if (fileName.endsWith(".hpp")) {
+ return"ClInclude";
+ } else if (fileName.endsWith(".h")) {
+ return "ClInclude";
+ } else {
+ return"None";
+ }
}
- interface Evaluator {
- boolean pick(FileInfo fi);
- }
-
- private void doWriteFiles(TreeSet<FileInfo> allFiles, NameFilter filter, String start, String tool, Evaluator eval, String base) {
- if (filter instanceof ContainerFilter) {
- Iterator i = ((ContainerFilter)filter).babies();
- while (i.hasNext()) {
- doWriteFiles(allFiles, (NameFilter)i.next(), start + filter.fname + "\\", tool, eval, base);
- }
- }
- else {
- Iterator i = allFiles.iterator();
- while (i.hasNext()) {
- FileInfo fi = (FileInfo)i.next();
-
- if (!filter.match(fi)) {
- continue;
- }
- if (eval.pick(fi)) {
- startTag(tool, "Include", rel(fi.full, base));
- tagData("Filter", start + filter.fname);
- endTag(tool);
-
- // we not gonna look at this file anymore (sic!)
- i.remove();
- }
- }
- }
- }
-
-
void writeFiles(Vector<BuildConfig> allConfigs, String projDir) {
- Hashtable<String, FileAttribute> allFiles = computeAttributedFiles(allConfigs);
- TreeSet<FileInfo> sortedFiles = sortFiles(allFiles);
+ // This code assummes there are no config specific includes.
+ startTag("ItemGroup");
- // first cpp-files
- startTag("ItemGroup");
- for (FileInfo fi : sortedFiles) {
- if (!fi.isCpp()) {
- continue;
- }
- writeFile("ClCompile", allConfigs, fi, projDir);
- }
- endTag("ItemGroup");
+ String sourceBase = BuildConfig.getFieldString(null, "SourceBase");
- // then header-files
- startTag("ItemGroup");
- for (FileInfo fi : sortedFiles) {
- if (!fi.isHeader()) {
- continue;
- }
- writeFile("ClInclude", allConfigs, fi, projDir);
- }
- endTag("ItemGroup");
+ // Use first config for all global absolute includes.
+ BuildConfig baseConfig = allConfigs.firstElement();
+ Vector<String> rv = new Vector<String>();
- // then others
- startTag("ItemGroup");
- for (FileInfo fi : sortedFiles) {
- if (fi.isHeader() || fi.isCpp()) {
- continue;
- }
- writeFile("None", allConfigs, fi, projDir);
- }
- endTag("ItemGroup");
- }
+ // Then use first config for all relative includes
+ Vector<String> ri = new Vector<String>();
+ baseConfig.collectRelevantVectors(ri, "RelativeSrcInclude");
+ for (String f : ri) {
+ rv.add(sourceBase + Util.sep + f);
+ }
- /**
- * Make "path" into a relative path using "base" as the base.
- *
- * path and base are assumed to be normalized with / as the file separator.
- * returned path uses "\\" as file separator
- */
- private String rel(String path, String base)
- {
- if(!base.endsWith("/")) {
- base += "/";
- }
- String[] pathTok = path.split("/");
- String[] baseTok = base.split("/");
- int pi = 0;
- int bi = 0;
- StringBuilder newPath = new StringBuilder();
-
- // first step past all path components that are the same
- while (pi < pathTok.length &&
- bi < baseTok.length &&
- pathTok[pi].equals(baseTok[bi])) {
- pi++;
- bi++;
- }
+ baseConfig.collectRelevantVectors(rv, "AbsoluteSrcInclude");
- // for each path component left in base, add "../"
- while (bi < baseTok.length) {
- bi++;
- newPath.append("..\\");
- }
+ handleIncludes(rv, allConfigs);
- // now add everything left in path
- while (pi < pathTok.length) {
- newPath.append(pathTok[pi]);
- pi++;
- if (pi != pathTok.length) {
- newPath.append("\\");
- }
- }
- return newPath.toString();
+ endTag();
}
- private void writeFile(String tool, Vector<BuildConfig> allConfigs, FileInfo fi, String base) {
- if (fi.attr.configs == null && fi.attr.pchRoot == false && fi.attr.noPch == false) {
- tag(tool, "Include", rel(fi.full, base));
- }
- else {
- startTag(tool, "Include", rel(fi.full, base));
- for (BuildConfig cfg : allConfigs) {
- if (fi.attr.configs != null && !fi.attr.configs.contains(cfg.get("Name"))) {
- tagData(cfg, "ExcludedFromBuild", "true");
- }
- if (fi.attr.pchRoot) {
- tagData(cfg, "PrecompiledHeader", "Create");
- }
- if (fi.attr.noPch) {
- startTag(cfg, "PrecompiledHeader");
- endTag("PrecompiledHeader");
- }
- }
- endTag(tool);
- }
+ // Will visit file tree for each include
+ private void handleIncludes(Vector<String> includes, Vector<BuildConfig> allConfigs) {
+ for (String path : includes) {
+ FileTreeCreatorVC10 ftc = new FileTreeCreatorVC10(FileSystems.getDefault().getPath(path) , allConfigs, this);
+ try {
+ ftc.writeFileTree();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
}
String buildCond(BuildConfig cfg) {
return "'$(Configuration)|$(Platform)'=='"+cfg.get("Name")+"'";
}
-
void tagV(Vector<String> v) {
Iterator<String> i = v.iterator();
while(i.hasNext()) {
@@ -391,6 +285,7 @@ public class WinGammaPlatformVC10 extends WinGammaPlatformVC7 {
startTag(name, ss);
}
+
}
class CompilerInterfaceVC10 extends CompilerInterface {
diff --git a/src/share/tools/ProjectCreator/WinGammaPlatformVC6.java b/src/share/tools/ProjectCreator/WinGammaPlatformVC6.java
deleted file mode 100644
index f29abc051..000000000
--- a/src/share/tools/ProjectCreator/WinGammaPlatformVC6.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- * Copyright (c) 2005, 2011, 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-
-import java.io.*;
-import java.util.*;
-
-public class WinGammaPlatformVC6 extends WinGammaPlatform {
- public void writeProjectFile(String projectFileName, String projectName,
- Vector allConfigs) throws IOException {
- Vector allConfigNames = new Vector();
-
- printWriter = new PrintWriter(new FileWriter(projectFileName));
- String cfg = ((BuildConfig)allConfigs.get(0)).get("Name");
-
- printWriter.println("# Microsoft Developer Studio Project File - Name=\"" + projectName + "\" - Package Owner=<4>");
- printWriter.println("# Microsoft Developer Studio Generated Build File, Format Version 6.00");
- printWriter.println("# ** DO NOT EDIT **");
- printWriter.println("");
- printWriter.println("# TARGTYPE \"Win32 (x86) Dynamic-Link Library\" 0x0102");
- printWriter.println("CFG=" + cfg);
- printWriter.println("");
-
- printWriter.println("!MESSAGE This is not a valid makefile. To build this project using NMAKE,");
- printWriter.println("!MESSAGE use the Export Makefile command and run");
- printWriter.println("!MESSAGE ");
- printWriter.println("!MESSAGE NMAKE /f \"" + projectName + ".mak\".");
- printWriter.println("!MESSAGE ");
- printWriter.println("!MESSAGE You can specify a configuration when running NMAKE");
- printWriter.println("!MESSAGE by defining the macro CFG on the command line. For example:");
- printWriter.println("!MESSAGE ");
- printWriter.println("!MESSAGE NMAKE /f \"" + projectName + ".mak\" CFG=\"" + cfg + "\"");
- printWriter.println("!MESSAGE ");
- printWriter.println("!MESSAGE Possible choices for configuration are:");
- printWriter.println("!MESSAGE ");
- for (Iterator i = allConfigs.iterator(); i.hasNext(); ) {
- String name = ((BuildConfig)i.next()).get("Name");
- printWriter.println("!MESSAGE \""+ name + "\" (based on \"Win32 (x86) Dynamic-Link Library\")");
- allConfigNames.add(name);
- }
- printWriter.println("!MESSAGE ");
- printWriter.println("");
-
- printWriter.println("# Begin Project");
- printWriter.println("# PROP AllowPerConfigDependencies 0");
- printWriter.println("# PROP Scc_ProjName \"\"");
- printWriter.println("# PROP Scc_LocalPath \"\"");
- printWriter.println("CPP=cl.exe");
- printWriter.println("MTL=midl.exe");
- printWriter.println("RSC=rc.exe");
-
-
- String keyword = "!IF";
- for (Iterator i = allConfigs.iterator(); i.hasNext(); ) {
- BuildConfig bcfg = (BuildConfig)i.next();
- printWriter.println(keyword + " \"$(CFG)\" == \"" + bcfg.get("Name") + "\"");
- writeConfigHeader(bcfg);
- keyword = "!ELSEIF";
- if (!i.hasNext()) printWriter.println("!ENDIF");
- }
-
-
- TreeSet sortedFiles = sortFiles(computeAttributedFiles(allConfigs));
-
- printWriter.println("# Begin Target");
-
- for (Iterator i = allConfigs.iterator(); i.hasNext(); ) {
- printWriter.println("# Name \"" + ((BuildConfig)i.next()).get("Name") + "\"");
- }
- printWriter.println("# Begin Group \"Header Files\"");
- printWriter.println("# PROP Default_Filter \"h;hpp;hxx;hm;inl;fi;fd\"");
-
- Iterator i = sortedFiles.iterator();
-
- while (i.hasNext()) {
- FileInfo fi = (FileInfo)i.next();
-
- // skip sources
- if (!fi.isHeader()) {
- continue;
- }
-
- printFile(fi, allConfigNames);
- }
- printWriter.println("# End Group");
- printWriter.println("");
-
- printWriter.println("# Begin Group \"Source Files\"");
- printWriter.println("# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90\"");
-
- i = sortedFiles.iterator();
- while (i.hasNext()) {
- FileInfo fi = (FileInfo)i.next();
-
- // skip headers
- if (fi.isHeader()) {
- continue;
- }
-
- printFile(fi, allConfigNames);
- }
- printWriter.println("# End Group");
- printWriter.println("");
-
-
- printWriter.println("# Begin Group \"Resource Files\"");
- printWriter.println("# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe\"");
- printWriter.println("# End Group");
- printWriter.println("");
- printWriter.println("# End Target");
-
- printWriter.println("# End Project");
-
- printWriter.close();
- }
-
-
- void printFile(FileInfo fi, Vector allConfigNames) {
- printWriter.println("# Begin Source File");
- printWriter.println("");
- printWriter.println("SOURCE=\"" + fi.full + "\"");
- FileAttribute attr = fi.attr;
-
- if (attr.noPch) {
- printWriter.println("# SUBTRACT CPP /YX /Yc /Yu");
- }
-
- if (attr.pchRoot) {
- printWriter.println("# ADD CPP /Yc\"incls/_precompiled.incl\"");
- }
- if (attr.configs != null) {
- String keyword = "!IF";
- for (Iterator j=allConfigNames.iterator(); j.hasNext();) {
- String cfg = (String)j.next();
- if (!attr.configs.contains(cfg)) {
- printWriter.println(keyword+" \"$(CFG)\" == \"" + cfg +"\"");
- printWriter.println("# PROP BASE Exclude_From_Build 1");
- printWriter.println("# PROP Exclude_From_Build 1");
- keyword = "!ELSEIF";
- }
- }
- printWriter.println("!ENDIF");
- }
-
- printWriter.println("# End Source File");
- }
-
- void writeConfigHeader(BuildConfig cfg) {
- printWriter.println("# Begin Special Build Tool");
- printWriter.println("SOURCE=\"$(InputPath)\"");
- printWriter.println("PreLink_Desc=" + BuildConfig.getFieldString(null, "PrelinkDescription"));
- printWriter.println("PreLink_Cmds=" +
- cfg.expandFormat(BuildConfig.getFieldString(null, "PrelinkCommand")));
- printWriter.println("# End Special Build Tool");
- printWriter.println("");
-
- for (Iterator i = cfg.getV("CompilerFlags").iterator(); i.hasNext(); ) {
- printWriter.println("# "+(String)i.next());
- }
-
-
- printWriter.println("LINK32=link.exe");
-
- for (Iterator i = cfg.getV("LinkerFlags").iterator(); i.hasNext(); ) {
- printWriter.println("# "+(String)i.next());
- }
-
- printWriter.println("ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32");
- printWriter.println("ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32");
- printWriter.println("ADD BASE RSC /l 0x409 /d \"_DEBUG\"");
- printWriter.println("ADD RSC /l 0x409 /d \"_DEBUG\"");
- printWriter.println("BSC32=bscmake.exe");
- printWriter.println("ADD BASE BSC32 /nologo");
- printWriter.println("ADD BSC32 /nologo");
- printWriter.println("");
- }
-
- protected String getProjectExt() {
- return ".dsp";
- }
-}
-
-
-class CompilerInterfaceVC6 extends CompilerInterface {
- Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir) {
- Vector rv = new Vector();
-
- rv.add("PROP BASE Use_MFC 0");
- rv.add("PROP Use_MFC 0");
- rv.add("ADD CPP /nologo /MT /W3 /WX /GX /YX /Fr /FD /c");
- rv.add("PROP BASE Output_Dir \""+outDir+"\"");
- rv.add("PROP Output_Dir \""+outDir+"\"");
- rv.add("PROP BASE Intermediate_Dir \""+outDir+"\"");
- rv.add("PROP Intermediate_Dir \""+outDir+"\"");
- rv.add("PROP BASE Target_Dir \"\"");
- rv.add("PROP Target_Dir \"\"");
- rv.add("ADD BASE CPP "+Util.prefixed_join(" /I ", includes, true));
- rv.add("ADD CPP "+Util.prefixed_join(" /I ", includes, true));
- rv.add("ADD BASE CPP "+Util.prefixed_join(" /D ", defines, true));
- rv.add("ADD CPP "+Util.prefixed_join(" /D ", defines, true));
- rv.add("ADD CPP /Yu\"incls/_precompiled.incl\"");
-
- return rv;
- }
-
- Vector getBaseLinkerFlags(String outDir, String outDll, String platformName) {
- Vector rv = new Vector();
-
- rv.add("PROP Ignore_Export_Lib 0");
- rv.add("ADD BASE CPP /MD");
- rv.add("ADD CPP /MD");
- rv.add("ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib " +
- " advapi32.lib shell32.lib ole32.lib oleaut32.lib winmm.lib");
- String machine = "/machine:I386";
- if (platformName.equals("x64")) {
- machine = "/machine:X64";
- }
- rv.add("ADD LINK32 /out:\""+outDll+"\" "+
- " /nologo /subsystem:windows /machine:" + machine +
- " /nologo /base:\"0x8000000\" /subsystem:windows /dll" +
- " /export:JNI_GetDefaultJavaVMInitArgs /export:JNI_CreateJavaVM /export:JNI_GetCreatedJavaVMs "+
- " /export:jio_snprintf /export:jio_printf /export:jio_fprintf /export:jio_vfprintf "+
- " /export:jio_vsnprintf ");
- rv.add("SUBTRACT LINK32 /pdb:none /map");
-
- return rv;
- }
-
- Vector getDebugCompilerFlags(String opt) {
- Vector rv = new Vector();
-
- rv.add("ADD BASE CPP /Gm /Zi /O"+opt);
-
- return rv;
- }
-
- Vector getDebugLinkerFlags() {
- Vector rv = new Vector();
-
- rv.add("PROP BASE Use_Debug_Libraries 1");
- rv.add("PROP Use_Debug_Libraries 1");
- rv.add("ADD LINK32 /debug");
-
- return rv;
- }
-
- void getAdditionalNonKernelLinkerFlags(Vector rv) {}
-
- Vector getProductCompilerFlags() {
- Vector rv = new Vector();
-
- rv.add("ADD CPP /O"+getOptFlag());
-
- return rv;
- }
-
- Vector getProductLinkerFlags() {
- Vector rv = new Vector();
-
- rv.add("PROP BASE Use_Debug_Libraries 0");
- rv.add("PROP Use_Debug_Libraries 0");
-
- return rv;
- }
-
- String getOptFlag() {
- return "2";
- }
-
- String getNoOptFlag() {
- return "d";
- }
-
- String makeCfgName(String flavourBuild, String platform) {
- return "vm - "+ platform + " " + flavourBuild;
- }
-}
diff --git a/src/share/tools/ProjectCreator/WinGammaPlatformVC7.java b/src/share/tools/ProjectCreator/WinGammaPlatformVC7.java
index d1d63c847..735b1a813 100644
--- a/src/share/tools/ProjectCreator/WinGammaPlatformVC7.java
+++ b/src/share/tools/ProjectCreator/WinGammaPlatformVC7.java
@@ -25,758 +25,326 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.TreeSet;
+import java.nio.file.FileSystems;
import java.util.Vector;
public class WinGammaPlatformVC7 extends WinGammaPlatform {
- String projectVersion() {return "7.10";};
+ // TODO How about moving all globals configs to its own BuildConfig?
- public void writeProjectFile(String projectFileName, String projectName,
- Vector<BuildConfig> allConfigs) throws IOException {
- System.out.println();
- System.out.println(" Writing .vcproj file: "+projectFileName);
- // If we got this far without an error, we're safe to actually
- // write the .vcproj file
- printWriter = new PrintWriter(new FileWriter(projectFileName));
+ String projectVersion() {
+ return "7.10";
+ };
- printWriter.println("<?xml version=\"1.0\" encoding=\"windows-1251\"?>");
- startTag(
- "VisualStudioProject",
- new String[] {
- "ProjectType", "Visual C++",
- "Version", projectVersion(),
- "Name", projectName,
- "ProjectGUID", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}",
- "SccProjectName", "",
- "SccLocalPath", ""
- }
- );
- startTag("Platforms");
- tag("Platform", new String[] {"Name", (String) BuildConfig.getField(null, "PlatformName")});
- endTag("Platforms");
-
- startTag("Configurations");
-
- for (Iterator i = allConfigs.iterator(); i.hasNext(); ) {
- writeConfiguration((BuildConfig)i.next());
- }
-
- endTag("Configurations");
-
- tag("References");
-
- writeFiles(allConfigs);
-
- tag("Globals");
-
- endTag("VisualStudioProject");
- printWriter.close();
-
- System.out.println(" Done.");
- }
-
-
- abstract class NameFilter {
- protected String fname;
-
- abstract boolean match(FileInfo fi);
-
- String filterString() { return ""; }
- String name() { return this.fname;}
-
- @Override
- // eclipse auto-generated
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + getOuterType().hashCode();
- result = prime * result + ((fname == null) ? 0 : fname.hashCode());
- return result;
- }
-
- @Override
- // eclipse auto-generated
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- NameFilter other = (NameFilter) obj;
- if (!getOuterType().equals(other.getOuterType()))
- return false;
- if (fname == null) {
- if (other.fname != null)
- return false;
- } else if (!fname.equals(other.fname))
- return false;
- return true;
- }
-
- // eclipse auto-generated
- private WinGammaPlatformVC7 getOuterType() {
- return WinGammaPlatformVC7.this;
- }
- }
-
- class DirectoryFilter extends NameFilter {
- String dir;
- int baseLen, dirLen;
-
- DirectoryFilter(String dir, String sbase) {
- this.dir = dir;
- this.baseLen = sbase.length();
- this.dirLen = dir.length();
- this.fname = dir;
- }
-
- DirectoryFilter(String fname, String dir, String sbase) {
- this.dir = dir;
- this.baseLen = sbase.length();
- this.dirLen = dir.length();
- this.fname = fname;
- }
-
-
- boolean match(FileInfo fi) {
- int lastSlashIndex = fi.full.lastIndexOf('/');
- String fullDir = fi.full.substring(0, lastSlashIndex);
- return fullDir.endsWith(dir);
- }
-
- @Override
- // eclipse auto-generated
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + getOuterType().hashCode();
- result = prime * result + baseLen;
- result = prime * result + ((dir == null) ? 0 : dir.hashCode());
- result = prime * result + dirLen;
- return result;
- }
-
- @Override
- // eclipse auto-generated
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!super.equals(obj))
- return false;
- if (getClass() != obj.getClass())
- return false;
- DirectoryFilter other = (DirectoryFilter) obj;
- if (!getOuterType().equals(other.getOuterType()))
- return false;
- if (baseLen != other.baseLen)
- return false;
- if (dir == null) {
- if (other.dir != null)
- return false;
- } else if (!dir.equals(other.dir))
- return false;
- if (dirLen != other.dirLen)
- return false;
- return true;
- }
-
- // eclipse auto-generated
- private WinGammaPlatformVC7 getOuterType() {
- return WinGammaPlatformVC7.this;
- }
- }
-
- class TerminatorFilter extends NameFilter {
- TerminatorFilter(String fname) {
- this.fname = fname;
-
- }
- boolean match(FileInfo fi) {
- return true;
- }
-
- }
-
- class SpecificNameFilter extends NameFilter {
- String pats[];
-
- SpecificNameFilter(String fname, String[] pats) {
- this.fname = fname;
- this.pats = pats;
- }
-
- boolean match(FileInfo fi) {
- for (int i=0; i<pats.length; i++) {
- if (fi.attr.shortName.matches(pats[i])) {
- return true;
- }
- }
- return false;
- }
-
- }
-
- class SpecificPathFilter extends NameFilter {
- String pats[];
-
- SpecificPathFilter(String fname, String[] pats) {
- this.fname = fname;
- this.pats = pats;
- }
-
- boolean match(FileInfo fi) {
- for (int i=0; i<pats.length; i++) {
- if (fi.full.matches(pats[i])) {
- return true;
- }
- }
- return false;
- }
-
- }
-
- class ContainerFilter extends NameFilter {
- Vector children;
-
- ContainerFilter(String fname) {
- this.fname = fname;
- children = new Vector();
-
- }
- boolean match(FileInfo fi) {
- return false;
- }
-
- Iterator babies() { return children.iterator(); }
-
- void add(NameFilter f) {
- children.add(f);
- }
- }
-
-
- void writeCustomToolConfig(Vector configs, String[] customToolAttrs) {
- for (Iterator i = configs.iterator(); i.hasNext(); ) {
- startTag("FileConfiguration",
- new String[] {
- "Name", (String)i.next()
- }
- );
- tag("Tool", customToolAttrs);
-
- endTag("FileConfiguration");
- }
- }
-
- // here we define filters, which define layout of what can be seen in 'Solution View' of MSVC
- // Basically there are two types of entities - container filters and real filters
- // - container filter just provides a container to group together real filters
- // - real filter can select elements from the set according to some rule, put it into XML
- // and remove from the list
- Vector<NameFilter> makeFilters(TreeSet<FileInfo> files) {
- Vector<NameFilter> rv = new Vector<NameFilter>();
- String sbase = Util.normalize(BuildConfig.getFieldString(null, "SourceBase")+"/src/");
-
- String currentDir = "";
- DirectoryFilter container = null;
- for(FileInfo fileInfo : files) {
-
- if (!fileInfo.full.startsWith(sbase)) {
- continue;
- }
-
- int lastSlash = fileInfo.full.lastIndexOf('/');
- String dir = fileInfo.full.substring(sbase.length(), lastSlash);
- if(dir.equals("share/vm")) {
- // skip files directly in share/vm - should only be precompiled.hpp which is handled below
- continue;
- }
- if (!dir.equals(currentDir)) {
- currentDir = dir;
- if (container != null && !rv.contains(container)) {
- rv.add(container);
- }
-
- // remove "share/vm/" from names
- String name = dir;
- if (dir.startsWith("share/vm/")) {
- name = dir.substring("share/vm/".length(), dir.length());
- }
- DirectoryFilter newfilter = new DirectoryFilter(name, dir, sbase);
- int i = rv.indexOf(newfilter);
- if(i == -1) {
- container = newfilter;
- } else {
- // if the filter already exists, reuse it
- container = (DirectoryFilter) rv.get(i);
- }
- }
- }
- if (container != null && !rv.contains(container)) {
- rv.add(container);
- }
-
- ContainerFilter generated = new ContainerFilter("Generated");
- ContainerFilter c1Generated = new ContainerFilter("C1");
- c1Generated.add(new SpecificPathFilter("C++ Interpreter Generated", new String[] {".*compiler1/generated/jvmtifiles/bytecodeInterpreterWithChecks.+"}));
- c1Generated.add(new SpecificPathFilter("jvmtifiles", new String[] {".*compiler1/generated/jvmtifiles/.*"}));
- generated.add(c1Generated);
- ContainerFilter c2Generated = new ContainerFilter("C2");
- c2Generated.add(new SpecificPathFilter("C++ Interpreter Generated", new String[] {".*compiler2/generated/jvmtifiles/bytecodeInterpreterWithChecks.+"}));
- c2Generated.add(new SpecificPathFilter("adfiles", new String[] {".*compiler2/generated/adfiles/.*"}));
- c2Generated.add(new SpecificPathFilter("jvmtifiles", new String[] {".*compiler2/generated/jvmtifiles/.*"}));
- generated.add(c2Generated);
- ContainerFilter coreGenerated = new ContainerFilter("Core");
- coreGenerated.add(new SpecificPathFilter("C++ Interpreter Generated", new String[] {".*core/generated/jvmtifiles/bytecodeInterpreterWithChecks.+"}));
- coreGenerated.add(new SpecificPathFilter("jvmtifiles", new String[] {".*core/generated/jvmtifiles/.*"}));
- generated.add(coreGenerated);
- ContainerFilter tieredGenerated = new ContainerFilter("Tiered");
- tieredGenerated.add(new SpecificPathFilter("C++ Interpreter Generated", new String[] {".*tiered/generated/jvmtifiles/bytecodeInterpreterWithChecks.+"}));
- tieredGenerated.add(new SpecificPathFilter("adfiles", new String[] {".*tiered/generated/adfiles/.*"}));
- tieredGenerated.add(new SpecificPathFilter("jvmtifiles", new String[] {".*tiered/generated/jvmtifiles/.*"}));
- generated.add(tieredGenerated);
- ContainerFilter kernelGenerated = new ContainerFilter("Kernel");
- kernelGenerated.add(new SpecificPathFilter("C++ Interpreter Generated", new String[] {".*kernel/generated/jvmtifiles/bytecodeInterpreterWithChecks.+"}));
- kernelGenerated.add(new SpecificPathFilter("jvmtifiles", new String[] {".*kernel/generated/jvmtifiles/.*"}));
- generated.add(kernelGenerated);
- rv.add(generated);
-
- rv.add(new SpecificNameFilter("Precompiled Header", new String[] {"precompiled.hpp"}));
-
- // this one is to catch files not caught by other filters
- rv.add(new TerminatorFilter("Source Files"));
-
- return rv;
- }
-
- void writeFiles(Vector<BuildConfig> allConfigs) {
-
- Hashtable allFiles = computeAttributedFiles(allConfigs);
-
- Vector allConfigNames = new Vector();
- for (Iterator i = allConfigs.iterator(); i.hasNext(); ) {
- allConfigNames.add(((BuildConfig)i.next()).get("Name"));
- }
-
- TreeSet sortedFiles = sortFiles(allFiles);
-
- startTag("Files");
-
- for (Iterator i = makeFilters(sortedFiles).iterator(); i.hasNext(); ) {
- doWriteFiles(sortedFiles, allConfigNames, (NameFilter)i.next());
- }
-
-
- startTag("Filter",
- new String[] {
- "Name", "Resource Files",
- "Filter", "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
- }
- );
- endTag("Filter");
-
- endTag("Files");
- }
-
- void doWriteFiles(TreeSet allFiles, Vector allConfigNames, NameFilter filter) {
- startTag("Filter",
- new String[] {
- "Name", filter.name(),
- "Filter", filter.filterString()
- }
- );
-
- if (filter instanceof ContainerFilter) {
-
- Iterator i = ((ContainerFilter)filter).babies();
- while (i.hasNext()) {
- doWriteFiles(allFiles, allConfigNames, (NameFilter)i.next());
- }
-
- } else {
-
- Iterator i = allFiles.iterator();
- while (i.hasNext()) {
- FileInfo fi = (FileInfo)i.next();
-
- if (!filter.match(fi)) {
- continue;
- }
-
- startTag("File",
- new String[] {
- "RelativePath", fi.full.replace('/', '\\')
- }
- );
-
- FileAttribute a = fi.attr;
- if (a.pchRoot) {
- writeCustomToolConfig(allConfigNames,
- new String[] {
- "Name", "VCCLCompilerTool",
- "UsePrecompiledHeader", "1"
- });
- }
-
- if (a.noPch) {
- writeCustomToolConfig(allConfigNames,
- new String[] {
- "Name", "VCCLCompilerTool",
- "UsePrecompiledHeader", "0"
- });
- }
-
- if (a.configs != null) {
- for (Iterator j=allConfigNames.iterator(); j.hasNext();) {
- String cfg = (String)j.next();
- if (!a.configs.contains(cfg)) {
- startTag("FileConfiguration",
- new String[] {
- "Name", cfg,
- "ExcludedFromBuild", "TRUE"
- });
- endTag("FileConfiguration");
-
- }
- }
- }
+ public void writeProjectFile(String projectFileName, String projectName,
+ Vector<BuildConfig> allConfigs) throws IOException {
+ System.out.println();
+ System.out.println(" Writing .vcproj file: " + projectFileName);
+ // If we got this far without an error, we're safe to actually
+ // write the .vcproj file
+ printWriter = new PrintWriter(new FileWriter(projectFileName));
- endTag("File");
+ printWriter
+ .println("<?xml version=\"1.0\" encoding=\"windows-1251\"?>");
+ startTag("VisualStudioProject", new String[] { "ProjectType",
+ "Visual C++", "Version", projectVersion(), "Name", projectName,
+ "ProjectGUID", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}",
+ "SccProjectName", "", "SccLocalPath", "" });
+ startTag("Platforms");
+ tag("Platform",
+ new String[] { "Name",
+ (String) BuildConfig.getField(null, "PlatformName") });
+ endTag();
- // we not gonna look at this file anymore
- i.remove();
- }
- }
-
- endTag("Filter");
- }
-
-
- void writeConfiguration(BuildConfig cfg) {
- startTag("Configuration",
- new String[] {
- "Name", cfg.get("Name"),
- "OutputDirectory", cfg.get("OutputDir"),
- "IntermediateDirectory", cfg.get("OutputDir"),
- "ConfigurationType", "2",
- "UseOfMFC", "0",
- "ATLMinimizesCRunTimeLibraryUsage", "FALSE"
- }
- );
-
-
-
- tagV("Tool", cfg.getV("CompilerFlags"));
-
- tag("Tool",
- new String[] {
- "Name", "VCCustomBuildTool"
- }
- );
+ startTag("Configurations");
- tagV("Tool", cfg.getV("LinkerFlags"));
+ for (BuildConfig cfg : allConfigs) {
+ writeConfiguration(cfg);
+ }
- tag("Tool",
- new String[] {
- "Name", "VCPostBuildEventTool",
- "Description", BuildConfig.getFieldString(null, "PostbuildDescription"),
- //Caution: String.replace(String,String) is available from JDK5 onwards only
- "CommandLine", cfg.expandFormat(BuildConfig.getFieldString(null, "PostbuildCommand").replace
- ("\t", "&#x0D;&#x0A;"))
- }
- );
-
- tag("Tool",
- new String[] {
- "Name", "VCPreBuildEventTool"
- }
- );
+ endTag();
- tag("Tool",
- new String[] {
- "Name", "VCPreLinkEventTool",
- "Description", BuildConfig.getFieldString(null, "PrelinkDescription"),
- //Caution: String.replace(String,String) is available from JDK5 onwards only
- "CommandLine", cfg.expandFormat(BuildConfig.getFieldString(null, "PrelinkCommand").replace
- ("\t", "&#x0D;&#x0A;"))
- }
- );
-
- tag("Tool",
- new String[] {
- "Name", "VCResourceCompilerTool",
- // XXX???
- "PreprocessorDefinitions", "NDEBUG",
- "Culture", "1033"
- }
- );
-
- tag("Tool",
- new String[] {
- "Name", "VCMIDLTool",
- "PreprocessorDefinitions", "NDEBUG",
- "MkTypLibCompatible", "TRUE",
- "SuppressStartupBanner", "TRUE",
- "TargetEnvironment", "1",
- "TypeLibraryName", cfg.get("OutputDir") + Util.sep + "vm.tlb",
- "HeaderFileName", ""
- }
- );
-
- endTag("Configuration");
- }
-
- int indent;
-
- 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 {
- 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) {
- indent--;
- doIndent();
- printWriter.println("</"+name+">");
- }
-
- void tag(String name, String... attrs) {
- startTagPrim(name, attrs, true);
- }
-
- void tagData(String name, String data) {
- doIndent();
- printWriter.print("<"+name+">");
- printWriter.print(data);
- printWriter.println("</"+name+">");
- }
-
- void tagData(String name, String data, String... attrs) {
- startTagPrim(name, attrs, false, false);
- printWriter.print(data);
- printWriter.println("</"+name+">");
- indent--;
- }
-
- 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);
+ tag("References");
+
+ writeFiles(allConfigs);
+
+ tag("Globals");
+
+ endTag();
+ printWriter.close();
+
+ System.out.println(" Done.");
+ }
+
+ void writeCustomToolConfig(Vector<BuildConfig> configs, String[] customToolAttrs) {
+ for (BuildConfig cfg : configs) {
+ startTag("FileConfiguration",
+ new String[] { "Name", (String) cfg.get("Name") });
+ tag("Tool", customToolAttrs);
+
+ endTag();
+ }
+ }
+
+ void writeFiles(Vector<BuildConfig> allConfigs) {
+
+ // This code assummes there are no config specific includes.
+ startTag("Files");
+ String sourceBase = BuildConfig.getFieldString(null, "SourceBase");
+
+ // Use first config for all global absolute includes.
+ BuildConfig baseConfig = allConfigs.firstElement();
+ Vector<String> rv = new Vector<String>();
+
+ // Then use first config for all relative includes
+ Vector<String> ri = new Vector<String>();
+ baseConfig.collectRelevantVectors(ri, "RelativeSrcInclude");
+ for (String f : ri) {
+ rv.add(sourceBase + Util.sep + f);
+ }
+
+ baseConfig.collectRelevantVectors(rv, "AbsoluteSrcInclude");
+
+ handleIncludes(rv, allConfigs);
+
+ startTag("Filter", new String[] { "Name", "Resource Files", "Filter",
+ "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" });
+ endTag();
+
+ endTag();
+ }
+
+ // Will visit file tree for each include
+ private void handleIncludes(Vector<String> includes, Vector<BuildConfig> allConfigs) {
+ for (String path : includes) {
+ FileTreeCreatorVC7 ftc = new FileTreeCreatorVC7(FileSystems.getDefault().getPath(path) , allConfigs, this);
+ try {
+ ftc.writeFileTree();
+ } catch (IOException e) {
+ e.printStackTrace();
}
- startTagPrim(name, s, true);
- }
+ }
+ }
+
+ void writeConfiguration(BuildConfig cfg) {
+ startTag("Configuration", new String[] { "Name", cfg.get("Name"),
+ "OutputDirectory", cfg.get("OutputDir"),
+ "IntermediateDirectory", cfg.get("OutputDir"),
+ "ConfigurationType", "2", "UseOfMFC", "0",
+ "ATLMinimizesCRunTimeLibraryUsage", "FALSE" });
+
+ tagV("Tool", cfg.getV("CompilerFlags"));
+ tag("Tool", new String[] { "Name", "VCCustomBuildTool" });
- void doIndent() {
- for (int i=0; i<indent; i++) {
- printWriter.print(" ");
- }
- }
+ tagV("Tool", cfg.getV("LinkerFlags"));
- protected String getProjectExt() {
- return ".vcproj";
- }
+ tag("Tool",
+ new String[] {
+ "Name",
+ "VCPostBuildEventTool",
+ "Description",
+ BuildConfig
+ .getFieldString(null, "PostbuildDescription"),
+ // Caution: String.replace(String,String) is available
+ // from JDK5 onwards only
+ "CommandLine",
+ cfg.expandFormat(BuildConfig.getFieldString(null,
+ "PostbuildCommand").replace("\t",
+ "&#x0D;&#x0A;")) });
+
+ tag("Tool", new String[] { "Name", "VCPreBuildEventTool" });
+
+ tag("Tool",
+ new String[] {
+ "Name",
+ "VCPreLinkEventTool",
+ "Description",
+ BuildConfig.getFieldString(null, "PrelinkDescription"),
+ // Caution: String.replace(String,String) is available
+ // from JDK5 onwards only
+ "CommandLine",
+ cfg.expandFormat(BuildConfig.getFieldString(null,
+ "PrelinkCommand").replace("\t", "&#x0D;&#x0A;")) });
+
+ tag("Tool", new String[] { "Name", "VCResourceCompilerTool",
+ "PreprocessorDefinitions", "NDEBUG", "Culture", "1033" });
+
+ tag("Tool", new String[] { "Name", "VCMIDLTool",
+ "PreprocessorDefinitions", "NDEBUG", "MkTypLibCompatible",
+ "TRUE", "SuppressStartupBanner", "TRUE", "TargetEnvironment",
+ "1", "TypeLibraryName",
+ cfg.get("OutputDir") + Util.sep + "vm.tlb", "HeaderFileName",
+ "" });
+
+ endTag();
+ }
+
+
+
+ protected String getProjectExt() {
+ return ".vcproj";
+ }
}
class CompilerInterfaceVC7 extends CompilerInterface {
- void getBaseCompilerFlags_common(Vector defines, Vector includes, String outDir,Vector rv) {
-
- // advanced M$ IDE (2003) can only recognize name if it's first or
- // second attribute in the tag - go guess
- addAttr(rv, "Name", "VCCLCompilerTool");
- addAttr(rv, "AdditionalIncludeDirectories", Util.join(",", includes));
- addAttr(rv, "PreprocessorDefinitions",
- Util.join(";", defines).replace("\"","&quot;"));
- addAttr(rv, "PrecompiledHeaderThrough", "precompiled.hpp");
- addAttr(rv, "PrecompiledHeaderFile", outDir+Util.sep+"vm.pch");
- addAttr(rv, "AssemblerListingLocation", outDir);
- addAttr(rv, "ObjectFile", outDir+Util.sep);
- addAttr(rv, "ProgramDataBaseFileName", outDir+Util.sep+"jvm.pdb");
- // Set /nologo optin
- addAttr(rv, "SuppressStartupBanner", "TRUE");
- // Surpass the default /Tc or /Tp. 0 is compileAsDefault
- addAttr(rv, "CompileAs", "0");
- // Set /W3 option. 3 is warningLevel_3
- addAttr(rv, "WarningLevel", "3");
- // Set /WX option,
- addAttr(rv, "WarnAsError", "TRUE");
- // Set /GS option
- addAttr(rv, "BufferSecurityCheck", "FALSE");
- // Set /Zi option. 3 is debugEnabled
- addAttr(rv, "DebugInformationFormat", "3");
- }
- Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir) {
- Vector rv = new Vector();
-
- getBaseCompilerFlags_common(defines,includes, outDir, rv);
- // Set /Yu option. 3 is pchUseUsingSpecific
- // Note: Starting VC8 pchUseUsingSpecific is 2 !!!
- addAttr(rv, "UsePrecompiledHeader", "3");
- // Set /EHsc- option
- addAttr(rv, "ExceptionHandling", "FALSE");
-
- return rv;
- }
-
- Vector getBaseLinkerFlags(String outDir, String outDll, String platformName) {
- Vector rv = new Vector();
-
- addAttr(rv, "Name", "VCLinkerTool");
- addAttr(rv, "AdditionalOptions",
- "/export:JNI_GetDefaultJavaVMInitArgs " +
- "/export:JNI_CreateJavaVM " +
- "/export:JVM_FindClassFromBootLoader "+
- "/export:JNI_GetCreatedJavaVMs "+
- "/export:jio_snprintf /export:jio_printf "+
- "/export:jio_fprintf /export:jio_vfprintf "+
- "/export:jio_vsnprintf "+
- "/export:JVM_GetVersionInfo "+
- "/export:JVM_GetThreadStateNames "+
- "/export:JVM_GetThreadStateValues "+
- "/export:JVM_InitAgentProperties ");
- addAttr(rv, "AdditionalDependencies", "Wsock32.lib winmm.lib");
- addAttr(rv, "OutputFile", outDll);
- // Set /INCREMENTAL option. 1 is linkIncrementalNo
- addAttr(rv, "LinkIncremental", "1");
- addAttr(rv, "SuppressStartupBanner", "TRUE");
- addAttr(rv, "ModuleDefinitionFile", outDir+Util.sep+"vm.def");
- addAttr(rv, "ProgramDatabaseFile", outDir+Util.sep+"jvm.pdb");
- // Set /SUBSYSTEM option. 2 is subSystemWindows
- addAttr(rv, "SubSystem", "2");
- addAttr(rv, "BaseAddress", "0x8000000");
- addAttr(rv, "ImportLibrary", outDir+Util.sep+"jvm.lib");
- if(platformName.equals("Win32")) {
- // Set /MACHINE option. 1 is X86
- addAttr(rv, "TargetMachine", "1");
- } else {
- // Set /MACHINE option. 17 is X64
- addAttr(rv, "TargetMachine", "17");
- }
-
- return rv;
- }
-
- void getDebugCompilerFlags_common(String opt,Vector rv) {
-
- // Set /On option
- addAttr(rv, "Optimization", opt);
- // Set /FR option. 1 is brAllInfo
- addAttr(rv, "BrowseInformation", "1");
- addAttr(rv, "BrowseInformationFile", "$(IntDir)" + Util.sep);
- // Set /MD option. 2 is rtMultiThreadedDLL
- addAttr(rv, "RuntimeLibrary", "2");
- // Set /Oy- option
- addAttr(rv, "OmitFramePointers", "FALSE");
-
- }
-
- Vector getDebugCompilerFlags(String opt) {
- Vector rv = new Vector();
-
- getDebugCompilerFlags_common(opt,rv);
-
- return rv;
- }
-
- Vector getDebugLinkerFlags() {
- Vector rv = new Vector();
-
- addAttr(rv, "GenerateDebugInformation", "TRUE"); // == /DEBUG option
-
- return rv;
- }
-
- void getAdditionalNonKernelLinkerFlags(Vector rv) {
- extAttr(rv, "AdditionalOptions",
- "/export:AsyncGetCallTrace ");
- }
-
- void getProductCompilerFlags_common(Vector rv) {
- // Set /O2 option. 2 is optimizeMaxSpeed
- addAttr(rv, "Optimization", "2");
- // Set /Oy- option
- addAttr(rv, "OmitFramePointers", "FALSE");
- // Set /Ob option. 1 is expandOnlyInline
- addAttr(rv, "InlineFunctionExpansion", "1");
- // Set /GF option.
- addAttr(rv, "StringPooling", "TRUE");
- // Set /MD option. 2 is rtMultiThreadedDLL
- addAttr(rv, "RuntimeLibrary", "2");
- // Set /Gy option
- addAttr(rv, "EnableFunctionLevelLinking", "TRUE");
- }
-
- Vector getProductCompilerFlags() {
- Vector rv = new Vector();
-
- getProductCompilerFlags_common(rv);
-
- return rv;
- }
-
- Vector getProductLinkerFlags() {
- Vector rv = new Vector();
-
- // Set /OPT:REF option. 2 is optReferences
- addAttr(rv, "OptimizeReferences", "2");
- // Set /OPT:optFolding option. 2 is optFolding
- addAttr(rv, "EnableCOMDATFolding", "2");
-
- return rv;
- }
-
- String getOptFlag() {
- return "2";
- }
-
- String getNoOptFlag() {
- return "0";
- }
-
- String makeCfgName(String flavourBuild, String platform) {
- return flavourBuild + "|" + platform;
- }
+ void getBaseCompilerFlags_common(Vector defines, Vector includes,
+ String outDir, Vector rv) {
+
+ // advanced M$ IDE (2003) can only recognize name if it's first or
+ // second attribute in the tag - go guess
+ addAttr(rv, "Name", "VCCLCompilerTool");
+ addAttr(rv, "AdditionalIncludeDirectories", Util.join(",", includes));
+ addAttr(rv, "PreprocessorDefinitions",
+ Util.join(";", defines).replace("\"", "&quot;"));
+ addAttr(rv, "PrecompiledHeaderThrough", "precompiled.hpp");
+ addAttr(rv, "PrecompiledHeaderFile", outDir + Util.sep + "vm.pch");
+ addAttr(rv, "AssemblerListingLocation", outDir);
+ addAttr(rv, "ObjectFile", outDir + Util.sep);
+ addAttr(rv, "ProgramDataBaseFileName", outDir + Util.sep + "jvm.pdb");
+ // Set /nologo optin
+ addAttr(rv, "SuppressStartupBanner", "TRUE");
+ // Surpass the default /Tc or /Tp. 0 is compileAsDefault
+ addAttr(rv, "CompileAs", "0");
+ // Set /W3 option. 3 is warningLevel_3
+ addAttr(rv, "WarningLevel", "3");
+ // Set /WX option,
+ addAttr(rv, "WarnAsError", "TRUE");
+ // Set /GS option
+ addAttr(rv, "BufferSecurityCheck", "FALSE");
+ // Set /Zi option. 3 is debugEnabled
+ addAttr(rv, "DebugInformationFormat", "3");
+ }
+
+ Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir) {
+ Vector rv = new Vector();
+
+ getBaseCompilerFlags_common(defines, includes, outDir, rv);
+ // Set /Yu option. 3 is pchUseUsingSpecific
+ // Note: Starting VC8 pchUseUsingSpecific is 2 !!!
+ addAttr(rv, "UsePrecompiledHeader", "3");
+ // Set /EHsc- option
+ addAttr(rv, "ExceptionHandling", "FALSE");
+
+ return rv;
+ }
+
+ Vector getBaseLinkerFlags(String outDir, String outDll, String platformName) {
+ Vector rv = new Vector();
+
+ addAttr(rv, "Name", "VCLinkerTool");
+ addAttr(rv, "AdditionalOptions",
+ "/export:JNI_GetDefaultJavaVMInitArgs "
+ + "/export:JNI_CreateJavaVM "
+ + "/export:JVM_FindClassFromBootLoader "
+ + "/export:JNI_GetCreatedJavaVMs "
+ + "/export:jio_snprintf /export:jio_printf "
+ + "/export:jio_fprintf /export:jio_vfprintf "
+ + "/export:jio_vsnprintf "
+ + "/export:JVM_GetVersionInfo "
+ + "/export:JVM_GetThreadStateNames "
+ + "/export:JVM_GetThreadStateValues "
+ + "/export:JVM_InitAgentProperties ");
+ addAttr(rv, "AdditionalDependencies", "Wsock32.lib winmm.lib");
+ addAttr(rv, "OutputFile", outDll);
+ // Set /INCREMENTAL option. 1 is linkIncrementalNo
+ addAttr(rv, "LinkIncremental", "1");
+ addAttr(rv, "SuppressStartupBanner", "TRUE");
+ addAttr(rv, "ModuleDefinitionFile", outDir + Util.sep + "vm.def");
+ addAttr(rv, "ProgramDatabaseFile", outDir + Util.sep + "jvm.pdb");
+ // Set /SUBSYSTEM option. 2 is subSystemWindows
+ addAttr(rv, "SubSystem", "2");
+ addAttr(rv, "BaseAddress", "0x8000000");
+ addAttr(rv, "ImportLibrary", outDir + Util.sep + "jvm.lib");
+ if (platformName.equals("Win32")) {
+ // Set /MACHINE option. 1 is X86
+ addAttr(rv, "TargetMachine", "1");
+ } else {
+ // Set /MACHINE option. 17 is X64
+ addAttr(rv, "TargetMachine", "17");
+ }
+
+ return rv;
+ }
+
+ void getDebugCompilerFlags_common(String opt, Vector rv) {
+
+ // Set /On option
+ addAttr(rv, "Optimization", opt);
+ // Set /FR option. 1 is brAllInfo
+ addAttr(rv, "BrowseInformation", "1");
+ addAttr(rv, "BrowseInformationFile", "$(IntDir)" + Util.sep);
+ // Set /MD option. 2 is rtMultiThreadedDLL
+ addAttr(rv, "RuntimeLibrary", "2");
+ // Set /Oy- option
+ addAttr(rv, "OmitFramePointers", "FALSE");
+
+ }
+
+ Vector getDebugCompilerFlags(String opt) {
+ Vector rv = new Vector();
+
+ getDebugCompilerFlags_common(opt, rv);
+
+ return rv;
+ }
+
+ Vector getDebugLinkerFlags() {
+ Vector rv = new Vector();
+
+ addAttr(rv, "GenerateDebugInformation", "TRUE"); // == /DEBUG option
+
+ return rv;
+ }
+
+ void getAdditionalNonKernelLinkerFlags(Vector rv) {
+ extAttr(rv, "AdditionalOptions", "/export:AsyncGetCallTrace ");
+ }
+
+ void getProductCompilerFlags_common(Vector rv) {
+ // Set /O2 option. 2 is optimizeMaxSpeed
+ addAttr(rv, "Optimization", "2");
+ // Set /Oy- option
+ addAttr(rv, "OmitFramePointers", "FALSE");
+ // Set /Ob option. 1 is expandOnlyInline
+ addAttr(rv, "InlineFunctionExpansion", "1");
+ // Set /GF option.
+ addAttr(rv, "StringPooling", "TRUE");
+ // Set /MD option. 2 is rtMultiThreadedDLL
+ addAttr(rv, "RuntimeLibrary", "2");
+ // Set /Gy option
+ addAttr(rv, "EnableFunctionLevelLinking", "TRUE");
+ }
+
+ Vector getProductCompilerFlags() {
+ Vector rv = new Vector();
+
+ getProductCompilerFlags_common(rv);
+
+ return rv;
+ }
+
+ Vector getProductLinkerFlags() {
+ Vector rv = new Vector();
+
+ // Set /OPT:REF option. 2 is optReferences
+ addAttr(rv, "OptimizeReferences", "2");
+ // Set /OPT:optFolding option. 2 is optFolding
+ addAttr(rv, "EnableCOMDATFolding", "2");
+
+ return rv;
+ }
+
+ String getOptFlag() {
+ return "2";
+ }
+
+ String getNoOptFlag() {
+ return "0";
+ }
+
+ String makeCfgName(String flavourBuild, String platform) {
+ return flavourBuild + "|" + platform;
+ }
+
}