GtkD: Build script
Johnson Jones via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Aug 20 11:17:43 PDT 2017
I've modified the build script:
changed 2 things: 1. Builds for all archs. 2. Replaced the
specialized x86 build with the generic used for 64-bit. You were
building for each individual directory for some reason, I guess
for more granularity, but it produced a different result than the
64 build because it left out the root gtk dir, when I put some
package files in to help make it easier to deal with all the
modules.
It might be better to put the libs in their own unique
directories. I was just tired of having to build for each version
so I simplified it. Probably could use some output mentioning
what is going on, although it works well, so maybe not.
I assume for 2 you just did that for more control? The lib file
was quite a bit larger(I think it went from 30 megs to 50 or
something).
Maybe a script such as this could be added and called buildAll.
module Build;
import core.stdc.stdlib: exit;
import std.algorithm;
import std.array;
import std.file;
import std.getopt;
import std.path;
import std.process;
import std.stdio;
import std.string;
string dcflags;
string ldflags;
int main(string[] args)
{
version(Posix)
{
writeln("This build script is currently Windows only.");
return(1);
}
getopt(args, "dcflags", &dcflags, "ldflags", &ldflags);
args.popFront();
foreach ( arg; args )
{
if ( !["gtkd", "gtkdgl", "sv", "gstreamer", "vte", "peas",
"all"].canFind(arg) )
{
writefln("Unknown option: %s", arg);
return 1;
}
}
if ( args.length == 0 )
args = ["gtkd", "sv"];
if ( args.canFind("all") )
args = ["gtkd", "sv", "gstreamer", "peas"];
foreach ( arg; args )
{
switch ( arg )
{
case "gtkd":
build("generated\\gtkd", "gtkd");
break;
case "gtkdgl":
build("generated\\gtkdgl", "gtkdgl");
break;
case "sv":
build("generated\\sourceview", "gtkdsv");
break;
case "gstreamer":
build("generated\\gstreamer", "gstreamerd");
break;
case "peas":
build("generated\\peas", "peasd");
break;
default:
assert(false);
break;
}
}
return(0);
}
void build(string dir, string lib)
{
import std.algorithm;
foreach(i; [0,1,2])
switch(i)
{
// 64bit
case 1:
std.file.write("build.rf", format("-m64 -c -lib %s %s
-Igenerated/gtkd -of%sx64.lib %s ", dcflags, ldflags, lib,
dFiles(dir)));
auto pid = spawnProcess(["dmd", "@build.rf"]);
if ( wait(pid) != 0 ) exit(1);
break;
default: goto case 0;
case 0:
std.file.write("build.rf", format("-m32 -c -lib %s %s
-Igenerated/gtkd -of%sx86.lib %s ", dcflags, ldflags, lib,
dFiles(dir)));
auto pid = spawnProcess(["dmd", "@build.rf"]);
if ( wait(pid) != 0 ) exit(1);
break;
case 2:
std.file.write("build.rf", format("-m32mscoff -c -lib %s %s
-Igenerated/gtkd -of%sx86coff.lib %s", dcflags, ldflags, lib,
dFiles(dir)));
auto pid = spawnProcess(["dmd", "@build.rf"]);
if ( wait(pid) != 0 ) exit(1);
break;
}
std.file.remove("build.rf");
}
string dFiles(string sourceDir)
{
string files;
auto entries = dirEntries(sourceDir, SpanMode.breadth);
foreach ( DirEntry entry; entries )
{
if ( entry.isDir == false && entry.name.extension == ".d" )
{
files ~= entry.name ~ " ";
}
}
return files;
}
More information about the Digitalmars-d-learn
mailing list