Advertisement
Guest User

Untitled

a guest
Feb 26th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. import std.stdio, std.file, std.path, std.range, std.string, std.algorithm ;
  2.  
  3. string[] filterList = ["./test_runner.d", "./Makefile.in", "./gcc/config.d.in", "./gcc/libbacktrace.d.in", "./phobos-ver-syms.in",
  4. "./Makefile.am", "./LICENSE_1_0.txt", "./README.txt", "./rt/dylib_fixes.c"];
  5.  
  6. struct Files
  7. {
  8. string[] baseList, cppList, gcList, gcStubList;
  9. string[][string] sysList;
  10. }
  11.  
  12. void main(string[] args)
  13. {
  14. Files[string] fileMap;
  15.  
  16. foreach(entry; ".".dirEntries(SpanMode.depth).filter!(a => !filterList.canFind(a)))
  17. {
  18. if(entry.isFile)
  19. {
  20. auto ext = entry.extension.empty ? "" : entry.extension[1 .. $];
  21. if(!(ext in fileMap))
  22. fileMap[ext] = Files.init;
  23.  
  24. string sentry = entry[2 .. $];
  25.  
  26. if(entry.name.startsWith("./gc/"))
  27. fileMap[ext].gcList ~= sentry;
  28. else if(entry.name.startsWith("./gcstub/"))
  29. fileMap[ext].gcStubList ~= sentry;
  30. else if(entry.name.startsWith("./core/stdcpp/"))
  31. fileMap[ext].cppList ~= sentry;
  32. else if(entry.name.startsWith("./core/sys/"))
  33. {
  34. auto components = entry.pathSplitter;
  35. components.popFrontN(3);
  36. fileMap[ext].sysList[components.front] ~= sentry;
  37. }
  38. else
  39. fileMap[ext].baseList ~= sentry;
  40. }
  41. }
  42.  
  43. foreach(extEntry; fileMap.byKeyValue.array.sort!"a.key < b.key")
  44. {
  45. auto ext = extEntry.key;
  46. auto value = extEntry.value;
  47. writeList("DRUNTIME_" ~ ext.toUpper() ~ "SOURCES", value.baseList);
  48. writeList("DRUNTIME_" ~ ext.toUpper() ~ "SOURCES_STDCXX", value.cppList);
  49. writeList("DRUNTIME_" ~ ext.toUpper() ~ "SOURCES_GC", value.gcList);
  50. writeList("DRUNTIME_" ~ ext.toUpper() ~ "SOURCES_GCSTUB", value.gcStubList);
  51. foreach(entry; value.sysList.byKeyValue.array.sort!"a.key < b.key")
  52. {
  53. writeList("DRUNTIME_" ~ ext.toUpper() ~ "SOURCES_" ~ entry.key.toUpper(), entry.value);
  54. }
  55. }
  56. }
  57.  
  58. void writeList(string name, string[] values)
  59. {
  60. if(values.empty)
  61. return;
  62.  
  63. values = sort(values).array();
  64. writef("%s =", name);
  65. size_t line = name.length + 3;
  66. foreach(entry; values)
  67. {
  68. if(line + entry.length > 70)
  69. {
  70. line = 0;
  71. writeln(` \`);
  72. write('\t');
  73. }
  74. else
  75. write(" ");
  76. write(entry);
  77. line += entry.length + 1;
  78. }
  79. writeln();
  80. writeln();
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement