src/share/tools/MakeDeps/Database.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6697238 Sdiff src/share/tools/MakeDeps

src/share/tools/MakeDeps/Database.java

Print this page




  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  *
  23  */
  24 
  25 import java.io.*;
  26 import java.util.*;
  27 
  28 public class Database {
  29   private MacroDefinitions macros;
  30   // allFiles is kept in lexicographically sorted order. See get().
  31   private FileList allFiles;
  32   // files that have implicit dependency on platform files
  33   // e.g. os.hpp: os_<os_family>.hpp os_<os_arch>.hpp but only
  34   // recorded if the platform file was seen.
  35   private FileList platformFiles;
  36   private FileList outerFiles;
  37   private FileList indivIncludes;
  38   private FileList grandInclude; // the results for the grand include file

  39   private long threshold;
  40   private int nOuterFiles;
  41   private int nPrecompiledFiles;
  42   private boolean missingOk;
  43   private Platform plat;
  44   /** These allow you to specify files not in the include database
  45     which are prepended and appended to the file list, allowing
  46     you to have well-known functions at the start and end of the
  47     text segment (allows us to find out in a portable fashion
  48     whether the current PC is in VM code or not upon a crash) */
  49   private String firstFile;
  50   private String lastFile;
  51 
  52   public Database(Platform plat, long t) {
  53     this.plat = plat;
  54     macros          = new MacroDefinitions();
  55     allFiles        = new FileList("allFiles", plat);
  56     platformFiles   = new FileList("platformFiles", plat);
  57     outerFiles      = new FileList("outerFiles", plat);
  58     indivIncludes   = new FileList("IndivIncludes", plat);
  59     grandInclude    = new FileList(plat.getGIFileTemplate().nameOfList(), plat);

  60 
  61     threshold = t;
  62     nOuterFiles = 0;
  63     nPrecompiledFiles = 0;
  64     missingOk = false;
  65     firstFile = null;
  66     lastFile = null;
  67   };
  68 
  69   public FileList getAllFiles() {
  70     return allFiles;
  71   }
  72 
  73   public Iterator getMacros() {
  74     return macros.getMacros();
  75   }
  76 
  77   public void canBeMissing() {
  78     missingOk = true;
  79   }


 192 
 193               for ( int i = 0; i < len - 1 ; i++ ) {
 194                 if (newIncluder_temp.charAt(i) == '_' && newIncluder_temp.charAt(i+1) == '.') {
 195                   count++;
 196                 } else {
 197                   newIncluder += newIncluder_temp.charAt(i);
 198                 }
 199               }
 200               newIncluder += newIncluder_temp.charAt(len-1);
 201 
 202               if (count != 1) {
 203                 throw new FileFormatException(
 204                     "Unexpected filename format for platform dependent file.\nline: \"" + line +
 205                     "\".\nError position: line " + lineNo
 206                     );
 207               }
 208 
 209               FileList p = allFiles.listForFile(includer);
 210               p.setPlatformDependentInclude(pdName.dirPreStemSuff());
 211 




 212               // Add an implicit dependency on platform
 213               // specific file for the generic file
 214 
 215               p = platformFiles.listForFile(newIncluder);
 216 
 217               // if this list is empty then this is 1st
 218               // occurance of a platform dependent file and
 219               // we need a new version of the include file.
 220               // Otherwise we just append to the current
 221               // file.
 222 
 223               PrintWriter pdFile =
 224                 new PrintWriter(
 225                     new FileWriter(pdName.dirPreStemSuff(),
 226                       !p.isEmpty())
 227                     );
 228               pdFile.println("# include \"" + includer + "\"");
 229               pdFile.close();
 230 
 231               // Add the platform specific file to the list


 391       gd.println();
 392     } else {
 393       // write Obj_Files = ...
 394       gd.println("Obj_Files = \\");
 395       for (Iterator iter = outerFiles.iterator(); iter.hasNext(); ) {
 396         FileList anOuterFile = (FileList) iter.next();
 397 
 398         String stemName = removeSuffixFrom(anOuterFile.getName());
 399         gd.println(stemName + plat.objFileSuffix() + " \\");
 400       }
 401       gd.println();
 402       gd.println();
 403     }
 404 
 405     if (nPrecompiledFiles > 0) {
 406       // write Precompiled_Files = ...
 407       gd.println("Precompiled_Files = \\");
 408       for (Iterator iter = grandInclude.iterator(); iter.hasNext(); ) {
 409         FileList list = (FileList) iter.next();
 410         gd.println(list.getName() + " \\");





 411       }

 412       gd.println();
 413       gd.println();
 414     }
 415 
 416     gd.println("DTraced_Files = \\");
 417     for (Iterator iter = outerFiles.iterator(); iter.hasNext(); ) {
 418       FileList anOuterFile = (FileList) iter.next();
 419 
 420       if (anOuterFile.hasListForFile("dtrace.hpp")) {
 421         String stemName = removeSuffixFrom(anOuterFile.getName());
 422         gd.println(stemName + plat.objFileSuffix() + " \\");
 423       }
 424     }
 425     gd.println();
 426     gd.println();
 427 
 428     {
 429       // write each dependency
 430 
 431       for (Iterator iter = indivIncludes.iterator(); iter.hasNext(); ) {




  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  *
  23  */
  24 
  25 import java.io.*;
  26 import java.util.*;
  27 
  28 public class Database {
  29   private MacroDefinitions macros;
  30   // allFiles is kept in lexicographically sorted order. See get().
  31   private FileList allFiles;
  32   // files that have implicit dependency on platform files
  33   // e.g. os.hpp: os_<os_family>.hpp os_<os_arch>.hpp but only
  34   // recorded if the platform file was seen.
  35   private FileList platformFiles;
  36   private FileList outerFiles;
  37   private FileList indivIncludes;
  38   private FileList grandInclude; // the results for the grand include file
  39   private HashMap<String,String> platformDepFiles;
  40   private long threshold;
  41   private int nOuterFiles;
  42   private int nPrecompiledFiles;
  43   private boolean missingOk;
  44   private Platform plat;
  45   /** These allow you to specify files not in the include database
  46     which are prepended and appended to the file list, allowing
  47     you to have well-known functions at the start and end of the
  48     text segment (allows us to find out in a portable fashion
  49     whether the current PC is in VM code or not upon a crash) */
  50   private String firstFile;
  51   private String lastFile;
  52 
  53   public Database(Platform plat, long t) {
  54     this.plat = plat;
  55     macros          = new MacroDefinitions();
  56     allFiles        = new FileList("allFiles", plat);
  57     platformFiles   = new FileList("platformFiles", plat);
  58     outerFiles      = new FileList("outerFiles", plat);
  59     indivIncludes   = new FileList("IndivIncludes", plat);
  60     grandInclude    = new FileList(plat.getGIFileTemplate().nameOfList(), plat);
  61     platformDepFiles = new HashMap<String,String>();
  62 
  63     threshold = t;
  64     nOuterFiles = 0;
  65     nPrecompiledFiles = 0;
  66     missingOk = false;
  67     firstFile = null;
  68     lastFile = null;
  69   };
  70 
  71   public FileList getAllFiles() {
  72     return allFiles;
  73   }
  74 
  75   public Iterator getMacros() {
  76     return macros.getMacros();
  77   }
  78 
  79   public void canBeMissing() {
  80     missingOk = true;
  81   }


 194 
 195               for ( int i = 0; i < len - 1 ; i++ ) {
 196                 if (newIncluder_temp.charAt(i) == '_' && newIncluder_temp.charAt(i+1) == '.') {
 197                   count++;
 198                 } else {
 199                   newIncluder += newIncluder_temp.charAt(i);
 200                 }
 201               }
 202               newIncluder += newIncluder_temp.charAt(len-1);
 203 
 204               if (count != 1) {
 205                 throw new FileFormatException(
 206                     "Unexpected filename format for platform dependent file.\nline: \"" + line +
 207                     "\".\nError position: line " + lineNo
 208                     );
 209               }
 210 
 211               FileList p = allFiles.listForFile(includer);
 212               p.setPlatformDependentInclude(pdName.dirPreStemSuff());
 213 
 214               // Record the implicit include of this file so that the
 215               // dependencies for precompiled headers can mention it.
 216               platformDepFiles.put(newIncluder, includer);
 217 
 218               // Add an implicit dependency on platform
 219               // specific file for the generic file
 220 
 221               p = platformFiles.listForFile(newIncluder);
 222 
 223               // if this list is empty then this is 1st
 224               // occurance of a platform dependent file and
 225               // we need a new version of the include file.
 226               // Otherwise we just append to the current
 227               // file.
 228 
 229               PrintWriter pdFile =
 230                 new PrintWriter(
 231                     new FileWriter(pdName.dirPreStemSuff(),
 232                       !p.isEmpty())
 233                     );
 234               pdFile.println("# include \"" + includer + "\"");
 235               pdFile.close();
 236 
 237               // Add the platform specific file to the list


 397       gd.println();
 398     } else {
 399       // write Obj_Files = ...
 400       gd.println("Obj_Files = \\");
 401       for (Iterator iter = outerFiles.iterator(); iter.hasNext(); ) {
 402         FileList anOuterFile = (FileList) iter.next();
 403 
 404         String stemName = removeSuffixFrom(anOuterFile.getName());
 405         gd.println(stemName + plat.objFileSuffix() + " \\");
 406       }
 407       gd.println();
 408       gd.println();
 409     }
 410 
 411     if (nPrecompiledFiles > 0) {
 412       // write Precompiled_Files = ...
 413       gd.println("Precompiled_Files = \\");
 414       for (Iterator iter = grandInclude.iterator(); iter.hasNext(); ) {
 415         FileList list = (FileList) iter.next();
 416         gd.println(list.getName() + " \\");
 417         String platformDep = platformDepFiles.get(list.getName());
 418         if (platformDep != null) {
 419             // make sure changes to the platform dependent file will
 420             // cause regeneration of the pch file.
 421             gd.println(platformDep + " \\");
 422         }
 423       }
 424       gd.println();
 425       gd.println();
 426     }
 427 
 428     gd.println("DTraced_Files = \\");
 429     for (Iterator iter = outerFiles.iterator(); iter.hasNext(); ) {
 430       FileList anOuterFile = (FileList) iter.next();
 431 
 432       if (anOuterFile.hasListForFile("dtrace.hpp")) {
 433         String stemName = removeSuffixFrom(anOuterFile.getName());
 434         gd.println(stemName + plat.objFileSuffix() + " \\");
 435       }
 436     }
 437     gd.println();
 438     gd.println();
 439 
 440     {
 441       // write each dependency
 442 
 443       for (Iterator iter = indivIncludes.iterator(); iter.hasNext(); ) {


src/share/tools/MakeDeps/Database.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File