mirror of
https://github.com/gcc-mirror/gcc.git
synced 2025-08-06 10:55:56 +00:00

These two scripts have been used for updating Makefile.am whenever there's been a file added/removed from either Druntime or Phobos since the start, but never included in the source tree. libphobos/ChangeLog: * libdruntime/Makefile.am: Update comment. * libdruntime/Makefile.in: Regenerate. * src/Makefile.am: Update comment. * src/Makefile.in: Regenerate. * scripts/.gitignore: New file. * scripts/README: New file. * scripts/gen_druntime_sources.d: New file. * scripts/gen_phobos_sources.d: New file.
117 lines
3.0 KiB
D
117 lines
3.0 KiB
D
#!/usr/bin/env dub
|
|
/++dub.sdl:
|
|
name "gen_phobos_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",
|
|
"./index.dd",
|
|
"./libgphobos.spec.in", "./drtstuff.spec",
|
|
"./LICENSE_1_0.txt", "./MERGE",
|
|
"./std/experimental/note.md"
|
|
];
|
|
|
|
struct Files
|
|
{
|
|
string[] baseList;
|
|
string[][string] sysList;
|
|
}
|
|
|
|
void main(string[] args)
|
|
{
|
|
Files[string] fileMap;
|
|
|
|
foreach (entry; "."
|
|
.dirEntries(SpanMode.depth)
|
|
.filter!(a => !filterList.canFind(a)))
|
|
{
|
|
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("./std/c/"))
|
|
{
|
|
if (entry.dirName == "./std/c")
|
|
{
|
|
fileMap[ext].sysList["stdc"] ~= sentry;
|
|
}
|
|
else
|
|
{
|
|
auto components = entry.pathSplitter;
|
|
components.popFrontN(3);
|
|
fileMap[ext].sysList[components.front] ~= sentry;
|
|
}
|
|
}
|
|
else
|
|
fileMap[ext].baseList ~= sentry;
|
|
}
|
|
}
|
|
|
|
writeln("if ENABLE_LIBDRUNTIME_ONLY");
|
|
foreach (extEntry; fileMap.byKeyValue.array.sort!"a.key < b.key")
|
|
{
|
|
auto ext = extEntry.key;
|
|
auto value = extEntry.value;
|
|
writeList("PHOBOS_" ~ ext.toUpper() ~ "SOURCES", [],
|
|
!value.baseList.empty);
|
|
foreach (entry; value.sysList.byKeyValue.array.sort!"a.key < b.key")
|
|
{
|
|
string name = "PHOBOS_" ~ ext.toUpper() ~ "SOURCES_"
|
|
~ entry.key.toUpper();
|
|
writeList(name, [], !entry.value.empty);
|
|
}
|
|
}
|
|
writeln();
|
|
writeln("else");
|
|
foreach (extEntry; fileMap.byKeyValue.array.sort!"a.key < b.key")
|
|
{
|
|
auto ext = extEntry.key;
|
|
auto value = extEntry.value;
|
|
writeList("PHOBOS_" ~ ext.toUpper() ~ "SOURCES", value.baseList);
|
|
foreach (entry; value.sysList.byKeyValue.array.sort!"a.key < b.key")
|
|
{
|
|
string name = "PHOBOS_" ~ ext.toUpper() ~ "SOURCES_"
|
|
~ entry.key.toUpper();
|
|
writeList(name, entry.value);
|
|
}
|
|
}
|
|
writeln();
|
|
writeln("endif");
|
|
}
|
|
|
|
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();
|
|
}
|