1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#!/usr/bin/env dub
/++dub.sdl:
name "gen_druntime_sources"
+/
// Written in the D programming language.
import std.stdio;
import std.file;
import std.path;
import std.range;
import std.string;
import std.algorithm;
string[] filterList = [
"./Makefile.in", "./Makefile.am",
"./gcc/config.d.in", "./gcc/libbacktrace.d.in", "./gcc/drtstuff.c",
"./LICENSE.txt", "./MERGE",
"./rt/dylib_fixes.c"
];
struct Files
{
string[] baseList, cppList;
string[][string] sysList;
}
void main(string[] args)
{
Files[string] fileMap;
foreach(entry; ".".dirEntries(SpanMode.depth).filter!(a => !filterList.canFind(a)))
{
if (entry.name.startsWith("./config/"))
continue;
if(entry.isFile)
{
auto ext = entry.extension.empty ? "" : entry.extension[1 .. $];
if(!(ext in fileMap))
fileMap[ext] = Files.init;
string sentry = entry[2 .. $];
if(entry.name.startsWith("./core/stdcpp/"))
fileMap[ext].cppList ~= sentry;
else if(entry.name.startsWith("./core/sys/"))
{
auto components = entry.pathSplitter;
components.popFrontN(3);
fileMap[ext].sysList[components.front] ~= sentry;
}
else
fileMap[ext].baseList ~= sentry;
}
}
foreach(extEntry; fileMap.byKeyValue.array.sort!"a.key < b.key")
{
auto ext = extEntry.key;
auto value = extEntry.value;
writeList("DRUNTIME_" ~ ext.toUpper() ~ "SOURCES", value.baseList);
writeList("DRUNTIME_" ~ ext.toUpper() ~ "SOURCES_STDCXX", value.cppList);
foreach(entry; value.sysList.byKeyValue.array.sort!"a.key < b.key")
{
writeList("DRUNTIME_" ~ ext.toUpper() ~ "SOURCES_" ~ entry.key.toUpper(), entry.value);
}
}
}
void writeList(string name, string[] values, bool force = false)
{
if (!force && values.empty)
return;
values = sort(values).array();
writeln();
writef("%s =", name);
size_t line = name.length + 3;
foreach(entry; values)
{
if(line + entry.length > 70)
{
line = 0;
writeln(` \`);
write('\t');
}
else
write(" ");
write(entry);
line += entry.length + 1;
}
writeln();
}
|