--- old/make/windows/makefiles/projectcreator.make 2012-04-19 13:24:09.262587800 +0200 +++ new/make/windows/makefiles/projectcreator.make 2012-04-19 13:24:08.800561400 +0200 @@ -29,12 +29,11 @@ # HOTSPOTRELEASEBINDEST, or HOTSPOTDEBUGBINDEST environment variables. 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\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\WinGammaPlatformVC6.java \ $(WorkSpace)\src\share\tools\ProjectCreator\WinGammaPlatformVC7.java \ $(WorkSpace)\src\share\tools\ProjectCreator\WinGammaPlatformVC8.java \ $(WorkSpace)\src\share\tools\ProjectCreator\WinGammaPlatformVC9.java \ @@ -57,10 +56,24 @@ -relativeInclude src\os_cpu\windows_$(Platform_arch)\vm \ -relativeInclude src\cpu\$(Platform_arch)\vm \ -absoluteInclude $(HOTSPOTBUILDSPACE)/%f/generated \ - -ignorePath $(HOTSPOTBUILDSPACE)/%f/generated \ - -ignorePath src\share\vm\adlc \ - -ignorePath src\share\vm\shark \ - -ignorePath posix + -relativeSrcInclude src \ + -absoluteSrcInclude $(HOTSPOTBUILDSPACE) \ + -ignorePath $(HOTSPOTBUILDSPACE) \ + -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 ProjectCreatorOptions= @@ -84,6 +97,7 @@ $(ProjectCreatorIDEOptions) \ -sourceBase $(HOTSPOTWORKSPACE) \ -buildBase $(HOTSPOTBUILDSPACE)\%f\%b \ + -buildSpace $(HOTSPOTBUILDSPACE) \ -startAt src \ -compiler $(VcVersion) \ -projectFileName $(HOTSPOTBUILDSPACE)\$(ProjectFile) \ @@ -103,6 +117,7 @@ -define TARGET_OS_ARCH_windows_x86 \ -define TARGET_OS_FAMILY_windows \ -define TARGET_COMPILER_visCPP \ + -define INCLUDE_TRACE \ $(ProjectCreatorIncludesPRIVATE) # Add in build-specific options @@ -125,9 +140,13 @@ !endif ProjectCreatorIDEOptionsIgnoreCompiler1=\ + -ignorePath_TARGET compiler1 \ + -ignorePath_TARGET tiered \ -ignorePath_TARGET c1_ ProjectCreatorIDEOptionsIgnoreCompiler2=\ + -ignorePath_TARGET compiler2 \ + -ignorePath_TARGET tiered \ -ignorePath_TARGET src/share/vm/opto \ -ignorePath_TARGET src/share/vm/libadt \ -ignorePath_TARGET adfiles \ @@ -209,6 +228,7 @@ ################################################## ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \ -define_compiler1 COMPILER1 \ + -ignorePath_compiler1 core \ $(ProjectCreatorIDEOptionsIgnoreCompiler2:TARGET=compiler1) ################################################## @@ -217,18 +237,19 @@ #NOTE! This list must be kept in sync with GENERATED_NAMES in adlc.make. ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \ -define_compiler2 COMPILER2 \ + -ignorePath_compiler2 core \ -additionalFile_compiler2 $(Platform_arch_model).ad \ - -additionalGeneratedFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles ad_$(Platform_arch_model).cpp \ - -additionalGeneratedFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles ad_$(Platform_arch_model).hpp \ - -additionalGeneratedFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles ad_$(Platform_arch_model)_clone.cpp \ - -additionalGeneratedFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles ad_$(Platform_arch_model)_expand.cpp \ - -additionalGeneratedFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles ad_$(Platform_arch_model)_format.cpp \ - -additionalGeneratedFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles ad_$(Platform_arch_model)_gen.cpp \ - -additionalGeneratedFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles ad_$(Platform_arch_model)_misc.cpp \ - -additionalGeneratedFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles ad_$(Platform_arch_model)_peephole.cpp \ - -additionalGeneratedFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles ad_$(Platform_arch_model)_pipeline.cpp \ - -additionalGeneratedFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles adGlobals_$(Platform_arch_model).hpp \ - -additionalGeneratedFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles dfa_$(Platform_arch_model).cpp \ + -additionalFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles/ad_$(Platform_arch_model).cpp \ + -additionalFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles/ad_$(Platform_arch_model).hpp \ + -additionalFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles/ad_$(Platform_arch_model)_clone.cpp \ + -additionalFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles/ad_$(Platform_arch_model)_expand.cpp \ + -additionalFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles/ad_$(Platform_arch_model)_format.cpp \ + -additionalFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles/ad_$(Platform_arch_model)_gen.cpp \ + -additionalFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles/ad_$(Platform_arch_model)_misc.cpp \ + -additionalFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles/ad_$(Platform_arch_model)_peephole.cpp \ + -additionalFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles/ad_$(Platform_arch_model)_pipeline.cpp \ + -additionalFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles/adGlobals_$(Platform_arch_model).hpp \ + -additionalFile_compiler2 $(HOTSPOTBUILDSPACE)/%f/generated/adfiles/dfa_$(Platform_arch_model).cpp \ $(ProjectCreatorIDEOptionsIgnoreCompiler1:TARGET=compiler2) # Add in the jvmti (JSR-163) options @@ -237,8 +258,8 @@ # 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. ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \ - -additionalGeneratedFile $(HOTSPOTBUILDSPACE)/%f/generated/jvmtifiles jvmtiEnv.hpp \ - -additionalGeneratedFile $(HOTSPOTBUILDSPACE)/%f/generated/jvmtifiles jvmtiEnter.cpp \ - -additionalGeneratedFile $(HOTSPOTBUILDSPACE)/%f/generated/jvmtifiles jvmtiEnterTrace.cpp \ - -additionalGeneratedFile $(HOTSPOTBUILDSPACE)/%f/generated/jvmtifiles jvmti.h \ - -additionalGeneratedFile $(HOTSPOTBUILDSPACE)/%f/generated/jvmtifiles bytecodeInterpreterWithChecks.cpp + -additionalFile $(HOTSPOTBUILDSPACE)/%f/generated/jvmtifiles/jvmtiEnv.hpp \ + -additionalFile $(HOTSPOTBUILDSPACE)/%f/generated/jvmtifiles/jvmtiEnter.cpp \ + -additionalFile $(HOTSPOTBUILDSPACE)/%f/generated/jvmtifiles/jvmtiEnterTrace.cpp \ + -additionalFile $(HOTSPOTBUILDSPACE)/%f/generated/jvmtifiles/jvmti.h \ + -additionalFile $(HOTSPOTBUILDSPACE)/%f/generated/jvmtifiles/bytecodeInterpreterWithChecks.cpp --- old/src/share/tools/ProjectCreator/BuildConfig.java 2012-04-19 13:24:12.546775700 +0200 +++ new/src/share/tools/ProjectCreator/BuildConfig.java 2012-04-19 13:24:12.080749000 +0200 @@ -22,15 +22,14 @@ * */ -import java.io.File; import java.util.Enumeration; import java.util.Hashtable; -import java.util.Iterator; import java.util.Vector; class BuildConfig { - Hashtable vars; - Vector basicNames, basicPaths; + @SuppressWarnings("rawtypes") + Hashtable vars; + Vector basicNames, basicPaths; String[] context; static CompilerInterface ci; @@ -47,7 +46,8 @@ return ci; } - protected void initNames(String flavour, String build, String outDll) { + @SuppressWarnings("rawtypes") + protected void initNames(String flavour, String build, String outDll) { if (vars == null) vars = new Hashtable(); String flavourBuild = flavour + "_" + build; @@ -63,26 +63,28 @@ // ones mentioned above were needed to expand format String buildBase = expandFormat(getFieldString(null, "BuildBase")); String sourceBase = getFieldString(null, "SourceBase"); + String buildSpace = getFieldString(null, "BuildSpace"); String outDir = buildBase; put("Id", flavourBuild); put("OutputDir", outDir); put("SourceBase", sourceBase); put("BuildBase", buildBase); + put("BuildSpace", buildSpace); put("OutputDll", outDir + Util.sep + outDll); context = new String [] {flavourBuild, flavour, build, null}; } - protected void init(Vector includes, Vector defines) { + protected void init(Vector includes, Vector defines) { initDefaultDefines(defines); initDefaultCompilerFlags(includes); initDefaultLinkerFlags(); - handleDB(); + //handleDB(); } - protected void initDefaultCompilerFlags(Vector includes) { + protected void initDefaultCompilerFlags(Vector includes) { Vector compilerFlags = new Vector(); compilerFlags.addAll(getCI().getBaseCompilerFlags(getV("Define"), @@ -100,143 +102,48 @@ put("LinkerFlags", linkerFlags); } - DirectoryTree getSourceTree(String sourceBase, String startAt) { - DirectoryTree tree = new DirectoryTree(); - - tree.addSubdirToIgnore("Codemgr_wsdata"); - tree.addSubdirToIgnore("deleted_files"); - tree.addSubdirToIgnore("SCCS"); - tree.setVerbose(true); - if (startAt != null) { - tree.readDirectory(sourceBase + File.separator + startAt); - } else { - tree.readDirectory(sourceBase); + public boolean matchesIgnoredPath(String path) { + Vector rv = new Vector(); + collectRelevantVectors(rv, "IgnorePath"); + for (String pathPart : rv) { + if (path.contains(pathPart)) { + return true; + } } - - 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)); + return false; } - - - private boolean matchesIgnoredPath(String prefixedName) { - Vector rv = new Vector(); - collectRelevantVectors(rv, "IgnorePath"); - for (Iterator i = rv.iterator(); i.hasNext(); ) { - String pathPart = (String) i.next(); - if (prefixedName.contains(Util.normalize(pathPart))) { + + public boolean matchesHidePath(String path) { + Vector rv = new Vector(); + collectRelevantVectors(rv, "HidePath"); + for (String pathPart : rv) { + if (path.contains(Util.normalize(pathPart))) { return true; } } return false; } - - void addAll(Iterator i, Hashtable hash, - WinGammaPlatform platform, DirectoryTree tree, - Vector preferredPaths, Vector filesNotFound, Vector filesDuplicate) { - for (; i.hasNext(); ) { - String fileName = (String) i.next(); - if (lookupHashFieldInContext("IgnoreFile", fileName) == null) { - String prefixedName = platform.envVarPrefixedFileName(fileName, - 0, /* ignored */ - tree, - preferredPaths, - filesNotFound, - filesDuplicate); - if (prefixedName != null) { - prefixedName = Util.normalize(prefixedName); - if (!matchesIgnoredPath(prefixedName)) { - addTo(hash, prefixedName, fileName); - } - } + + public Vector matchesAdditionalGeneratedPath(String fullPath) { + Vector rv = new Vector(); + Hashtable v = (Hashtable)BuildConfig.getField(this.toString(), "AdditionalGeneratedFile"); + if (v != null) { + for (Enumeration 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) { 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) { Vector sysDefines = new Vector(); sysDefines.add("WIN32"); @@ -324,20 +231,19 @@ } void collectRelevantVectors(Vector rv, String field) { - for (int i = 0; i < context.length; i++) { - Vector v = getFieldVector(context[i], field); + for (String ctx : context) { + Vector v = getFieldVector(ctx, field); if (v != null) { - for (Iterator j=v.iterator(); j.hasNext(); ) { - String val = (String)j.next(); - rv.add(expandFormat(val)); + for (String val : v) { + rv.add(expandFormat(val).replace('/', '\\')); } } } } void collectRelevantHashes(Hashtable rv, String field) { - for (int i = 0; i < context.length; i++) { - Hashtable v = (Hashtable)getField(context[i], field); + for (String ctx : context) { + Hashtable v = (Hashtable)getField(ctx, field); if (v != null) { for (Enumeration e=v.keys(); e.hasMoreElements(); ) { String key = (String)e.nextElement(); @@ -357,21 +263,17 @@ Vector getIncludes() { Vector rv = new Vector(); - collectRelevantVectors(rv, "AbsoluteInclude"); - rv.addAll(getSourceIncludes()); - return rv; } private Vector getSourceIncludes() { - Vector rv = new Vector(); - Vector ri = new Vector(); + Vector rv = new Vector(); + Vector ri = new Vector(); String sourceBase = getFieldString(null, "SourceBase"); collectRelevantVectors(ri, "RelativeInclude"); - for (Iterator i = ri.iterator(); i.hasNext(); ) { - String f = (String)i.next(); + for (String f : ri) { rv.add(sourceBase + Util.sep + f); } return rv; @@ -604,7 +506,6 @@ } } - abstract class ProductConfig extends BuildConfig { protected void init(Vector includes, Vector defines) { defines.add("NDEBUG"); @@ -638,7 +539,7 @@ } } - +/* class CoreDebugConfig extends GenericDebugNonKernelConfig { String getOptFlag() { return getCI().getNoOptFlag(); @@ -650,7 +551,6 @@ } } - class CoreFastDebugConfig extends GenericDebugNonKernelConfig { String getOptFlag() { return getCI().getOptFlag(); @@ -662,13 +562,12 @@ } } - class CoreProductConfig extends ProductConfig { CoreProductConfig() { initNames("core", "product", "jvm.dll"); init(getIncludes(), getDefines()); } -} +}*/ class KernelDebugConfig extends GenericDebugConfig { String getOptFlag() { @@ -700,6 +599,7 @@ init(getIncludes(), getDefines()); } } + abstract class CompilerInterface { abstract Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir); abstract Vector getBaseLinkerFlags(String outDir, String outDll, String platformName); --- old/src/share/tools/ProjectCreator/ProjectCreator.java 2012-04-19 13:24:18.476114800 +0200 +++ new/src/share/tools/ProjectCreator/ProjectCreator.java 2012-04-19 13:24:17.862079700 +0200 @@ -24,75 +24,76 @@ public class ProjectCreator { - public static void usage() { - System.out.println("ProjectCreator options:"); - System.err.println("WinGammaPlatform platform-specific options:"); - System.err.println(" -sourceBase "); - System.err.println(" -dspFileName "); - System.err.println(" -envVar "); - System.err.println(" -dllLoc "); - System.err.println(" If any of the above are specified, "+ - "they must all be."); - System.err.println(" Additional, optional arguments, which can be " + - "specified multiple times:"); - System.err.println(" -absoluteInclude "); - System.err.println(" -relativeInclude "); - System.err.println(" -define "); - System.err.println(" -perFileLine "); - System.err.println(" -conditionalPerFileLine "); - System.err.println(" (NOTE: To work around a bug in nmake, where " + - "you can't have a '#' character in a quoted " + - "string, all of the lines outputted have \"#\"" + - "prepended)"); - System.err.println(" -startAt "); - System.err.println(" -ignoreFile "); - System.err.println(" -additionalFile "); - System.err.println(" -additionalGeneratedFile " + - ""); - System.err.println(" -prelink :"); - System.err.println(" Generate a set of prelink commands for the given BUILD"); - System.err.println(" (\"Debug\" or \"Release\"). The prelink description and commands"); - System.err.println(" are both quoted strings."); - System.err.println(" Default includes: \".\""); - System.err.println(" Default defines: WIN32, _WINDOWS, \"HOTSPOT_BUILD_USER=$(USERNAME)\""); - } - - public static void main(String[] args) { - try { - if (args.length < 3) { - usage(); - System.exit(1); - } - - String platformName = args[0]; - Class platformClass = Class.forName(platformName); - WinGammaPlatform platform = (WinGammaPlatform) platformClass.newInstance(); - - String[] platformArgs = new String[args.length - 1]; - System.arraycopy(args, 1, platformArgs, 0, platformArgs.length); - - // Allow the platform to write platform-specific files - platform.createVcproj(platformArgs); - } - catch (Exception e) { - e.printStackTrace(); - System.exit(1); - } - } + public static void usage() { + System.out.println("ProjectCreator options:"); + System.err.println("WinGammaPlatform platform-specific options:"); + System.err.println(" -sourceBase "); + System.err.println(" -dspFileName "); + System.err.println(" -envVar "); + System.err.println(" -dllLoc "); + System.err.println(" If any of the above are specified, " + + "they must all be."); + System.err.println(" Additional, optional arguments, which can be " + + "specified multiple times:"); + System.err.println(" -absoluteInclude "); + System.err.println(" -relativeInclude "); + System.err.println(" -define "); + System.err.println(" -perFileLine "); + System.err.println(" -conditionalPerFileLine "); + System.err.println(" (NOTE: To work around a bug in nmake, where " + + "you can't have a '#' character in a quoted " + + "string, all of the lines outputted have \"#\"" + "prepended)"); + System.err.println(" -startAt "); + System.err.println(" -ignoreFile "); + System.err.println(" -additionalFile "); + System.err + .println(" -additionalGeneratedFile " + + ""); + System.err.println(" -prelink :"); + System.err + .println(" Generate a set of prelink commands for the given BUILD"); + System.err + .println(" (\"Debug\" or \"Release\"). The prelink description and commands"); + System.err.println(" are both quoted strings."); + System.err.println(" Default includes: \".\""); + System.err + .println(" Default defines: WIN32, _WINDOWS, \"HOTSPOT_BUILD_USER=$(USERNAME)\""); + } + + public static void main(String[] args) { + try { + if (args.length < 3) { + usage(); + System.exit(1); + } + + String platformName = args[0]; + Class platformClass = Class.forName(platformName); + WinGammaPlatform platform = (WinGammaPlatform) platformClass + .newInstance(); + + String[] platformArgs = new String[args.length - 1]; + System.arraycopy(args, 1, platformArgs, 0, platformArgs.length); + + // Allow the platform to write platform-specific files + platform.createVcproj(platformArgs); + } catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } + } } --- old/src/share/tools/ProjectCreator/Util.java 2012-04-19 13:24:22.160325600 +0200 +++ new/src/share/tools/ProjectCreator/Util.java 2012-04-19 13:24:21.696299000 +0200 @@ -26,18 +26,19 @@ import java.io.File; public class Util { - static String join(String padder, Vector v) { + + static String join(String padder, Vector v) { return join(padder, v, false); } - static String join(String padder, Vector v, boolean quoted) { + static String join(String padder, Vector v, boolean quoted) { StringBuffer sb = new StringBuffer(); - for (Iterator iter = v.iterator(); iter.hasNext(); ) { + for (Iterator iter = v.iterator(); iter.hasNext(); ) { if (quoted) { sb.append('"'); } - sb.append((String)iter.next()); + sb.append(iter.next()); if (quoted) { sb.append('"'); } @@ -48,10 +49,10 @@ } - static String prefixed_join(String padder, Vector v, boolean quoted) { + static String prefixed_join(String padder, Vector v, boolean quoted) { StringBuffer sb = new StringBuffer(); - for (Iterator iter = v.iterator(); iter.hasNext(); ) { + for (Iterator iter = v.iterator(); iter.hasNext(); ) { sb.append(padder); if (quoted) { --- old/src/share/tools/ProjectCreator/WinGammaPlatform.java 2012-04-19 13:24:25.605522600 +0200 +++ new/src/share/tools/ProjectCreator/WinGammaPlatform.java 2012-04-19 13:24:25.147496400 +0200 @@ -25,11 +25,9 @@ import java.io.File; import java.io.IOException; import java.io.PrintWriter; -import java.util.Enumeration; import java.util.Hashtable; import java.util.Iterator; -import java.util.List; -import java.util.TreeSet; +import java.util.Stack; import java.util.Vector; abstract class HsArgHandler extends ArgHandler { @@ -196,7 +194,7 @@ protected static class PrelinkCommandData { String description; String commands; - } + } protected void addPrelinkCommand(Hashtable table, String build, @@ -215,71 +213,8 @@ } } - 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; - } + return false; + } String getProjectName(String fullPath, String extension) throws IllegalArgumentException, IOException { @@ -369,6 +304,9 @@ HsArgHandler.STRING ), + new HsArgRule("-buildSpace", "BuildSpace", null, + HsArgHandler.STRING), + new HsArgRule("-platformName", "PlatformName", null, @@ -405,6 +343,12 @@ HsArgHandler.VECTOR ), + new HsArgRule("-absoluteSrcInclude", "AbsoluteSrcInclude", + null, HsArgHandler.VECTOR), + + new HsArgRule("-relativeSrcInclude", "RelativeSrcInclude", + null, HsArgHandler.VECTOR), + new HsArgRule("-define", "Define", null, @@ -493,33 +437,18 @@ null, HsArgHandler.VECTOR ), + + new HsArgRule("-hidePath", + "IgnorePath", + null, + HsArgHandler.VECTOR + ), new HsArgRule("-additionalFile", "AdditionalFile", null, HsArgHandler.VECTOR ), - - new ArgRuleSpecific("-additionalGeneratedFile", - new HsArgHandler() { - public void handle(ArgIterator it) { - String cfg = getCfg(it.get()); - if (nextNotKey(it)) { - String dir = it.get(); - if (nextNotKey(it)) { - String fileName = it.get(); - BuildConfig.putFieldHash(cfg, "AdditionalGeneratedFile", - Util.normalize(dir + Util.sep + fileName), - fileName); - it.next(); - return; - } - } - empty(null, "** Error: wrong number of args to -additionalGeneratedFile"); - } - } - ), - new ArgRule("-prelink", new HsArgHandler() { public void handle(ArgIterator it) { @@ -598,9 +527,10 @@ allConfigs.add(new TieredFastDebugConfig()); allConfigs.add(new TieredProductConfig()); - allConfigs.add(new CoreDebugConfig()); - allConfigs.add(new CoreFastDebugConfig()); - allConfigs.add(new CoreProductConfig()); + // Removed for now, doesn't build and isn't tested + //allConfigs.add(new CoreDebugConfig()); + //allConfigs.add(new CoreFastDebugConfig()); + //allConfigs.add(new CoreProductConfig()); if (platform.equals("Win32")) { allConfigs.add(new KernelDebugConfig()); @@ -611,107 +541,99 @@ 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"); - } - } - + PrintWriter printWriter; - 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); - } + public void writeProjectFile(String projectFileName, String projectName, + Vector allConfigs) throws IOException { + throw new RuntimeException("use compiler version specific version"); + } + + int indent; + private Stack tagStack = new Stack(); + + 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) { } - } + } + } - return ht; - } + if (close) { + indent--; + printWriter.print(" />"); + } else { + 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(""); + } + + private void endTagNoIndent() { + String name = tagStack.pop(); + indent--; + printWriter.println(""); + } + + 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(" "); + } + } - Hashtable computeAttributedFiles(BuildConfig bc) { - Hashtable ht = new Hashtable(); - Hashtable confFiles = (Hashtable)bc.getSpecificField("AllFilesHash"); - - for (Enumeration e = confFiles.keys(); e.hasMoreElements(); ) { - String filePath = (String)e.nextElement(); - ht.put(filePath, new FileAttribute((String)confFiles.get(filePath), bc, 1)); - } - - return ht; - } - - PrintWriter printWriter; - - public void writeProjectFile(String projectFileName, String projectName, - Vector allConfigs) throws IOException { - throw new RuntimeException("use compiler version specific version"); - } } --- old/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java 2012-04-19 13:24:29.010717400 +0200 +++ new/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java 2012-04-19 13:24:28.528689800 +0200 @@ -3,14 +3,18 @@ import java.io.IOException; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; -import java.util.Hashtable; +import java.nio.file.FileSystems; import java.util.Iterator; -import java.util.TreeSet; +import java.util.LinkedList; import java.util.UUID; import java.util.Vector; public class WinGammaPlatformVC10 extends WinGammaPlatformVC7 { + + LinkedList filters = new LinkedList(); + LinkedList filterDeps = new LinkedList(); + @Override protected String getProjectExt() { return ".vcxproj"; @@ -37,15 +41,15 @@ "Include", cfg.get("Name")); tagData("Configuration", cfg.get("Id")); tagData("Platform", cfg.get("PlatformName")); - endTag("ProjectConfiguration"); + endTag(); } - endTag("ItemGroup"); + endTag(); startTag("PropertyGroup", "Label", "Globals"); tagData("ProjectGuid", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}"); tag("SccProjectName"); tag("SccLocalPath"); - endTag("PropertyGroup"); + endTag(); tag("Import", "Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props"); @@ -53,19 +57,19 @@ startTag(cfg, "PropertyGroup", "Label", "Configuration"); tagData("ConfigurationType", "DynamicLibrary"); tagData("UseOfMfc", "false"); - endTag("PropertyGroup"); + endTag(); } tag("Import", "Project", "$(VCTargetsPath)\\Microsoft.Cpp.props"); startTag("ImportGroup", "Label", "ExtensionSettings"); - endTag("ImportGroup"); + endTag(); for (BuildConfig cfg : allConfigs) { startTag(cfg, "ImportGroup", "Label", "PropertySheets"); tag("Import", "Project", "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props", "Condition", "exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')", "Label", "LocalAppDataPlatform"); - endTag("ImportGroup"); + endTag(); } tag("PropertyGroup", "Label", "UserMacros"); @@ -82,38 +86,38 @@ tag(cfg, "CodeAnalysisRules"); tag(cfg, "CodeAnalysisRuleAssemblies"); } - endTag("PropertyGroup"); + endTag(); for (BuildConfig cfg : allConfigs) { startTag(cfg, "ItemDefinitionGroup"); startTag("ClCompile"); tagV(cfg.getV("CompilerFlags")); - endTag("ClCompile"); + endTag(); startTag("Link"); tagV(cfg.getV("LinkerFlags")); - endTag("Link"); + endTag(); startTag("PostBuildEvent"); tagData("Message", BuildConfig.getFieldString(null, "PostbuildDescription")); tagData("Command", cfg.expandFormat(BuildConfig.getFieldString(null, "PostbuildCommand").replace("\t", "\r\n"))); - endTag("PostBuildEvent"); + endTag(); startTag("PreLinkEvent"); tagData("Message", BuildConfig.getFieldString(null, "PrelinkDescription")); tagData("Command", cfg.expandFormat(BuildConfig.getFieldString(null, "PrelinkCommand").replace("\t", "\r\n"))); - endTag("PreLinkEvent"); + endTag(); - endTag("ItemDefinitionGroup"); + endTag(); } writeFiles(allConfigs, projDir); tag("Import", "Project", "$(VCTargetsPath)\\Microsoft.Cpp.targets"); startTag("ImportGroup", "Label", "ExtensionTargets"); - endTag("ImportGroup"); + endTag(); - endTag("Project"); + endTag(); printWriter.close(); System.out.println(" Done."); @@ -138,14 +142,22 @@ for (BuildConfig cfg : allConfigs) { startTag(cfg, "PropertyGroup"); tagData("LocalDebuggerCommand", "$(TargetDir)/hotspot.exe"); - endTag("PropertyGroup"); + endTag(); } - endTag("Project"); + endTag(); printWriter.close(); System.out.println(" Done."); } - + + public void addFilter(String rPath) { + filters.add(rPath); + } + + public void addFilterDependency(String fileLoc, String filter) { + filterDeps.add(new String[] {fileLoc, filter}); + } + private void writeFilterFile(String projectFileName, String projectName, Vector allConfigs, String base) throws FileNotFoundException, UnsupportedEncodingException { String filterFileName = projectFileName + ".filters"; @@ -157,210 +169,92 @@ "ToolsVersion", "4.0", "xmlns", "http://schemas.microsoft.com/developer/msbuild/2003"); - Hashtable allFiles = computeAttributedFiles(allConfigs); - TreeSet sortedFiles = sortFiles(allFiles); - Vector filters = makeFilters(sortedFiles); - - // first all filters startTag("ItemGroup"); - for (NameFilter filter : filters) { - doWriteFilter(filter, ""); + for (String filter : filters) { + startTag("Filter", "Include",filter); + UUID uuid = UUID.randomUUID(); + tagData("UniqueIdentifier", "{" + uuid.toString() + "}"); + endTag(); } startTag("Filter", "Include", "Resource Files"); UUID uuid = UUID.randomUUID(); tagData("UniqueIdentifier", "{" + uuid.toString() + "}"); tagData("Extensions", "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"); - endTag("Filter"); - endTag("ItemGroup"); - - // then all cpp files + endTag(); + endTag(); + + //TODO - do I need to split cpp and hpp files? + + // then all files startTag("ItemGroup"); - for (NameFilter filter : filters) { - doWriteFiles(sortedFiles, filter, "", "ClCompile", new Evaluator() { - public boolean pick(FileInfo fi) { - return fi.isCpp(); - } - }, base); - } - endTag("ItemGroup"); - - // then all header files - startTag("ItemGroup"); - for (NameFilter filter : filters) { - doWriteFiles(sortedFiles, filter, "", "ClInclude", new Evaluator() { - public boolean pick(FileInfo fi) { - return fi.isHeader(); - } - }, base); - } - endTag("ItemGroup"); - - // then all other files - startTag("ItemGroup"); - for (NameFilter filter : filters) { - doWriteFiles(sortedFiles, filter, "", "None", new Evaluator() { - public boolean pick(FileInfo fi) { - return true; - } - }, base); - } - endTag("ItemGroup"); - - endTag("Project"); + for (String[] dep : filterDeps) { + String tagName = getFileTagFromSuffix(dep[0]); + + startTag(tagName, "Include", dep[0]); + tagData("Filter", dep[1]); + endTag(); + } + endTag(); + + endTag(); printWriter.close(); System.out.println(" Done."); } - - private void doWriteFilter(NameFilter filter, String start) { - startTag("Filter", "Include", start + filter.fname); - UUID uuid = UUID.randomUUID(); - tagData("UniqueIdentifier", "{" + uuid.toString() + "}"); - endTag("Filter"); - if (filter instanceof ContainerFilter) { - Iterator i = ((ContainerFilter)filter).babies(); - while (i.hasNext()) { - doWriteFilter((NameFilter)i.next(), start + filter.fname + "\\"); - } - } - } - - interface Evaluator { - boolean pick(FileInfo fi); - } - - private void doWriteFiles(TreeSet 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(); - } - } - } + public String getFileTagFromSuffix(String fileName) { + if (fileName.endsWith(".cpp")) { + return"ClCompile"; + } else if (fileName.endsWith(".c")) { + return "ClCompile"; + } else if (fileName.endsWith(".hpp")) { + return"ClInclude"; + } else if (fileName.endsWith(".h")) { + return "ClInclude"; + } else { + return"None"; + } } - void writeFiles(Vector allConfigs, String projDir) { - Hashtable allFiles = computeAttributedFiles(allConfigs); - TreeSet sortedFiles = sortFiles(allFiles); - - // first cpp-files - startTag("ItemGroup"); - for (FileInfo fi : sortedFiles) { - if (!fi.isCpp()) { - continue; - } - writeFile("ClCompile", allConfigs, fi, projDir); - } - endTag("ItemGroup"); - - // then header-files - startTag("ItemGroup"); - for (FileInfo fi : sortedFiles) { - if (!fi.isHeader()) { - continue; - } - writeFile("ClInclude", allConfigs, fi, projDir); - } - endTag("ItemGroup"); - - // then others - startTag("ItemGroup"); - for (FileInfo fi : sortedFiles) { - if (fi.isHeader() || fi.isCpp()) { - continue; - } - writeFile("None", allConfigs, fi, projDir); - } - endTag("ItemGroup"); - } - - /** - * Make "path" into a relative path using "base" as the base. - * - * path and base are assumed to be normalized with / as the file separator. - * returned path uses "\\" as file separator - */ - private String rel(String path, String base) - { - if(!base.endsWith("/")) { - base += "/"; - } - String[] pathTok = path.split("/"); - String[] baseTok = base.split("/"); - int pi = 0; - int bi = 0; - StringBuilder newPath = new StringBuilder(); - - // first step past all path components that are the same - while (pi < pathTok.length && - bi < baseTok.length && - pathTok[pi].equals(baseTok[bi])) { - pi++; - bi++; - } - - // for each path component left in base, add "../" - while (bi < baseTok.length) { - bi++; - newPath.append("..\\"); - } - - // 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 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); - } + // This code assummes there are no config specific includes. + startTag("ItemGroup"); + + String sourceBase = BuildConfig.getFieldString(null, "SourceBase"); + + // Use first config for all global absolute includes. + BuildConfig baseConfig = allConfigs.firstElement(); + Vector rv = new Vector(); + + // Then use first config for all relative includes + Vector ri = new Vector(); + baseConfig.collectRelevantVectors(ri, "RelativeSrcInclude"); + for (String f : ri) { + rv.add(sourceBase + Util.sep + f); + } + + baseConfig.collectRelevantVectors(rv, "AbsoluteSrcInclude"); + + handleIncludes(rv, allConfigs); + + endTag(); + } + + // Will visit file tree for each include + private void handleIncludes(Vector includes, Vector allConfigs) { + for (String path : includes) { + FileTreeCreatorVC10 ftc = new FileTreeCreatorVC10(FileSystems.getDefault().getPath(path) , allConfigs, this); + try { + ftc.writeFileTree(); + } catch (IOException e) { + e.printStackTrace(); + } + } } - + String buildCond(BuildConfig cfg) { return "'$(Configuration)|$(Platform)'=='"+cfg.get("Name")+"'"; } - void tagV(Vector v) { Iterator i = v.iterator(); while(i.hasNext()) { @@ -391,6 +285,7 @@ startTag(name, ss); } + } class CompilerInterfaceVC10 extends CompilerInterface { @@ -543,5 +438,4 @@ String makeCfgName(String flavourBuild, String platform) { return flavourBuild + "|" + platform; } - } --- old/src/share/tools/ProjectCreator/WinGammaPlatformVC7.java 2012-04-19 13:24:32.742930800 +0200 +++ new/src/share/tools/ProjectCreator/WinGammaPlatformVC7.java 2012-04-19 13:24:32.294905200 +0200 @@ -25,9 +25,7 @@ import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.TreeSet; +import java.nio.file.FileSystems; import java.util.Vector; public class WinGammaPlatformVC7 extends WinGammaPlatform { @@ -42,29 +40,25 @@ // write the .vcproj file printWriter = new PrintWriter(new FileWriter(projectFileName)); - printWriter.println(""); - startTag( - "VisualStudioProject", - new String[] { - "ProjectType", "Visual C++", - "Version", projectVersion(), - "Name", projectName, - "ProjectGUID", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}", - "SccProjectName", "", - "SccLocalPath", "" - } - ); - startTag("Platforms"); - tag("Platform", new String[] {"Name", (String) BuildConfig.getField(null, "PlatformName")}); - endTag("Platforms"); + printWriter + .println(""); + startTag("VisualStudioProject", new String[] { "ProjectType", + "Visual C++", "Version", projectVersion(), "Name", projectName, + "ProjectGUID", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}", + "SccProjectName", "", "SccLocalPath", "" }); + startTag("Platforms"); + tag("Platform", + new String[] { "Name", + (String) BuildConfig.getField(null, "PlatformName") }); + endTag(); startTag("Configurations"); - for (Iterator i = allConfigs.iterator(); i.hasNext(); ) { - writeConfiguration((BuildConfig)i.next()); - } + for (BuildConfig cfg : allConfigs) { + writeConfiguration(cfg); + } - endTag("Configurations"); + endTag(); tag("References"); @@ -72,550 +66,118 @@ tag("Globals"); - endTag("VisualStudioProject"); + endTag(); printWriter.close(); System.out.println(" Done."); } - - abstract class NameFilter { - protected String fname; - - abstract boolean match(FileInfo fi); - - String filterString() { return ""; } - String name() { return this.fname;} - - @Override - // eclipse auto-generated - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + getOuterType().hashCode(); - result = prime * result + ((fname == null) ? 0 : fname.hashCode()); - return result; - } - - @Override - // eclipse auto-generated - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - NameFilter other = (NameFilter) obj; - if (!getOuterType().equals(other.getOuterType())) - return false; - if (fname == null) { - if (other.fname != null) - return false; - } else if (!fname.equals(other.fname)) - return false; - return true; - } - - // eclipse auto-generated - private WinGammaPlatformVC7 getOuterType() { - return WinGammaPlatformVC7.this; - } - } - - class DirectoryFilter extends NameFilter { - String dir; - int baseLen, dirLen; - - DirectoryFilter(String dir, String sbase) { - this.dir = dir; - this.baseLen = sbase.length(); - this.dirLen = dir.length(); - this.fname = dir; - } - - DirectoryFilter(String fname, String dir, String sbase) { - this.dir = dir; - this.baseLen = sbase.length(); - this.dirLen = dir.length(); - this.fname = fname; - } - - - boolean match(FileInfo fi) { - int lastSlashIndex = fi.full.lastIndexOf('/'); - String fullDir = fi.full.substring(0, lastSlashIndex); - return fullDir.endsWith(dir); - } - - @Override - // eclipse auto-generated - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + getOuterType().hashCode(); - result = prime * result + baseLen; - result = prime * result + ((dir == null) ? 0 : dir.hashCode()); - result = prime * result + dirLen; - return result; - } - - @Override - // eclipse auto-generated - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - DirectoryFilter other = (DirectoryFilter) obj; - if (!getOuterType().equals(other.getOuterType())) - return false; - if (baseLen != other.baseLen) - return false; - if (dir == null) { - if (other.dir != null) - return false; - } else if (!dir.equals(other.dir)) - return false; - if (dirLen != other.dirLen) - return false; - return true; - } - - // eclipse auto-generated - private WinGammaPlatformVC7 getOuterType() { - return WinGammaPlatformVC7.this; - } - } - - class TerminatorFilter extends NameFilter { - TerminatorFilter(String fname) { - this.fname = fname; - - } - boolean match(FileInfo fi) { - return true; - } - - } - - class SpecificNameFilter extends NameFilter { - String pats[]; - - SpecificNameFilter(String fname, String[] pats) { - this.fname = fname; - this.pats = pats; - } - - boolean match(FileInfo fi) { - for (int i=0; i makeFilters(TreeSet files) { - Vector rv = new Vector(); - 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 allConfigs) { - - Hashtable allFiles = computeAttributedFiles(allConfigs); - - Vector allConfigNames = new Vector(); - for (Iterator i = allConfigs.iterator(); i.hasNext(); ) { - allConfigNames.add(((BuildConfig)i.next()).get("Name")); - } - - TreeSet sortedFiles = sortFiles(allFiles); - - startTag("Files"); - - for (Iterator i = makeFilters(sortedFiles).iterator(); i.hasNext(); ) { - doWriteFiles(sortedFiles, allConfigNames, (NameFilter)i.next()); - } - - - startTag("Filter", - new String[] { - "Name", "Resource Files", - "Filter", "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" - } - ); - endTag("Filter"); - - endTag("Files"); - } - - void doWriteFiles(TreeSet allFiles, Vector allConfigNames, NameFilter filter) { - startTag("Filter", - new String[] { - "Name", filter.name(), - "Filter", filter.filterString() - } - ); - - if (filter instanceof ContainerFilter) { - - Iterator i = ((ContainerFilter)filter).babies(); - while (i.hasNext()) { - doWriteFiles(allFiles, allConfigNames, (NameFilter)i.next()); - } - - } else { - - Iterator i = allFiles.iterator(); - while (i.hasNext()) { - FileInfo fi = (FileInfo)i.next(); - - if (!filter.match(fi)) { - continue; - } - - startTag("File", - new String[] { - "RelativePath", fi.full.replace('/', '\\') - } - ); - - FileAttribute a = fi.attr; - if (a.pchRoot) { - writeCustomToolConfig(allConfigNames, - new String[] { - "Name", "VCCLCompilerTool", - "UsePrecompiledHeader", "1" - }); - } - - if (a.noPch) { - writeCustomToolConfig(allConfigNames, - new String[] { - "Name", "VCCLCompilerTool", - "UsePrecompiledHeader", "0" - }); - } - - if (a.configs != null) { - for (Iterator j=allConfigNames.iterator(); j.hasNext();) { - String cfg = (String)j.next(); - if (!a.configs.contains(cfg)) { - startTag("FileConfiguration", - new String[] { - "Name", cfg, - "ExcludedFromBuild", "TRUE" - }); - endTag("FileConfiguration"); - - } - } - } - - endTag("File"); - - // we not gonna look at this file anymore - i.remove(); - } - } - - endTag("Filter"); - } - - - void writeConfiguration(BuildConfig cfg) { - startTag("Configuration", - new String[] { - "Name", cfg.get("Name"), - "OutputDirectory", cfg.get("OutputDir"), - "IntermediateDirectory", cfg.get("OutputDir"), - "ConfigurationType", "2", - "UseOfMFC", "0", - "ATLMinimizesCRunTimeLibraryUsage", "FALSE" - } - ); - - - - tagV("Tool", cfg.getV("CompilerFlags")); - - tag("Tool", - new String[] { - "Name", "VCCustomBuildTool" - } - ); - - tagV("Tool", cfg.getV("LinkerFlags")); - - tag("Tool", - new String[] { - "Name", "VCPostBuildEventTool", - "Description", BuildConfig.getFieldString(null, "PostbuildDescription"), - //Caution: String.replace(String,String) is available from JDK5 onwards only - "CommandLine", cfg.expandFormat(BuildConfig.getFieldString(null, "PostbuildCommand").replace - ("\t", " ")) - } - ); - - tag("Tool", - new String[] { - "Name", "VCPreBuildEventTool" - } - ); - - tag("Tool", - new String[] { - "Name", "VCPreLinkEventTool", - "Description", BuildConfig.getFieldString(null, "PrelinkDescription"), - //Caution: String.replace(String,String) is available from JDK5 onwards only - "CommandLine", cfg.expandFormat(BuildConfig.getFieldString(null, "PrelinkCommand").replace - ("\t", " ")) - } - ); - - tag("Tool", - new String[] { - "Name", "VCResourceCompilerTool", - // XXX??? - "PreprocessorDefinitions", "NDEBUG", - "Culture", "1033" - } - ); - - tag("Tool", - new String[] { - "Name", "VCMIDLTool", - "PreprocessorDefinitions", "NDEBUG", - "MkTypLibCompatible", "TRUE", - "SuppressStartupBanner", "TRUE", - "TargetEnvironment", "1", - "TypeLibraryName", cfg.get("OutputDir") + Util.sep + "vm.tlb", - "HeaderFileName", "" - } - ); - - endTag("Configuration"); - } - - int indent; - - private void startTagPrim(String name, - String[] attrs, - boolean close) { - startTagPrim(name, attrs, close, true); - } - - private void startTagPrim(String name, - String[] attrs, - boolean close, - boolean newline) { - doIndent(); - printWriter.print("<"+name); - indent++; - - if (attrs != null && attrs.length > 0) { - for (int i=0; i"); - } 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 configs, String[] customToolAttrs) { + for (BuildConfig cfg : configs) { + startTag("FileConfiguration", + new String[] { "Name", (String) cfg.get("Name") }); + tag("Tool", customToolAttrs); + + endTag(); + } + } + + void writeFiles(Vector allConfigs) { + + // This code assummes there are no config specific includes. + startTag("Files"); + String sourceBase = BuildConfig.getFieldString(null, "SourceBase"); + + // Use first config for all global absolute includes. + BuildConfig baseConfig = allConfigs.firstElement(); + Vector rv = new Vector(); + + // Then use first config for all relative includes + Vector ri = new Vector(); + baseConfig.collectRelevantVectors(ri, "RelativeSrcInclude"); + for (String f : ri) { + rv.add(sourceBase + Util.sep + f); + } + + baseConfig.collectRelevantVectors(rv, "AbsoluteSrcInclude"); + + handleIncludes(rv, allConfigs); + + startTag("Filter", new String[] { "Name", "Resource Files", "Filter", + "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" }); + endTag(); + + endTag(); + } + + // Will visit file tree for each include + private void handleIncludes(Vector includes, Vector allConfigs) { + for (String path : includes) { + FileTreeCreatorVC7 ftc = new FileTreeCreatorVC7(FileSystems.getDefault().getPath(path) , allConfigs, this); + try { + ftc.writeFileTree(); + } catch (IOException e) { + e.printStackTrace(); } - startTagPrim(name, s, false); - } + } + } - void endTag(String name) { - indent--; - doIndent(); - printWriter.println(""); - } - - 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(""); - } + void writeConfiguration(BuildConfig cfg) { + startTag("Configuration", new String[] { "Name", cfg.get("Name"), + "OutputDirectory", cfg.get("OutputDir"), + "IntermediateDirectory", cfg.get("OutputDir"), + "ConfigurationType", "2", "UseOfMFC", "0", + "ATLMinimizesCRunTimeLibraryUsage", "FALSE" }); + + tagV("Tool", cfg.getV("CompilerFlags")); + + tag("Tool", new String[] { "Name", "VCCustomBuildTool" }); + + tagV("Tool", cfg.getV("LinkerFlags")); + + tag("Tool", + new String[] { + "Name", + "VCPostBuildEventTool", + "Description", + BuildConfig + .getFieldString(null, "PostbuildDescription"), + // Caution: String.replace(String,String) is available + // from JDK5 onwards only + "CommandLine", + cfg.expandFormat(BuildConfig.getFieldString(null, + "PostbuildCommand").replace("\t", + " ")) }); + + tag("Tool", new String[] { "Name", "VCPreBuildEventTool" }); + + tag("Tool", + new String[] { + "Name", + "VCPreLinkEventTool", + "Description", + BuildConfig.getFieldString(null, "PrelinkDescription"), + // Caution: String.replace(String,String) is available + // from JDK5 onwards only + "CommandLine", + cfg.expandFormat(BuildConfig.getFieldString(null, + "PrelinkCommand").replace("\t", " ")) }); + + tag("Tool", new String[] { "Name", "VCResourceCompilerTool", + "PreprocessorDefinitions", "NDEBUG", "Culture", "1033" }); + + tag("Tool", new String[] { "Name", "VCMIDLTool", + "PreprocessorDefinitions", "NDEBUG", "MkTypLibCompatible", + "TRUE", "SuppressStartupBanner", "TRUE", "TargetEnvironment", + "1", "TypeLibraryName", + cfg.get("OutputDir") + Util.sep + "vm.tlb", "HeaderFileName", + "" }); - void tagData(String name, String data, String... attrs) { - startTagPrim(name, attrs, false, false); - printWriter.print(data); - printWriter.println(""); - indent--; - } + endTag(); + } - void tagV(String name, Vector attrs) { - String s[] = new String [attrs.size()]; - for (int i=0; i +{ + Path vcProjLocation; + Path startDir; + final int startDirLength; + Stack attributes = new Stack(); + Vector allConfigs; + WinGammaPlatformVC10 wg; + + public FileTreeCreator(Path startDir, Vector 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 ignores; + private HashSet disablePch; + + public DirAttributes() { + ignores = new HashSet(); + disablePch = new HashSet(); + } + + public DirAttributes(HashSet excludes2, HashSet disablePch2) { + ignores = excludes2; + disablePch = disablePch2; + } + + @SuppressWarnings("unchecked") + public DirAttributes clone() { + return new DirAttributes((HashSet)this.ignores.clone(), (HashSet)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); + } + + } +} --- /dev/null 2012-04-19 13:24:39.000000000 +0200 +++ new/src/share/tools/ProjectCreator/FileTreeCreatorVC10.java 2012-04-19 13:24:38.632267700 +0200 @@ -0,0 +1,141 @@ +import static java.nio.file.FileVisitResult.CONTINUE; + +import java.io.IOException; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.Vector; + +public class FileTreeCreatorVC10 extends FileTreeCreator { + + public FileTreeCreatorVC10(Path startDir, Vector 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(); + String fileLoc = vcProjLocation.relativize(file).toString(); + String fullPath = file.toAbsolutePath().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(fullPath)) { + useIgnore = true; + currentFileAttr.setIgnore(cfg); + } + + if (cfg.lookupHashFieldInContext("DisablePch", fileName) != null) { + disablePch = true; + currentFileAttr.setDisablePch(cfg); + } + + Vector rv = new Vector(); + cfg.collectRelevantVectors(rv, "AdditionalFile"); + for (String addFile : rv) { + if (addFile.equals(fullPath)) { + // supress any ignore + currentFileAttr.removeFromIgnored(cfg); + } + } + } + + String tagName = wg.getFileTagFromSuffix(fileName); + + 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); + } +} --- /dev/null 2012-04-19 13:24:42.000000000 +0200 +++ new/src/share/tools/ProjectCreator/FileTreeCreatorVC7.java 2012-04-19 13:24:41.584436600 +0200 @@ -0,0 +1,156 @@ +import static java.nio.file.FileVisitResult.CONTINUE; + +import java.io.IOException; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.Vector; + +public class FileTreeCreatorVC7 extends FileTreeCreator { + + public FileTreeCreatorVC7(Path startDir, Vector 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 rv = new Vector(); + 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); + } +} --- old/src/share/tools/ProjectCreator/DirectoryTree.java 2012-04-19 13:24:44.968630100 +0200 +++ /dev/null 2012-04-19 13:24:45.000000000 +0200 @@ -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); - } - } -} --- old/src/share/tools/ProjectCreator/DirectoryTreeNode.java 2012-04-19 13:24:46.890740100 +0200 +++ /dev/null 2012-04-19 13:24:47.000000000 +0200 @@ -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; -} --- old/src/share/tools/ProjectCreator/FileFormatException.java 2012-04-19 13:24:48.831851100 +0200 +++ /dev/null 2012-04-19 13:24:49.000000000 +0200 @@ -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); - } -} --- old/src/share/tools/ProjectCreator/WinGammaPlatformVC6.java 2012-04-19 13:24:50.721959200 +0200 +++ /dev/null 2012-04-19 13:24:50.000000000 +0200 @@ -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; - } -}