aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2025-02-25 18:58:27 +0100
committerIain Buclaw <ibuclaw@gdcproject.org>2025-02-25 19:09:03 +0100
commitfffe14f045df597bf5ab50730eebe0977eea7090 (patch)
tree601467558ba75388e920bf852711f3d37f1b23a6
parentc17044e509824e5ed3de94c85a7a0dd71cfd9cc1 (diff)
downloadgcc-fffe14f045df597bf5ab50730eebe0977eea7090.zip
gcc-fffe14f045df597bf5ab50730eebe0977eea7090.tar.gz
gcc-fffe14f045df597bf5ab50730eebe0977eea7090.tar.bz2
libphobos: Add scripts to update Makefile.am after an upstream merge
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.
-rw-r--r--libphobos/libdruntime/Makefile.am2
-rw-r--r--libphobos/libdruntime/Makefile.in2
-rw-r--r--libphobos/scripts/.gitignore3
-rw-r--r--libphobos/scripts/README28
-rw-r--r--libphobos/scripts/gen_druntime_sources.d92
-rw-r--r--libphobos/scripts/gen_phobos_sources.d116
-rw-r--r--libphobos/src/Makefile.am2
-rw-r--r--libphobos/src/Makefile.in2
8 files changed, 243 insertions, 4 deletions
diff --git a/libphobos/libdruntime/Makefile.am b/libphobos/libdruntime/Makefile.am
index 8df0e1c..efdae4c 100644
--- a/libphobos/libdruntime/Makefile.am
+++ b/libphobos/libdruntime/Makefile.am
@@ -167,7 +167,7 @@ install-data-local:
done
# Source file definitions. Boring stuff, auto-generated with
-# https://gist.github.com/jpf91/8ad1dbc9902d6ad876313f134c6527d1
+# libphobos/scripts/gen_druntime_sources.d
# Can't use wildcards here:
# https://www.gnu.org/software/automake/manual/html_node/Wildcards.html
diff --git a/libphobos/libdruntime/Makefile.in b/libphobos/libdruntime/Makefile.in
index 999064e..1227c59 100644
--- a/libphobos/libdruntime/Makefile.in
+++ b/libphobos/libdruntime/Makefile.in
@@ -850,7 +850,7 @@ libgdruntime_convenience_la_DEPENDENCIES = $(libgdruntime_la_DEPENDENCIES)
libgdruntime_convenience_la_LINK = $(libgdruntime_la_LINK)
# Source file definitions. Boring stuff, auto-generated with
-# https://gist.github.com/jpf91/8ad1dbc9902d6ad876313f134c6527d1
+# libphobos/scripts/gen_druntime_sources.d
# Can't use wildcards here:
# https://www.gnu.org/software/automake/manual/html_node/Wildcards.html
DRUNTIME_CSOURCES = core/stdc/errno_.c etc/valgrind/valgrind_.c
diff --git a/libphobos/scripts/.gitignore b/libphobos/scripts/.gitignore
new file mode 100644
index 0000000..a5d300b
--- /dev/null
+++ b/libphobos/scripts/.gitignore
@@ -0,0 +1,3 @@
+# Dub leaves built programs in this directory.
+gen_druntime_sources
+gen_phobos_sources
diff --git a/libphobos/scripts/README b/libphobos/scripts/README
new file mode 100644
index 0000000..248324d
--- /dev/null
+++ b/libphobos/scripts/README
@@ -0,0 +1,28 @@
+The D language scripts in this directory are used during the syncing of
+libphobos with upstream. They can be built with the command:
+
+ dub build --single name-of-script.d
+
+Or when dub isn't available:
+
+ gdc -o name-of-script name-of-script.d [any other dependencies].d
+
+Scripts:
+
+gen_druntime_sources.d
+
+ Generates source file definitions for libphobos/libdruntime/Makefile.am.
+ Ran from the libdruntime directory and append output to Makefile.am.
+
+ Example:
+
+ cd libdruntime && ../scripts/gen_druntime_sources >> Makefile.am
+
+gen_phobos_sources.d
+
+ Generates source file definitions for libphobos/src/Makefile.am. Ran from
+ the libphobos/src directory and append output to Makefile.am.
+
+ Example:
+
+ cd src && ../scripts/gen_phobos_sources >> Makefile.am
diff --git a/libphobos/scripts/gen_druntime_sources.d b/libphobos/scripts/gen_druntime_sources.d
new file mode 100644
index 0000000..ee01477
--- /dev/null
+++ b/libphobos/scripts/gen_druntime_sources.d
@@ -0,0 +1,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();
+}
diff --git a/libphobos/scripts/gen_phobos_sources.d b/libphobos/scripts/gen_phobos_sources.d
new file mode 100644
index 0000000..661f5a9
--- /dev/null
+++ b/libphobos/scripts/gen_phobos_sources.d
@@ -0,0 +1,116 @@
+#!/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();
+}
diff --git a/libphobos/src/Makefile.am b/libphobos/src/Makefile.am
index 763ca3b..ec2bda6 100644
--- a/libphobos/src/Makefile.am
+++ b/libphobos/src/Makefile.am
@@ -78,7 +78,7 @@ install-data-local:
done
# Source file definitions. Boring stuff, auto-generated with
-# https://gist.github.com/jpf91/8744acebc9dcf1e9d1a35cdff20afbb2
+# libphobos/scripts/gen_phobos_sources.d
# Can't use wildcards here:
# https://www.gnu.org/software/automake/manual/html_node/Wildcards.html
if ENABLE_LIBDRUNTIME_ONLY
diff --git a/libphobos/src/Makefile.in b/libphobos/src/Makefile.in
index dcf6425..d1512b9 100644
--- a/libphobos/src/Makefile.in
+++ b/libphobos/src/Makefile.in
@@ -624,7 +624,7 @@ libgphobos_la_LINK = $(LIBTOOL) --tag=D $(libgphobos_la_LIBTOOLFLAGS) \
# Source file definitions. Boring stuff, auto-generated with
-# https://gist.github.com/jpf91/8744acebc9dcf1e9d1a35cdff20afbb2
+# libphobos/scripts/gen_phobos_sources.d
# Can't use wildcards here:
# https://www.gnu.org/software/automake/manual/html_node/Wildcards.html
@ENABLE_LIBDRUNTIME_ONLY_TRUE@PHOBOS_DSOURCES =