7163863: Updated projectcreator

Enable source browsing for all platform dependent code

Reviewed-by: brutisso, coleenp
This commit is contained in:
Nils Eliasson 2012-03-29 16:43:21 +02:00
parent 0bae010a3b
commit ac3b6a6442
14 changed files with 1018 additions and 1962 deletions

View file

@ -29,12 +29,11 @@
# HOTSPOTRELEASEBINDEST, or HOTSPOTDEBUGBINDEST environment variables. # HOTSPOTRELEASEBINDEST, or HOTSPOTDEBUGBINDEST environment variables.
ProjectCreatorSources=\ ProjectCreatorSources=\
$(WorkSpace)\src\share\tools\ProjectCreator\DirectoryTree.java \
$(WorkSpace)\src\share\tools\ProjectCreator\DirectoryTreeNode.java \
$(WorkSpace)\src\share\tools\ProjectCreator\FileFormatException.java \
$(WorkSpace)\src\share\tools\ProjectCreator\ProjectCreator.java \ $(WorkSpace)\src\share\tools\ProjectCreator\ProjectCreator.java \
$(WorkSpace)\src\share\tools\ProjectCreator\FileTreeCreator.java \
$(WorkSpace)\src\share\tools\ProjectCreator\FileTreeCreatorVC7.java \
$(WorkSpace)\src\share\tools\ProjectCreator\FileTreeCreatorVC10.java \
$(WorkSpace)\src\share\tools\ProjectCreator\WinGammaPlatform.java \ $(WorkSpace)\src\share\tools\ProjectCreator\WinGammaPlatform.java \
$(WorkSpace)\src\share\tools\ProjectCreator\WinGammaPlatformVC6.java \
$(WorkSpace)\src\share\tools\ProjectCreator\WinGammaPlatformVC7.java \ $(WorkSpace)\src\share\tools\ProjectCreator\WinGammaPlatformVC7.java \
$(WorkSpace)\src\share\tools\ProjectCreator\WinGammaPlatformVC8.java \ $(WorkSpace)\src\share\tools\ProjectCreator\WinGammaPlatformVC8.java \
$(WorkSpace)\src\share\tools\ProjectCreator\WinGammaPlatformVC9.java \ $(WorkSpace)\src\share\tools\ProjectCreator\WinGammaPlatformVC9.java \
@ -57,10 +56,24 @@ ProjectCreatorIncludesPRIVATE=\
-relativeInclude src\os_cpu\windows_$(Platform_arch)\vm \ -relativeInclude src\os_cpu\windows_$(Platform_arch)\vm \
-relativeInclude src\cpu\$(Platform_arch)\vm \ -relativeInclude src\cpu\$(Platform_arch)\vm \
-absoluteInclude $(HOTSPOTBUILDSPACE)/%f/generated \ -absoluteInclude $(HOTSPOTBUILDSPACE)/%f/generated \
-ignorePath $(HOTSPOTBUILDSPACE)/%f/generated \ -relativeSrcInclude src \
-ignorePath src\share\vm\adlc \ -absoluteSrcInclude $(HOTSPOTBUILDSPACE) \
-ignorePath src\share\vm\shark \ -ignorePath $(HOTSPOTBUILDSPACE) \
-ignorePath posix -ignorePath launcher \
-ignorePath share\vm\adlc \
-ignorePath share\vm\shark \
-ignorePath share\tools \
-ignorePath solaris \
-ignorePath posix \
-ignorePath sparc \
-ignorePath linux \
-ignorePath bsd \
-ignorePath osx \
-ignorePath arm \
-ignorePath ppc \
-ignorePath zero \
-hidePath .hg
# This is referenced externally by both the IDE and batch builds # This is referenced externally by both the IDE and batch builds
ProjectCreatorOptions= ProjectCreatorOptions=
@ -84,6 +97,7 @@ ProjectCreatorIDEOptions=\
$(ProjectCreatorIDEOptions) \ $(ProjectCreatorIDEOptions) \
-sourceBase $(HOTSPOTWORKSPACE) \ -sourceBase $(HOTSPOTWORKSPACE) \
-buildBase $(HOTSPOTBUILDSPACE)\%f\%b \ -buildBase $(HOTSPOTBUILDSPACE)\%f\%b \
-buildSpace $(HOTSPOTBUILDSPACE) \
-startAt src \ -startAt src \
-compiler $(VcVersion) \ -compiler $(VcVersion) \
-projectFileName $(HOTSPOTBUILDSPACE)\$(ProjectFile) \ -projectFileName $(HOTSPOTBUILDSPACE)\$(ProjectFile) \
@ -103,6 +117,7 @@ ProjectCreatorIDEOptions=\
-define TARGET_OS_ARCH_windows_x86 \ -define TARGET_OS_ARCH_windows_x86 \
-define TARGET_OS_FAMILY_windows \ -define TARGET_OS_FAMILY_windows \
-define TARGET_COMPILER_visCPP \ -define TARGET_COMPILER_visCPP \
-define INCLUDE_TRACE \
$(ProjectCreatorIncludesPRIVATE) $(ProjectCreatorIncludesPRIVATE)
# Add in build-specific options # Add in build-specific options
@ -125,9 +140,13 @@ ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \
!endif !endif
ProjectCreatorIDEOptionsIgnoreCompiler1=\ ProjectCreatorIDEOptionsIgnoreCompiler1=\
-ignorePath_TARGET compiler1 \
-ignorePath_TARGET tiered \
-ignorePath_TARGET c1_ -ignorePath_TARGET c1_
ProjectCreatorIDEOptionsIgnoreCompiler2=\ ProjectCreatorIDEOptionsIgnoreCompiler2=\
-ignorePath_TARGET compiler2 \
-ignorePath_TARGET tiered \
-ignorePath_TARGET src/share/vm/opto \ -ignorePath_TARGET src/share/vm/opto \
-ignorePath_TARGET src/share/vm/libadt \ -ignorePath_TARGET src/share/vm/libadt \
-ignorePath_TARGET adfiles \ -ignorePath_TARGET adfiles \
@ -209,6 +228,7 @@ $(ProjectCreatorIDEOptionsIgnoreCompiler2:TARGET=kernel) \
################################################## ##################################################
ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \ ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \
-define_compiler1 COMPILER1 \ -define_compiler1 COMPILER1 \
-ignorePath_compiler1 core \
$(ProjectCreatorIDEOptionsIgnoreCompiler2:TARGET=compiler1) $(ProjectCreatorIDEOptionsIgnoreCompiler2:TARGET=compiler1)
################################################## ##################################################
@ -217,18 +237,19 @@ $(ProjectCreatorIDEOptionsIgnoreCompiler2:TARGET=compiler1)
#NOTE! This list must be kept in sync with GENERATED_NAMES in adlc.make. #NOTE! This list must be kept in sync with GENERATED_NAMES in adlc.make.
ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \ ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \
-define_compiler2 COMPILER2 \ -define_compiler2 COMPILER2 \
-ignorePath_compiler2 core \
-additionalFile_compiler2 $(Platform_arch_model).ad \ -additionalFile_compiler2 $(Platform_arch_model).ad \
-additionalGeneratedFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles ad_$(Platform_arch_model).cpp \ -additionalFile_compiler2 ad_$(Platform_arch_model).cpp \
-additionalGeneratedFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles ad_$(Platform_arch_model).hpp \ -additionalFile_compiler2 ad_$(Platform_arch_model).hpp \
-additionalGeneratedFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles ad_$(Platform_arch_model)_clone.cpp \ -additionalFile_compiler2 ad_$(Platform_arch_model)_clone.cpp \
-additionalGeneratedFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles ad_$(Platform_arch_model)_expand.cpp \ -additionalFile_compiler2 ad_$(Platform_arch_model)_expand.cpp \
-additionalGeneratedFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles ad_$(Platform_arch_model)_format.cpp \ -additionalFile_compiler2 ad_$(Platform_arch_model)_format.cpp \
-additionalGeneratedFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles ad_$(Platform_arch_model)_gen.cpp \ -additionalFile_compiler2 ad_$(Platform_arch_model)_gen.cpp \
-additionalGeneratedFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles ad_$(Platform_arch_model)_misc.cpp \ -additionalFile_compiler2 ad_$(Platform_arch_model)_misc.cpp \
-additionalGeneratedFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles ad_$(Platform_arch_model)_peephole.cpp \ -additionalFile_compiler2 ad_$(Platform_arch_model)_peephole.cpp \
-additionalGeneratedFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles ad_$(Platform_arch_model)_pipeline.cpp \ -additionalFile_compiler2 ad_$(Platform_arch_model)_pipeline.cpp \
-additionalGeneratedFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles adGlobals_$(Platform_arch_model).hpp \ -additionalFile_compiler2 adGlobals_$(Platform_arch_model).hpp \
-additionalGeneratedFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles dfa_$(Platform_arch_model).cpp \ -additionalFile_compiler2 dfa_$(Platform_arch_model).cpp \
$(ProjectCreatorIDEOptionsIgnoreCompiler1:TARGET=compiler2) $(ProjectCreatorIDEOptionsIgnoreCompiler1:TARGET=compiler2)
# Add in the jvmti (JSR-163) options # Add in the jvmti (JSR-163) options
@ -237,8 +258,8 @@ ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \
# code merge was done correctly (@see jvmti.make and jvmtiEnvFill.java). # code merge was done correctly (@see jvmti.make and jvmtiEnvFill.java).
# If so, they would then check it in as a new version of jvmtiEnv.cpp. # If so, they would then check it in as a new version of jvmtiEnv.cpp.
ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \ ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \
-additionalGeneratedFile $(HOTSPOTBUILDSPACE)/%f/generated/jvmtifiles jvmtiEnv.hpp \ -additionalFile jvmtiEnv.hpp \
-additionalGeneratedFile $(HOTSPOTBUILDSPACE)/%f/generated/jvmtifiles jvmtiEnter.cpp \ -additionalFile jvmtiEnter.cpp \
-additionalGeneratedFile $(HOTSPOTBUILDSPACE)/%f/generated/jvmtifiles jvmtiEnterTrace.cpp \ -additionalFile jvmtiEnterTrace.cpp \
-additionalGeneratedFile $(HOTSPOTBUILDSPACE)/%f/generated/jvmtifiles jvmti.h \ -additionalFile jvmti.h \
-additionalGeneratedFile $(HOTSPOTBUILDSPACE)/%f/generated/jvmtifiles bytecodeInterpreterWithChecks.cpp -additionalFile bytecodeInterpreterWithChecks.cpp

