diff src/share/tools/ProjectCreator/BuildConfig.java @ 6948:e522a00b91aa

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
author Doug Simon <doug.simon@oracle.com>
date Mon, 12 Nov 2012 23:14:12 +0100
parents 33df1aeaebbf 1a9b9cfcef41
children b9a918201d47
line wrap: on
line diff
--- a/src/share/tools/ProjectCreator/BuildConfig.java	Mon Nov 12 18:11:17 2012 +0100
+++ b/src/share/tools/ProjectCreator/BuildConfig.java	Mon Nov 12 23:14:12 2012 +0100
@@ -22,15 +22,14 @@
  *
  */
 
-import java.io.File;
 import java.util.Enumeration;
 import java.util.Hashtable;
-import java.util.Iterator;
 import java.util.Vector;
 
 class BuildConfig {
+    @SuppressWarnings("rawtypes")
     Hashtable vars;
-    Vector basicNames, basicPaths;
+    Vector<String> basicNames, basicPaths;
     String[] context;
 
     static CompilerInterface ci;
@@ -47,6 +46,7 @@
         return ci;
     }
 
+    @SuppressWarnings("rawtypes")
     protected void initNames(String flavour, String build, String outDll) {
         if (vars == null) vars = new Hashtable();
 
@@ -63,6 +63,7 @@
         // 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;
         String value = System.getenv("OUT_DIR");
         if (value != null) {
@@ -88,20 +89,21 @@
         put("OutputDir", outDir);
         put("SourceBase", sourceBase);
         put("BuildBase", buildBase);
+        put("BuildSpace", buildSpace);
         put("OutputDll", outDir + Util.sep + outDll);
 
         context = new String [] {flavourBuild, flavour, build, null};
     }
 
-    protected void init(Vector includes, Vector defines) {
+    protected void init(Vector<String> includes, Vector<String> defines) {
         initDefaultDefines(defines);
         initDefaultCompilerFlags(includes);
         initDefaultLinkerFlags();
-        handleDB();
+        //handleDB();
     }
 
 
-    protected void initDefaultCompilerFlags(Vector includes) {
+    protected void initDefaultCompilerFlags(Vector<String> includes) {
         Vector compilerFlags = new Vector();
 
         compilerFlags.addAll(getCI().getBaseCompilerFlags(getV("Define"),
@@ -119,142 +121,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");
-        if (startAt != null) {
-            tree.readDirectory(sourceBase + File.separator + startAt);
-        } else {
-            tree.readDirectory(sourceBase);
-        }
-
-        return tree;
-    }
-
-
-    Vector getPreferredPaths() {
-        Vector preferredPaths = new Vector();
-
-        // In the case of multiple files with the same name in
-        // different subdirectories, prefer these versions
-        preferredPaths.add("windows");
-        preferredPaths.add("x86");
-        preferredPaths.add("closed");
-
-        // Also prefer "opto" over "adlc" for adlcVMDeps.hpp
-        preferredPaths.add("opto");
-
-        return preferredPaths;
-    }
-
-
-    void handleDB() {
-        WinGammaPlatform platform = (WinGammaPlatform)getField(null, "PlatformObject");
-
-        putSpecificField("AllFilesHash", computeAllFiles(platform));
-    }
-
-
-    private boolean matchesIgnoredPath(String prefixedName) {
-        Vector rv = new Vector();
+    public boolean matchesIgnoredPath(String path) {
+        Vector<String> rv = new Vector<String>();
         collectRelevantVectors(rv, "IgnorePath");
-        for (Iterator i = rv.iterator(); i.hasNext(); ) {
-            String pathPart = (String) i.next();
-            if (prefixedName.contains(Util.normalize(pathPart)))  {
+        for (String pathPart : rv) {
+            if (path.contains(pathPart))  {
                 return true;
             }
         }
         return false;
     }
 
-    void addAll(Iterator i, Hashtable hash,
-                WinGammaPlatform platform, DirectoryTree tree,
-                Vector preferredPaths, Vector filesNotFound, Vector filesDuplicate) {
-        for (; i.hasNext(); ) {
-            String fileName = (String) i.next();
-            if (lookupHashFieldInContext("IgnoreFile", fileName) == null) {
-                String prefixedName = platform.envVarPrefixedFileName(fileName,
-                                                                      0, /* ignored */
-                                                                      tree,
-                                                                      preferredPaths,
-                                                                      filesNotFound,
-                                                                      filesDuplicate);
-                if (prefixedName != null) {
-                    prefixedName = Util.normalize(prefixedName);
-                    if (!matchesIgnoredPath(prefixedName)) {
-                        addTo(hash, prefixedName, fileName);
-                    }
+    public boolean matchesHidePath(String path) {
+        Vector<String> rv = new Vector<String>();
+        collectRelevantVectors(rv, "HidePath");
+        for (String pathPart : rv) {
+            if (path.contains(Util.normalize(pathPart)))  {
+                return true;
+            }
+        }
+        return false;
+    }
+
+   public Vector<String> matchesAdditionalGeneratedPath(String fullPath) {
+        Vector<String> rv = new Vector<String>();
+        Hashtable<String, String> v = (Hashtable<String, String>)BuildConfig.getField(this.toString(), "AdditionalGeneratedFile");
+        if (v != null) {
+            for (Enumeration<String> e=v.keys(); e.hasMoreElements(); ) {
+                String key = e.nextElement();
+                String val = v.get(key);
+
+                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();
 
@@ -358,20 +266,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<String> v = getFieldVector(ctx, field);
             if (v != null) {
-                for (Iterator j=v.iterator(); j.hasNext(); ) {
-                    String val = (String)j.next();
-                    rv.add(expandFormat(val));
+                for (String val : v) {
+                    rv.add(expandFormat(val).replace('/', '\\'));
                 }
             }
         }
     }
 
     void collectRelevantHashes(Hashtable rv, String field) {
-        for (int i = 0; i < context.length; i++) {
-            Hashtable v = (Hashtable)getField(context[i], field);
+        for (String ctx : context) {
+            Hashtable v = (Hashtable)getField(ctx, field);
             if (v != null) {
                 for (Enumeration e=v.keys(); e.hasMoreElements(); ) {
                     String key = (String)e.nextElement();
@@ -391,21 +298,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<String> rv = new Vector<String>();
+        Vector<String> ri = new Vector<String>();
         String sourceBase = getFieldString(null, "SourceBase");
         collectRelevantVectors(ri, "RelativeInclude");
-        for (Iterator i = ri.iterator(); i.hasNext(); ) {
-            String f = (String)i.next();
+        for (String f : ri) {
             rv.add(sourceBase + Util.sep + f);
         }
         return rv;
@@ -663,7 +566,6 @@
     }
 }
 
-
 abstract class ProductConfig extends BuildConfig {
     protected void init(Vector includes, Vector defines) {
         defines.add("NDEBUG");
@@ -704,7 +606,6 @@
     }
 }
 
-
 class CoreDebugConfig extends GenericDebugNonKernelConfig {
     String getOptFlag() {
         return getCI().getNoOptFlag();
@@ -716,7 +617,6 @@
     }
 }
 
-
 class CoreFastDebugConfig extends GenericDebugNonKernelConfig {
     String getOptFlag() {
         return getCI().getOptFlag();
@@ -728,7 +628,6 @@
     }
 }
 
-
 class CoreProductConfig extends ProductConfig {
     CoreProductConfig() {
         initNames("core", "product", "jvm.dll");
@@ -766,6 +665,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);