Loading

Paste #pxsi49hsl

  1. import std.stdio, std.file, std.path, std.range, std.string, std.algorithm ;
  2.  
  3. string[] filterList = ["./unittest.d"];
  4.  
  5. void main(string[] args)
  6. {
  7.     // File extension to search for
  8.     string ext = args[1];
  9.  
  10.     string[] baseList, gcList, gcStubList;
  11.     string[][string] sysList;
  12.     foreach(entry; ".".dirEntries(SpanMode.depth).filter!(a => !filterList.canFind(a)))
  13.     {
  14.         if(entry.isFile && entry.extension == "." ~ ext)
  15.         {
  16.             string sentry = entry[2 .. $];
  17.  
  18.             if(entry.name.startsWith("./gc/"))
  19.                 gcList ~= sentry;
  20.             else if(entry.name.startsWith("./gcstub/"))
  21.                 gcStubList ~= sentry;
  22.             else if(entry.name.startsWith("./core/sys/"))
  23.             {
  24.                 auto components = entry.pathSplitter;
  25.                 components.popFrontN(3);
  26.                 sysList[components.front] ~= sentry;
  27.             }
  28.             else
  29.                 baseList ~= sentry;
  30.         }
  31.     }
  32.  
  33.     writeList("DRUNTIME_" ~ ext.toUpper() ~ "SOURCES", baseList);
  34.     writeList("DRUNTIME_" ~ ext.toUpper() ~ "SOURCES_GC", gcList);
  35.     writeList("DRUNTIME_" ~ ext.toUpper() ~ "SOURCES_GCSTUB", gcStubList);
  36.     foreach(entry; sysList.byKeyValue)
  37.     {
  38.         writeList("DRUNTIME_" ~ ext.toUpper() ~ "SOURCES_" ~ entry.key.toUpper(), entry.value);
  39.     }
  40. }
  41.  
  42. void writeList(string name, string[] values)
  43. {
  44.     values = sort(values).array();
  45.     writef("%s = ", name);
  46.     size_t line = name.length + 3;
  47.     foreach(entry; values)
  48.     {
  49.         if(line > 80)
  50.         {
  51.             line = 0;
  52.             writeln(`\`);
  53.             write('\t');
  54.         }
  55.         writef("%s ", entry);
  56.         line += entry.length + 1;
  57.     }
  58.     writeln();
  59.     writeln();
  60. }