View file

@ -22,15 +22,14 @@
* *
*/ */
import java.io.File;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator;
import java.util.Vector; import java.util.Vector;
class BuildConfig { class BuildConfig {
@SuppressWarnings("rawtypes")
Hashtable vars; Hashtable vars;
Vector basicNames, basicPaths; Vector<String> basicNames, basicPaths;
String[] context; String[] context;
static CompilerInterface ci; static CompilerInterface ci;
@ -47,6 +46,7 @@ class BuildConfig {
return ci; return ci;
} }
@SuppressWarnings("rawtypes")
protected void initNames(String flavour, String build, String outDll) { protected void initNames(String flavour, String build, String outDll) {
if (vars == null) vars = new Hashtable(); if (vars == null) vars = new Hashtable();
@ -63,26 +63,28 @@ class BuildConfig {
// ones mentioned above were needed to expand format // ones mentioned above were needed to expand format
String buildBase = expandFormat(getFieldString(null, "BuildBase")); String buildBase = expandFormat(getFieldString(null, "BuildBase"));
String sourceBase = getFieldString(null, "SourceBase"); String sourceBase = getFieldString(null, "SourceBase");
String buildSpace = getFieldString(null, "BuildSpace");
String outDir = buildBase; String outDir = buildBase;
put("Id", flavourBuild); put("Id", flavourBuild);
put("OutputDir", outDir); put("OutputDir", outDir);
put("SourceBase", sourceBase); put("SourceBase", sourceBase);
put("BuildBase", buildBase); put("BuildBase", buildBase);
put("BuildSpace", buildSpace);
put("OutputDll", outDir + Util.sep + outDll); put("OutputDll", outDir + Util.sep + outDll);
context = new String [] {flavourBuild, flavour, build, null}; 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); initDefaultDefines(defines);
initDefaultCompilerFlags(includes); initDefaultCompilerFlags(includes);
initDefaultLinkerFlags(); initDefaultLinkerFlags();
handleDB(); //handleDB();
} }
protected void initDefaultCompilerFlags(Vector includes) { protected void initDefaultCompilerFlags(Vector<String> includes) {
Vector compilerFlags = new Vector(); Vector compilerFlags = new Vector();
compilerFlags.addAll(getCI().getBaseCompilerFlags(getV("Define"), compilerFlags.addAll(getCI().getBaseCompilerFlags(getV("Define"),
@ -100,143 +102,48 @@ class BuildConfig {
put("LinkerFlags", linkerFlags); put("LinkerFlags", linkerFlags);
} }
DirectoryTree getSourceTree(String sourceBase, String startAt) { public boolean matchesIgnoredPath(String path) {
DirectoryTree tree = new DirectoryTree(); Vector<String> rv = new Vector<String>();
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();
collectRelevantVectors(rv, "IgnorePath"); collectRelevantVectors(rv, "IgnorePath");
for (Iterator i = rv.iterator(); i.hasNext(); ) { for (String pathPart : rv) {
String pathPart = (String) i.next(); if (path.contains(pathPart)) {
if (prefixedName.contains(Util.normalize(pathPart))) {
return true; return true;
} }
} }
return false; return false;
} }
void addAll(Iterator i, Hashtable hash, public boolean matchesHidePath(String path) {
WinGammaPlatform platform, DirectoryTree tree, Vector<String> rv = new Vector<String>();
Vector preferredPaths, Vector filesNotFound, Vector filesDuplicate) { collectRelevantVectors(rv, "HidePath");
for (; i.hasNext(); ) { for (String pathPart : rv) {
String fileName = (String) i.next(); if (path.contains(Util.normalize(pathPart))) {
if (lookupHashFieldInContext("IgnoreFile", fileName) == null) { return true;
String prefixedName = platform.envVarPrefixedFileName(fileName, }
0, /* ignored */ }
tree, return false;
preferredPaths, }
filesNotFound,
filesDuplicate); public Vector<String> matchesAdditionalGeneratedPath(String fullPath) {
if (prefixedName != null) { Vector<String> rv = new Vector<String>();
prefixedName = Util.normalize(prefixedName); Hashtable<String, String> v = (Hashtable<String, String>)BuildConfig.getField(this.toString(), "AdditionalGeneratedFile");
if (!matchesIgnoredPath(prefixedName)) { if (v != null) {
addTo(hash, prefixedName, fileName); for (Enumeration<String> e=v.keys(); e.hasMoreElements(); ) {
} String key = e.nextElement();
String val = v.get(key);
if (fullPath.endsWith(expandFormat(key))) {
rv.add(expandFormat(val));
} }
} }
} }
return rv;
} }
void addTo(Hashtable ht, String key, String value) { void addTo(Hashtable ht, String key, String value) {
ht.put(expandFormat(key), expandFormat(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();
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());
}
}
throw new RuntimeException();
}
return rv;
}
void initDefaultDefines(Vector defines) { void initDefaultDefines(Vector defines) {
Vector sysDefines = new Vector(); Vector sysDefines = new Vector();
sysDefines.add("WIN32"); sysDefines.add("WIN32");
@ -324,20 +231,19 @@ class BuildConfig {
} }
void collectRelevantVectors(Vector rv, String field) { void collectRelevantVectors(Vector rv, String field) {
for (int i = 0; i < context.length; i++) { for (String ctx : context) {
Vector v = getFieldVector(context[i], field); Vector<String> v = getFieldVector(ctx, field);
if (v != null) { if (v != null) {
for (Iterator j=v.iterator(); j.hasNext(); ) { for (String val : v) {
String val = (String)j.next(); rv.add(expandFormat(val).replace('/', '\\'));
rv.add(expandFormat(val));
} }
} }
} }
} }
void collectRelevantHashes(Hashtable rv, String field) { void collectRelevantHashes(Hashtable rv, String field) {
for (int i = 0; i < context.length; i++) { for (String ctx : context) {
Hashtable v = (Hashtable)getField(context[i], field); Hashtable v = (Hashtable)getField(ctx, field);
if (v != null) { if (v != null) {
for (Enumeration e=v.keys(); e.hasMoreElements(); ) { for (Enumeration e=v.keys(); e.hasMoreElements(); ) {
String key = (String)e.nextElement(); String key = (String)e.nextElement();
@ -357,21 +263,17 @@ class BuildConfig {
Vector getIncludes() { Vector getIncludes() {
Vector rv = new Vector(); Vector rv = new Vector();
collectRelevantVectors(rv, "AbsoluteInclude"); collectRelevantVectors(rv, "AbsoluteInclude");
rv.addAll(getSourceIncludes()); rv.addAll(getSourceIncludes());
return rv; return rv;
} }
private Vector getSourceIncludes() { private Vector getSourceIncludes() {
Vector rv = new Vector(); Vector<String> rv = new Vector<String>();
Vector ri = new Vector(); Vector<String> ri = new Vector<String>();
String sourceBase = getFieldString(null, "SourceBase"); String sourceBase = getFieldString(null, "SourceBase");
collectRelevantVectors(ri, "RelativeInclude"); collectRelevantVectors(ri, "RelativeInclude");
for (Iterator i = ri.iterator(); i.hasNext(); ) { for (String f : ri) {
String f = (String)i.next();
rv.add(sourceBase + Util.sep + f); rv.add(sourceBase + Util.sep + f);
} }
return rv; return rv;
@ -604,7 +506,6 @@ class TieredFastDebugConfig extends GenericDebugNonKernelConfig {
} }
} }
abstract class ProductConfig extends BuildConfig { abstract class ProductConfig extends BuildConfig {
protected void init(Vector includes, Vector defines) { protected void init(Vector includes, Vector defines) {
defines.add("NDEBUG"); defines.add("NDEBUG");
@ -638,7 +539,6 @@ class TieredProductConfig extends ProductConfig {
} }
} }
class CoreDebugConfig extends GenericDebugNonKernelConfig { class CoreDebugConfig extends GenericDebugNonKernelConfig {
String getOptFlag() { String getOptFlag() {
return getCI().getNoOptFlag(); return getCI().getNoOptFlag();
@ -650,7 +550,6 @@ class CoreDebugConfig extends GenericDebugNonKernelConfig {
} }
} }
class CoreFastDebugConfig extends GenericDebugNonKernelConfig { class CoreFastDebugConfig extends GenericDebugNonKernelConfig {
String getOptFlag() { String getOptFlag() {
return getCI().getOptFlag(); return getCI().getOptFlag();
@ -662,7 +561,6 @@ class CoreFastDebugConfig extends GenericDebugNonKernelConfig {
} }
} }
class CoreProductConfig extends ProductConfig { class CoreProductConfig extends ProductConfig {
CoreProductConfig() { CoreProductConfig() {
initNames("core", "product", "jvm.dll"); initNames("core", "product", "jvm.dll");
@ -700,6 +598,7 @@ class KernelProductConfig extends ProductConfig {
init(getIncludes(), getDefines()); init(getIncludes(), getDefines());
} }
} }
abstract class CompilerInterface { abstract class CompilerInterface {
abstract Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir); abstract Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir);
abstract Vector getBaseLinkerFlags(String outDir, String outDll, String platformName); abstract Vector getBaseLinkerFlags(String outDir, String outDll, String platformName);

View file

@ -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);
}
}
}

View file

@ -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;
}

View file

@ -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);
}
}

View file

@ -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);
}
}
}

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -27,50 +27,51 @@ public class ProjectCreator {
public static void usage() { public static void usage() {
System.out.println("ProjectCreator options:"); System.out.println("ProjectCreator options:");
System.err.println("WinGammaPlatform platform-specific options:"); System.err.println("WinGammaPlatform platform-specific options:");
System.err.println(" -sourceBase <path to directory (workspace) " + System.err.println(" -sourceBase <path to directory (workspace) "
"containing source files; no trailing slash>"); + "containing source files; no trailing slash>");
System.err.println(" -dspFileName <full pathname to which .dsp file " + System.err.println(" -dspFileName <full pathname to which .dsp file "
"will be written; all parent directories must " + + "will be written; all parent directories must "
"already exist>"); + "already exist>");
System.err.println(" -envVar <environment variable to be inserted " + System.err.println(" -envVar <environment variable to be inserted "
"into .dsp file, substituting for path given in " + + "into .dsp file, substituting for path given in "
"-sourceBase. Example: HotSpotWorkSpace>"); + "-sourceBase. Example: HotSpotWorkSpace>");
System.err.println(" -dllLoc <path to directory in which to put " + System.err.println(" -dllLoc <path to directory in which to put "
"jvm.dll and jvm_g.dll; no trailing slash>"); + "jvm.dll and jvm_g.dll; no trailing slash>");
System.err.println(" If any of the above are specified, "+ System.err.println(" If any of the above are specified, "
"they must all be."); + "they must all be.");
System.err.println(" Additional, optional arguments, which can be " + System.err.println(" Additional, optional arguments, which can be "
"specified multiple times:"); + "specified multiple times:");
System.err.println(" -absoluteInclude <string containing absolute " + System.err.println(" -absoluteInclude <string containing absolute "
"path to include directory>"); + "path to include directory>");
System.err.println(" -relativeInclude <string containing include " + System.err.println(" -relativeInclude <string containing include "
"directory relative to -envVar>"); + "directory relative to -envVar>");
System.err.println(" -define <preprocessor flag to be #defined " + System.err.println(" -define <preprocessor flag to be #defined "
"(note: doesn't yet support " + + "(note: doesn't yet support " + "#define (flag) (value))>");
"#define (flag) (value))>");
System.err.println(" -perFileLine <file> <line>"); System.err.println(" -perFileLine <file> <line>");
System.err.println(" -conditionalPerFileLine <file> <line for " + System.err.println(" -conditionalPerFileLine <file> <line for "
"release build> <line for debug build>"); + "release build> <line for debug build>");
System.err.println(" (NOTE: To work around a bug in nmake, where " + System.err.println(" (NOTE: To work around a bug in nmake, where "
"you can't have a '#' character in a quoted " + + "you can't have a '#' character in a quoted "
"string, all of the lines outputted have \"#\"" + + "string, all of the lines outputted have \"#\"" + "prepended)");
"prepended)");
System.err.println(" -startAt <subdir of sourceBase>"); System.err.println(" -startAt <subdir of sourceBase>");
System.err.println(" -ignoreFile <file which won't be able to be " + System.err.println(" -ignoreFile <file which won't be able to be "
"found in the sourceBase because it's generated " + + "found in the sourceBase because it's generated " + "later>");
"later>"); System.err.println(" -additionalFile <file not in database but "
System.err.println(" -additionalFile <file not in database but " + + "which should show up in .dsp file>");
"which should show up in .dsp file>"); System.err
System.err.println(" -additionalGeneratedFile <environment variable of " + .println(" -additionalGeneratedFile <environment variable of "
"generated file's location> <relative path to " + + "generated file's location> <relative path to "
"directory containing file; no trailing slash> " + + "directory containing file; no trailing slash> "
"<name of file generated later in the build process>"); + "<name of file generated later in the build process>");
System.err.println(" -prelink <build> <desc> <cmds>:"); System.err.println(" -prelink <build> <desc> <cmds>:");
System.err.println(" Generate a set of prelink commands for the given BUILD"); System.err
System.err.println(" (\"Debug\" or \"Release\"). The prelink description and commands"); .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(" are both quoted strings.");
System.err.println(" Default includes: \".\""); System.err.println(" Default includes: \".\"");
System.err.println(" Default defines: WIN32, _WINDOWS, \"HOTSPOT_BUILD_USER=$(USERNAME)\""); System.err
.println(" Default defines: WIN32, _WINDOWS, \"HOTSPOT_BUILD_USER=$(USERNAME)\"");
} }
public static void main(String[] args) { public static void main(String[] args) {
@ -82,15 +83,15 @@ public class ProjectCreator {
String platformName = args[0]; String platformName = args[0];
Class platformClass = Class.forName(platformName); Class platformClass = Class.forName(platformName);
WinGammaPlatform platform = (WinGammaPlatform) platformClass.newInstance(); WinGammaPlatform platform = (WinGammaPlatform) platformClass
.newInstance();
String[] platformArgs = new String[args.length - 1]; String[] platformArgs = new String[args.length - 1];
System.arraycopy(args, 1, platformArgs, 0, platformArgs.length); System.arraycopy(args, 1, platformArgs, 0, platformArgs.length);
// Allow the platform to write platform-specific files // Allow the platform to write platform-specific files
platform.createVcproj(platformArgs); platform.createVcproj(platformArgs);
} } catch (Exception e) {
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
System.exit(1); System.exit(1);
} }

View file

@ -26,18 +26,19 @@ import java.util.*;
import java.io.File; import java.io.File;
public class Util { public class Util {
static String join(String padder, Vector v) {
static String join(String padder, Vector<String> v) {
return join(padder, v, false); 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(); StringBuffer sb = new StringBuffer();
for (Iterator iter = v.iterator(); iter.hasNext(); ) { for (Iterator<String> iter = v.iterator(); iter.hasNext(); ) {
if (quoted) { if (quoted) {
sb.append('"'); sb.append('"');
} }
sb.append((String)iter.next()); sb.append(iter.next());
if (quoted) { if (quoted) {
sb.append('"'); 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(); StringBuffer sb = new StringBuffer();
for (Iterator iter = v.iterator(); iter.hasNext(); ) { for (Iterator<String> iter = v.iterator(); iter.hasNext(); ) {
sb.append(padder); sb.append(padder);
if (quoted) { if (quoted) {

View file

@ -29,6 +29,7 @@ import java.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Stack;
import java.util.TreeSet; import java.util.TreeSet;
import java.util.Vector; import java.util.Vector;
@ -218,69 +219,6 @@ public abstract class WinGammaPlatform {
return false; 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) String getProjectName(String fullPath, String extension)
throws IllegalArgumentException, IOException { throws IllegalArgumentException, IOException {
File file = new File(fullPath).getCanonicalFile(); File file = new File(fullPath).getCanonicalFile();
@ -369,6 +307,12 @@ public abstract class WinGammaPlatform {
HsArgHandler.STRING HsArgHandler.STRING
), ),
new HsArgRule("-buildSpace",
"BuildSpace",
null,
HsArgHandler.STRING
),
new HsArgRule("-platformName", new HsArgRule("-platformName",
"PlatformName", "PlatformName",
null, null,
@ -405,6 +349,18 @@ public abstract class WinGammaPlatform {
HsArgHandler.VECTOR HsArgHandler.VECTOR
), ),
new HsArgRule("-absoluteSrcInclude",
"AbsoluteSrcInclude",
null,
HsArgHandler.VECTOR
),
new HsArgRule("-relativeSrcInclude",
"RelativeSrcInclude",
null,
HsArgHandler.VECTOR
),
new HsArgRule("-define", new HsArgRule("-define",
"Define", "Define",
null, null,
@ -494,6 +450,12 @@ public abstract class WinGammaPlatform {
HsArgHandler.VECTOR HsArgHandler.VECTOR
), ),
new HsArgRule("-hidePath",
"HidePath",
null,
HsArgHandler.VECTOR
),
new HsArgRule("-additionalFile", new HsArgRule("-additionalFile",
"AdditionalFile", "AdditionalFile",
null, null,
@ -611,107 +573,101 @@ public abstract class WinGammaPlatform {
return allConfigs; return allConfigs;
} }
class FileAttribute {
int numConfigs;
Vector configs;
String shortName;
boolean noPch, pchRoot;
FileAttribute(String shortName, BuildConfig cfg, int numConfigs) {
this.shortName = shortName;
this.noPch = (cfg.lookupHashFieldInContext("DisablePch", shortName) != null);
this.pchRoot = shortName.equals(BuildConfig.getFieldString(null, "UseToGeneratePch"));
this.numConfigs = numConfigs;
configs = new Vector();
add(cfg.get("Name"));
}
void add(String confName) {
configs.add(confName);
// if presented in all configs
if (configs.size() == numConfigs) {
configs = null;
}
}
}
class FileInfo implements Comparable {
String full;
FileAttribute attr;
FileInfo(String full, FileAttribute attr) {
this.full = full;
this.attr = attr;
}
public int compareTo(Object o) {
FileInfo oo = (FileInfo)o;
return full.compareTo(oo.full);
}
boolean isHeader() {
return attr.shortName.endsWith(".h") || attr.shortName.endsWith(".hpp");
}
boolean isCpp() {
return attr.shortName.endsWith(".cpp");
}
}
TreeSet sortFiles(Hashtable allFiles) {
TreeSet rv = new TreeSet();
Enumeration e = allFiles.keys();
while (e.hasMoreElements()) {
String fullPath = (String)e.nextElement();
rv.add(new FileInfo(fullPath, (FileAttribute)allFiles.get(fullPath)));
}
return rv;
}
Hashtable computeAttributedFiles(Vector allConfigs) {
Hashtable ht = new Hashtable();
int numConfigs = allConfigs.size();
for (Iterator i = allConfigs.iterator(); i.hasNext(); ) {
BuildConfig bc = (BuildConfig)i.next();
Hashtable confFiles = (Hashtable)bc.getSpecificField("AllFilesHash");
String confName = bc.get("Name");
for (Enumeration e=confFiles.keys(); e.hasMoreElements(); ) {
String filePath = (String)e.nextElement();
FileAttribute fa = (FileAttribute)ht.get(filePath);
if (fa == null) {
fa = new FileAttribute((String)confFiles.get(filePath), bc, numConfigs);
ht.put(filePath, fa);
} else {
fa.add(confName);
}
}
}
return ht;
}
Hashtable computeAttributedFiles(BuildConfig bc) {
Hashtable ht = new Hashtable();
Hashtable confFiles = (Hashtable)bc.getSpecificField("AllFilesHash");
for (Enumeration e = confFiles.keys(); e.hasMoreElements(); ) {
String filePath = (String)e.nextElement();
ht.put(filePath, new FileAttribute((String)confFiles.get(filePath), bc, 1));
}
return ht;
}
PrintWriter printWriter; PrintWriter printWriter;
public void writeProjectFile(String projectFileName, String projectName, public void writeProjectFile(String projectFileName, String projectName,
Vector<BuildConfig> allConfigs) throws IOException { Vector<BuildConfig> allConfigs) throws IOException {
throw new RuntimeException("use compiler version specific version"); throw new RuntimeException("use compiler version specific version");
} }
int indent;
private Stack<String> tagStack = new Stack<String>();
private void startTagPrim(String name, String[] attrs, boolean close) {
startTagPrim(name, attrs, close, true);
}
private void startTagPrim(String name, String[] attrs, boolean close,
boolean newline) {
doIndent();
printWriter.print("<" + name);
indent++;
if (attrs != null && attrs.length > 0) {
for (int i = 0; i < attrs.length; i += 2) {
printWriter.print(" " + attrs[i] + "=\"" + attrs[i + 1] + "\"");
if (i < attrs.length - 2) {
}
}
}
if (close) {
indent--;
printWriter.print(" />");
} else {
// TODO push tag name, and change endTag to pop and print.
tagStack.push(name);
printWriter.print(">");
}
if (newline) {
printWriter.println();
}
}
void startTag(String name, String... attrs) {
startTagPrim(name, attrs, false);
}
void startTagV(String name, Vector attrs) {
String s[] = new String[attrs.size()];
for (int i = 0; i < attrs.size(); i++) {
s[i] = (String) attrs.elementAt(i);
}
startTagPrim(name, s, false);
}
void endTag() {
String name = tagStack.pop();
indent--;
doIndent();
printWriter.println("</" + name + ">");
}
private void endTagNoIndent() {
String name = tagStack.pop();
indent--;
printWriter.println("</" + name + ">");
}
void tag(String name, String... attrs) {
startTagPrim(name, attrs, true);
}
void tagData(String name, String data) {
startTagPrim(name, null, false, false);
printWriter.print(data);
endTagNoIndent();
}
void tagData(String name, String data, String... attrs) {
startTagPrim(name, attrs, false, false);
printWriter.print(data);
endTagNoIndent();
}
void tagV(String name, Vector attrs) {
String s[] = new String[attrs.size()];
for (int i = 0; i < attrs.size(); i++) {
s[i] = (String) attrs.elementAt(i);
}
startTagPrim(name, s, true);
}
void doIndent() {
for (int i = 0; i < indent; i++) {
printWriter.print(" ");
}
}
} }

View file

@ -3,14 +3,18 @@ import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.Hashtable; import java.nio.file.FileSystems;
import java.util.Iterator; import java.util.Iterator;
import java.util.TreeSet; import java.util.LinkedList;
import java.util.UUID; import java.util.UUID;
import java.util.Vector; import java.util.Vector;
public class WinGammaPlatformVC10 extends WinGammaPlatformVC7 { public class WinGammaPlatformVC10 extends WinGammaPlatformVC7 {
LinkedList <String>filters = new LinkedList<String>();
LinkedList <String[]>filterDeps = new LinkedList<String[]>();
@Override @Override
protected String getProjectExt() { protected String getProjectExt() {
return ".vcxproj"; return ".vcxproj";
@ -37,15 +41,15 @@ public class WinGammaPlatformVC10 extends WinGammaPlatformVC7 {
"Include", cfg.get("Name")); "Include", cfg.get("Name"));
tagData("Configuration", cfg.get("Id")); tagData("Configuration", cfg.get("Id"));
tagData("Platform", cfg.get("PlatformName")); tagData("Platform", cfg.get("PlatformName"));
endTag("ProjectConfiguration"); endTag();
} }
endTag("ItemGroup"); endTag();
startTag("PropertyGroup", "Label", "Globals"); startTag("PropertyGroup", "Label", "Globals");
tagData("ProjectGuid", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}"); tagData("ProjectGuid", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}");
tag("SccProjectName"); tag("SccProjectName");
tag("SccLocalPath"); tag("SccLocalPath");
endTag("PropertyGroup"); endTag();
tag("Import", "Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props"); tag("Import", "Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props");
@ -53,19 +57,19 @@ public class WinGammaPlatformVC10 extends WinGammaPlatformVC7 {
startTag(cfg, "PropertyGroup", "Label", "Configuration"); startTag(cfg, "PropertyGroup", "Label", "Configuration");
tagData("ConfigurationType", "DynamicLibrary"); tagData("ConfigurationType", "DynamicLibrary");
tagData("UseOfMfc", "false"); tagData("UseOfMfc", "false");
endTag("PropertyGroup"); endTag();
} }
tag("Import", "Project", "$(VCTargetsPath)\\Microsoft.Cpp.props"); tag("Import", "Project", "$(VCTargetsPath)\\Microsoft.Cpp.props");
startTag("ImportGroup", "Label", "ExtensionSettings"); startTag("ImportGroup", "Label", "ExtensionSettings");
endTag("ImportGroup"); endTag();
for (BuildConfig cfg : allConfigs) { for (BuildConfig cfg : allConfigs) {
startTag(cfg, "ImportGroup", "Label", "PropertySheets"); startTag(cfg, "ImportGroup", "Label", "PropertySheets");
tag("Import", tag("Import",
"Project", "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props", "Project", "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props",
"Condition", "exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')", "Condition", "exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')",
"Label", "LocalAppDataPlatform"); "Label", "LocalAppDataPlatform");
endTag("ImportGroup"); endTag();
} }
tag("PropertyGroup", "Label", "UserMacros"); tag("PropertyGroup", "Label", "UserMacros");
@ -82,38 +86,38 @@ public class WinGammaPlatformVC10 extends WinGammaPlatformVC7 {
tag(cfg, "CodeAnalysisRules"); tag(cfg, "CodeAnalysisRules");
tag(cfg, "CodeAnalysisRuleAssemblies"); tag(cfg, "CodeAnalysisRuleAssemblies");
} }
endTag("PropertyGroup"); endTag();
for (BuildConfig cfg : allConfigs) { for (BuildConfig cfg : allConfigs) {
startTag(cfg, "ItemDefinitionGroup"); startTag(cfg, "ItemDefinitionGroup");
startTag("ClCompile"); startTag("ClCompile");
tagV(cfg.getV("CompilerFlags")); tagV(cfg.getV("CompilerFlags"));
endTag("ClCompile"); endTag();
startTag("Link"); startTag("Link");
tagV(cfg.getV("LinkerFlags")); tagV(cfg.getV("LinkerFlags"));
endTag("Link"); endTag();
startTag("PostBuildEvent"); startTag("PostBuildEvent");
tagData("Message", BuildConfig.getFieldString(null, "PostbuildDescription")); tagData("Message", BuildConfig.getFieldString(null, "PostbuildDescription"));
tagData("Command", cfg.expandFormat(BuildConfig.getFieldString(null, "PostbuildCommand").replace("\t", "\r\n"))); tagData("Command", cfg.expandFormat(BuildConfig.getFieldString(null, "PostbuildCommand").replace("\t", "\r\n")));
endTag("PostBuildEvent"); endTag();
startTag("PreLinkEvent"); startTag("PreLinkEvent");
tagData("Message", BuildConfig.getFieldString(null, "PrelinkDescription")); tagData("Message", BuildConfig.getFieldString(null, "PrelinkDescription"));
tagData("Command", cfg.expandFormat(BuildConfig.getFieldString(null, "PrelinkCommand").replace("\t", "\r\n"))); tagData("Command", cfg.expandFormat(BuildConfig.getFieldString(null, "PrelinkCommand").replace("\t", "\r\n")));
endTag("PreLinkEvent"); endTag();
endTag("ItemDefinitionGroup"); endTag();
} }
writeFiles(allConfigs, projDir); writeFiles(allConfigs, projDir);
tag("Import", "Project", "$(VCTargetsPath)\\Microsoft.Cpp.targets"); tag("Import", "Project", "$(VCTargetsPath)\\Microsoft.Cpp.targets");
startTag("ImportGroup", "Label", "ExtensionTargets"); startTag("ImportGroup", "Label", "ExtensionTargets");
endTag("ImportGroup"); endTag();
endTag("Project"); endTag();
printWriter.close(); printWriter.close();
System.out.println(" Done."); System.out.println(" Done.");
@ -138,14 +142,22 @@ public class WinGammaPlatformVC10 extends WinGammaPlatformVC7 {
for (BuildConfig cfg : allConfigs) { for (BuildConfig cfg : allConfigs) {
startTag(cfg, "PropertyGroup"); startTag(cfg, "PropertyGroup");
tagData("LocalDebuggerCommand", "$(TargetDir)/hotspot.exe"); tagData("LocalDebuggerCommand", "$(TargetDir)/hotspot.exe");
endTag("PropertyGroup"); endTag();
} }
endTag("Project"); endTag();
printWriter.close(); printWriter.close();
System.out.println(" Done."); 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, private void writeFilterFile(String projectFileName, String projectName,
Vector<BuildConfig> allConfigs, String base) throws FileNotFoundException, UnsupportedEncodingException { Vector<BuildConfig> allConfigs, String base) throws FileNotFoundException, UnsupportedEncodingException {
String filterFileName = projectFileName + ".filters"; String filterFileName = projectFileName + ".filters";
@ -157,202 +169,85 @@ public class WinGammaPlatformVC10 extends WinGammaPlatformVC7 {
"ToolsVersion", "4.0", "ToolsVersion", "4.0",
"xmlns", "http://schemas.microsoft.com/developer/msbuild/2003"); "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"); startTag("ItemGroup");
for (NameFilter filter : filters) { for (String filter : filters) {
doWriteFilter(filter, ""); startTag("Filter", "Include",filter);
UUID uuid = UUID.randomUUID();
tagData("UniqueIdentifier", "{" + uuid.toString() + "}");
endTag();
} }
startTag("Filter", "Include", "Resource Files"); startTag("Filter", "Include", "Resource Files");
UUID uuid = UUID.randomUUID(); UUID uuid = UUID.randomUUID();
tagData("UniqueIdentifier", "{" + uuid.toString() + "}"); tagData("UniqueIdentifier", "{" + uuid.toString() + "}");
tagData("Extensions", "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"); tagData("Extensions", "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe");
endTag("Filter"); endTag();
endTag("ItemGroup"); endTag();
// then all cpp files //TODO - do I need to split cpp and hpp files?
// then all files
startTag("ItemGroup"); startTag("ItemGroup");
for (NameFilter filter : filters) { for (String[] dep : filterDeps) {
doWriteFiles(sortedFiles, filter, "", "ClCompile", new Evaluator() { String tagName = getFileTagFromSuffix(dep[0]);
public boolean pick(FileInfo fi) {
return fi.isCpp();
}
}, base);
}
endTag("ItemGroup");
// then all header files startTag(tagName, "Include", dep[0]);
startTag("ItemGroup"); tagData("Filter", dep[1]);
for (NameFilter filter : filters) { endTag();
doWriteFiles(sortedFiles, filter, "", "ClInclude", new Evaluator() {
public boolean pick(FileInfo fi) {
return fi.isHeader();
} }
}, base); endTag();
}
endTag("ItemGroup");
// then all other files endTag();
startTag("ItemGroup");
for (NameFilter filter : filters) {
doWriteFiles(sortedFiles, filter, "", "None", new Evaluator() {
public boolean pick(FileInfo fi) {
return true;
}
}, base);
}
endTag("ItemGroup");
endTag("Project");
printWriter.close(); printWriter.close();
System.out.println(" Done."); System.out.println(" Done.");
} }
public String getFileTagFromSuffix(String fileName) {
private void doWriteFilter(NameFilter filter, String start) { if (fileName.endsWith(".cpp")) {
startTag("Filter", "Include", start + filter.fname); return"ClCompile";
UUID uuid = UUID.randomUUID(); } else if (fileName.endsWith(".c")) {
tagData("UniqueIdentifier", "{" + uuid.toString() + "}"); return "ClCompile";
endTag("Filter"); } else if (fileName.endsWith(".hpp")) {
if (filter instanceof ContainerFilter) { return"ClInclude";
Iterator i = ((ContainerFilter)filter).babies(); } else if (fileName.endsWith(".h")) {
while (i.hasNext()) { return "ClInclude";
doWriteFilter((NameFilter)i.next(), start + filter.fname + "\\"); } 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) { void writeFiles(Vector<BuildConfig> allConfigs, String projDir) {
Hashtable<String, FileAttribute> allFiles = computeAttributedFiles(allConfigs); // This code assummes there are no config specific includes.
TreeSet<FileInfo> sortedFiles = sortFiles(allFiles);
// first cpp-files
startTag("ItemGroup"); startTag("ItemGroup");
for (FileInfo fi : sortedFiles) {
if (!fi.isCpp()) {
continue;
}
writeFile("ClCompile", allConfigs, fi, projDir);
}
endTag("ItemGroup");
// then header-files String sourceBase = BuildConfig.getFieldString(null, "SourceBase");
startTag("ItemGroup");
for (FileInfo fi : sortedFiles) {
if (!fi.isHeader()) {
continue;
}
writeFile("ClInclude", allConfigs, fi, projDir);
}
endTag("ItemGroup");
// then others // Use first config for all global absolute includes.
startTag("ItemGroup"); BuildConfig baseConfig = allConfigs.firstElement();
for (FileInfo fi : sortedFiles) { Vector<String> rv = new Vector<String>();
if (fi.isHeader() || fi.isCpp()) {
continue; // Then use first config for all relative includes
} Vector<String> ri = new Vector<String>();
writeFile("None", allConfigs, fi, projDir); baseConfig.collectRelevantVectors(ri, "RelativeSrcInclude");
} for (String f : ri) {
endTag("ItemGroup"); rv.add(sourceBase + Util.sep + f);
} }
/** baseConfig.collectRelevantVectors(rv, "AbsoluteSrcInclude");
* 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 handleIncludes(rv, allConfigs);
while (pi < pathTok.length &&
bi < baseTok.length && endTag();
pathTok[pi].equals(baseTok[bi])) {
pi++;
bi++;
} }
// for each path component left in base, add "../" // Will visit file tree for each include
while (bi < baseTok.length) { private void handleIncludes(Vector<String> includes, Vector<BuildConfig> allConfigs) {
bi++; for (String path : includes) {
newPath.append("..\\"); FileTreeCreatorVC10 ftc = new FileTreeCreatorVC10(FileSystems.getDefault().getPath(path) , allConfigs, this);
try {
ftc.writeFileTree();
} catch (IOException e) {
e.printStackTrace();
} }
// now add everything left in path
while (pi < pathTok.length) {
newPath.append(pathTok[pi]);
pi++;
if (pi != pathTok.length) {
newPath.append("\\");
}
}
return newPath.toString();
}
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);
} }
} }
@ -360,7 +255,6 @@ public class WinGammaPlatformVC10 extends WinGammaPlatformVC7 {
return "'$(Configuration)|$(Platform)'=='"+cfg.get("Name")+"'"; return "'$(Configuration)|$(Platform)'=='"+cfg.get("Name")+"'";
} }
void tagV(Vector<String> v) { void tagV(Vector<String> v) {
Iterator<String> i = v.iterator(); Iterator<String> i = v.iterator();
while(i.hasNext()) { while(i.hasNext()) {
@ -391,6 +285,7 @@ public class WinGammaPlatformVC10 extends WinGammaPlatformVC7 {
startTag(name, ss); startTag(name, ss);
} }
} }
class CompilerInterfaceVC10 extends CompilerInterface { class CompilerInterfaceVC10 extends CompilerInterface {

View file

@ -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;
}
}

View file

@ -25,46 +25,44 @@
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.Hashtable; import java.nio.file.FileSystems;
import java.util.Iterator;
import java.util.TreeSet;
import java.util.Vector; import java.util.Vector;
public class WinGammaPlatformVC7 extends WinGammaPlatform { public class WinGammaPlatformVC7 extends WinGammaPlatform {
String projectVersion() {return "7.10";}; // TODO How about moving all globals configs to its own BuildConfig?
String projectVersion() {
return "7.10";
};
public void writeProjectFile(String projectFileName, String projectName, public void writeProjectFile(String projectFileName, String projectName,
Vector<BuildConfig> allConfigs) throws IOException { Vector<BuildConfig> allConfigs) throws IOException {
System.out.println(); System.out.println();
System.out.println(" Writing .vcproj file: "+projectFileName); System.out.println(" Writing .vcproj file: " + projectFileName);
// If we got this far without an error, we're safe to actually // If we got this far without an error, we're safe to actually
// write the .vcproj file // write the .vcproj file
printWriter = new PrintWriter(new FileWriter(projectFileName)); printWriter = new PrintWriter(new FileWriter(projectFileName));
printWriter.println("<?xml version=\"1.0\" encoding=\"windows-1251\"?>"); printWriter
startTag( .println("<?xml version=\"1.0\" encoding=\"windows-1251\"?>");
"VisualStudioProject", startTag("VisualStudioProject", new String[] { "ProjectType",
new String[] { "Visual C++", "Version", projectVersion(), "Name", projectName,
"ProjectType", "Visual C++",
"Version", projectVersion(),
"Name", projectName,
"ProjectGUID", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}", "ProjectGUID", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}",
"SccProjectName", "", "SccProjectName", "", "SccLocalPath", "" });
"SccLocalPath", ""
}
);
startTag("Platforms"); startTag("Platforms");
tag("Platform", new String[] {"Name", (String) BuildConfig.getField(null, "PlatformName")}); tag("Platform",
endTag("Platforms"); new String[] { "Name",
(String) BuildConfig.getField(null, "PlatformName") });
endTag();
startTag("Configurations"); startTag("Configurations");
for (Iterator i = allConfigs.iterator(); i.hasNext(); ) { for (BuildConfig cfg : allConfigs) {
writeConfiguration((BuildConfig)i.next()); writeConfiguration(cfg);
} }
endTag("Configurations"); endTag();
tag("References"); tag("References");
@ -72,549 +70,117 @@ public class WinGammaPlatformVC7 extends WinGammaPlatform {
tag("Globals"); tag("Globals");
endTag("VisualStudioProject"); endTag();
printWriter.close(); printWriter.close();
System.out.println(" Done."); System.out.println(" Done.");
} }
void writeCustomToolConfig(Vector<BuildConfig> configs, String[] customToolAttrs) {
abstract class NameFilter { for (BuildConfig cfg : configs) {
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", startTag("FileConfiguration",
new String[] { new String[] { "Name", (String) cfg.get("Name") });
"Name", (String)i.next()
}
);
tag("Tool", customToolAttrs); tag("Tool", customToolAttrs);
endTag("FileConfiguration"); endTag();
} }
} }
// 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) { void writeFiles(Vector<BuildConfig> allConfigs) {
Hashtable allFiles = computeAttributedFiles(allConfigs); // This code assummes there are no config specific includes.
Vector allConfigNames = new Vector();
for (Iterator i = allConfigs.iterator(); i.hasNext(); ) {
allConfigNames.add(((BuildConfig)i.next()).get("Name"));
}
TreeSet sortedFiles = sortFiles(allFiles);
startTag("Files"); startTag("Files");
String sourceBase = BuildConfig.getFieldString(null, "SourceBase");
for (Iterator i = makeFilters(sortedFiles).iterator(); i.hasNext(); ) { // Use first config for all global absolute includes.
doWriteFiles(sortedFiles, allConfigNames, (NameFilter)i.next()); 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");
startTag("Filter", handleIncludes(rv, allConfigs);
new String[] {
"Name", "Resource Files",
"Filter", "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
}
);
endTag("Filter");
endTag("Files"); startTag("Filter", new String[] { "Name", "Resource Files", "Filter",
"ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" });
endTag();
endTag();
} }
void doWriteFiles(TreeSet allFiles, Vector allConfigNames, NameFilter filter) { // Will visit file tree for each include
startTag("Filter", private void handleIncludes(Vector<String> includes, Vector<BuildConfig> allConfigs) {
new String[] { for (String path : includes) {
"Name", filter.name(), FileTreeCreatorVC7 ftc = new FileTreeCreatorVC7(FileSystems.getDefault().getPath(path) , allConfigs, this);
"Filter", filter.filterString() try {
} ftc.writeFileTree();
); } catch (IOException e) {
e.printStackTrace();
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");
} }
} }
} }
endTag("File");
// we not gonna look at this file anymore
i.remove();
}
}
endTag("Filter");
}
void writeConfiguration(BuildConfig cfg) { void writeConfiguration(BuildConfig cfg) {
startTag("Configuration", startTag("Configuration", new String[] { "Name", cfg.get("Name"),
new String[] {
"Name", cfg.get("Name"),
"OutputDirectory", cfg.get("OutputDir"), "OutputDirectory", cfg.get("OutputDir"),
"IntermediateDirectory", cfg.get("OutputDir"), "IntermediateDirectory", cfg.get("OutputDir"),
"ConfigurationType", "2", "ConfigurationType", "2", "UseOfMFC", "0",
"UseOfMFC", "0", "ATLMinimizesCRunTimeLibraryUsage", "FALSE" });
"ATLMinimizesCRunTimeLibraryUsage", "FALSE"
}
);
tagV("Tool", cfg.getV("CompilerFlags")); tagV("Tool", cfg.getV("CompilerFlags"));
tag("Tool", tag("Tool", new String[] { "Name", "VCCustomBuildTool" });
new String[] {
"Name", "VCCustomBuildTool"
}
);
tagV("Tool", cfg.getV("LinkerFlags")); tagV("Tool", cfg.getV("LinkerFlags"));
tag("Tool", tag("Tool",
new String[] { new String[] {
"Name", "VCPostBuildEventTool", "Name",
"Description", BuildConfig.getFieldString(null, "PostbuildDescription"), "VCPostBuildEventTool",
//Caution: String.replace(String,String) is available from JDK5 onwards only "Description",
"CommandLine", cfg.expandFormat(BuildConfig.getFieldString(null, "PostbuildCommand").replace BuildConfig
("\t", "&#x0D;&#x0A;")) .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", tag("Tool",
new String[] { new String[] {
"Name", "VCPreBuildEventTool" "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", tag("Tool", new String[] { "Name", "VCResourceCompilerTool",
new String[] { "PreprocessorDefinitions", "NDEBUG", "Culture", "1033" });
"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", tag("Tool", new String[] { "Name", "VCMIDLTool",
new String[] { "PreprocessorDefinitions", "NDEBUG", "MkTypLibCompatible",
"Name", "VCResourceCompilerTool", "TRUE", "SuppressStartupBanner", "TRUE", "TargetEnvironment",
// XXX??? "1", "TypeLibraryName",
"PreprocessorDefinitions", "NDEBUG", cfg.get("OutputDir") + Util.sep + "vm.tlb", "HeaderFileName",
"Culture", "1033" "" });
}
);
tag("Tool", endTag();
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);
}
startTagPrim(name, s, true);
} }
void doIndent() {
for (int i=0; i<indent; i++) {
printWriter.print(" ");
}
}
protected String getProjectExt() { protected String getProjectExt() {
return ".vcproj"; return ".vcproj";
@ -622,19 +188,20 @@ public class WinGammaPlatformVC7 extends WinGammaPlatform {
} }
class CompilerInterfaceVC7 extends CompilerInterface { class CompilerInterfaceVC7 extends CompilerInterface {
void getBaseCompilerFlags_common(Vector defines, Vector includes, String outDir,Vector rv) { void getBaseCompilerFlags_common(Vector defines, Vector includes,
String outDir, Vector rv) {
// advanced M$ IDE (2003) can only recognize name if it's first or // advanced M$ IDE (2003) can only recognize name if it's first or
// second attribute in the tag - go guess // second attribute in the tag - go guess
addAttr(rv, "Name", "VCCLCompilerTool"); addAttr(rv, "Name", "VCCLCompilerTool");
addAttr(rv, "AdditionalIncludeDirectories", Util.join(",", includes)); addAttr(rv, "AdditionalIncludeDirectories", Util.join(",", includes));
addAttr(rv, "PreprocessorDefinitions", addAttr(rv, "PreprocessorDefinitions",
Util.join(";", defines).replace("\"","&quot;")); Util.join(";", defines).replace("\"", "&quot;"));
addAttr(rv, "PrecompiledHeaderThrough", "precompiled.hpp"); addAttr(rv, "PrecompiledHeaderThrough", "precompiled.hpp");
addAttr(rv, "PrecompiledHeaderFile", outDir+Util.sep+"vm.pch"); addAttr(rv, "PrecompiledHeaderFile", outDir + Util.sep + "vm.pch");
addAttr(rv, "AssemblerListingLocation", outDir); addAttr(rv, "AssemblerListingLocation", outDir);
addAttr(rv, "ObjectFile", outDir+Util.sep); addAttr(rv, "ObjectFile", outDir + Util.sep);
addAttr(rv, "ProgramDataBaseFileName", outDir+Util.sep+"jvm.pdb"); addAttr(rv, "ProgramDataBaseFileName", outDir + Util.sep + "jvm.pdb");
// Set /nologo optin // Set /nologo optin
addAttr(rv, "SuppressStartupBanner", "TRUE"); addAttr(rv, "SuppressStartupBanner", "TRUE");
// Surpass the default /Tc or /Tp. 0 is compileAsDefault // Surpass the default /Tc or /Tp. 0 is compileAsDefault
@ -648,10 +215,11 @@ class CompilerInterfaceVC7 extends CompilerInterface {
// Set /Zi option. 3 is debugEnabled // Set /Zi option. 3 is debugEnabled
addAttr(rv, "DebugInformationFormat", "3"); addAttr(rv, "DebugInformationFormat", "3");
} }
Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir) { Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir) {
Vector rv = new Vector(); Vector rv = new Vector();
getBaseCompilerFlags_common(defines,includes, outDir, rv); getBaseCompilerFlags_common(defines, includes, outDir, rv);
// Set /Yu option. 3 is pchUseUsingSpecific // Set /Yu option. 3 is pchUseUsingSpecific
// Note: Starting VC8 pchUseUsingSpecific is 2 !!! // Note: Starting VC8 pchUseUsingSpecific is 2 !!!
addAttr(rv, "UsePrecompiledHeader", "3"); addAttr(rv, "UsePrecompiledHeader", "3");
@ -666,29 +234,29 @@ class CompilerInterfaceVC7 extends CompilerInterface {
addAttr(rv, "Name", "VCLinkerTool"); addAttr(rv, "Name", "VCLinkerTool");
addAttr(rv, "AdditionalOptions", addAttr(rv, "AdditionalOptions",
"/export:JNI_GetDefaultJavaVMInitArgs " + "/export:JNI_GetDefaultJavaVMInitArgs "
"/export:JNI_CreateJavaVM " + + "/export:JNI_CreateJavaVM "
"/export:JVM_FindClassFromBootLoader "+ + "/export:JVM_FindClassFromBootLoader "
"/export:JNI_GetCreatedJavaVMs "+ + "/export:JNI_GetCreatedJavaVMs "
"/export:jio_snprintf /export:jio_printf "+ + "/export:jio_snprintf /export:jio_printf "
"/export:jio_fprintf /export:jio_vfprintf "+ + "/export:jio_fprintf /export:jio_vfprintf "
"/export:jio_vsnprintf "+ + "/export:jio_vsnprintf "
"/export:JVM_GetVersionInfo "+ + "/export:JVM_GetVersionInfo "
"/export:JVM_GetThreadStateNames "+ + "/export:JVM_GetThreadStateNames "
"/export:JVM_GetThreadStateValues "+ + "/export:JVM_GetThreadStateValues "
"/export:JVM_InitAgentProperties "); + "/export:JVM_InitAgentProperties ");
addAttr(rv, "AdditionalDependencies", "Wsock32.lib winmm.lib"); addAttr(rv, "AdditionalDependencies", "Wsock32.lib winmm.lib");
addAttr(rv, "OutputFile", outDll); addAttr(rv, "OutputFile", outDll);
// Set /INCREMENTAL option. 1 is linkIncrementalNo // Set /INCREMENTAL option. 1 is linkIncrementalNo
addAttr(rv, "LinkIncremental", "1"); addAttr(rv, "LinkIncremental", "1");
addAttr(rv, "SuppressStartupBanner", "TRUE"); addAttr(rv, "SuppressStartupBanner", "TRUE");
addAttr(rv, "ModuleDefinitionFile", outDir+Util.sep+"vm.def"); addAttr(rv, "ModuleDefinitionFile", outDir + Util.sep + "vm.def");
addAttr(rv, "ProgramDatabaseFile", outDir+Util.sep+"jvm.pdb"); addAttr(rv, "ProgramDatabaseFile", outDir + Util.sep + "jvm.pdb");
// Set /SUBSYSTEM option. 2 is subSystemWindows // Set /SUBSYSTEM option. 2 is subSystemWindows
addAttr(rv, "SubSystem", "2"); addAttr(rv, "SubSystem", "2");
addAttr(rv, "BaseAddress", "0x8000000"); addAttr(rv, "BaseAddress", "0x8000000");
addAttr(rv, "ImportLibrary", outDir+Util.sep+"jvm.lib"); addAttr(rv, "ImportLibrary", outDir + Util.sep + "jvm.lib");
if(platformName.equals("Win32")) { if (platformName.equals("Win32")) {
// Set /MACHINE option. 1 is X86 // Set /MACHINE option. 1 is X86
addAttr(rv, "TargetMachine", "1"); addAttr(rv, "TargetMachine", "1");
} else { } else {
@ -699,7 +267,7 @@ class CompilerInterfaceVC7 extends CompilerInterface {
return rv; return rv;
} }
void getDebugCompilerFlags_common(String opt,Vector rv) { void getDebugCompilerFlags_common(String opt, Vector rv) {
// Set /On option // Set /On option
addAttr(rv, "Optimization", opt); addAttr(rv, "Optimization", opt);
@ -716,7 +284,7 @@ class CompilerInterfaceVC7 extends CompilerInterface {
Vector getDebugCompilerFlags(String opt) { Vector getDebugCompilerFlags(String opt) {
Vector rv = new Vector(); Vector rv = new Vector();
getDebugCompilerFlags_common(opt,rv); getDebugCompilerFlags_common(opt, rv);
return rv; return rv;
} }
@ -730,8 +298,7 @@ class CompilerInterfaceVC7 extends CompilerInterface {
} }
void getAdditionalNonKernelLinkerFlags(Vector rv) { void getAdditionalNonKernelLinkerFlags(Vector rv) {
extAttr(rv, "AdditionalOptions", extAttr(rv, "AdditionalOptions", "/export:AsyncGetCallTrace ");
"/export:AsyncGetCallTrace ");
} }
void getProductCompilerFlags_common(Vector rv) { void getProductCompilerFlags_common(Vector rv) {
@ -779,4 +346,5 @@ class CompilerInterfaceVC7 extends CompilerInterface {
String makeCfgName(String flavourBuild, String platform) { String makeCfgName(String flavourBuild, String platform) {
return flavourBuild + "|" + platform; return flavourBuild + "|" + platform;
} }
} }