New build.d

This commit is contained in:
edmccard 2012-04-24 10:11:16 -04:00
parent bf117ac730
commit 9f8f73f530
3 changed files with 73 additions and 1 deletions

View File

@ -16,6 +16,12 @@ Build by running `make` in the `src` directory; if the dependencies aren't insta
make GTKD=/path/to/gtkd DERELICT=/path/to/Derelict2
```
Alternatively, you can run `build.d` from the `src` directory:
```
cd src
rdmd build.d --gtkd=/path/to/gtkd --derelict=/path/to/Derelict2
```
### Testing
There are tests for the 6502/65C02 emulation:

View File

@ -7,7 +7,7 @@ LINK_OPTS = -L-lpthread -L-lGL -L-ldl -L-lX11 \
-L-L$(GTKD) -L-lgtkd -L-lgtkdgl \
-L-L$(DERELICT)/lib -L-lDerelictSDL -L-lDerelictUtil
ALL_SRC = $(shell find -name "*.d" \! -name "ctfe*")
ALL_SRC = $(shell find -name "*.d" \! -name "ctfe*" \! -name "build.d")
all: ${ALL_SRC}
dmd $(COMPILE_OPTS) ${ALL_SRC} -oftwoapple ${LINK_OPTS}

66
src/build.d Normal file
View File

@ -0,0 +1,66 @@
import std.algorithm, std.array, std.exception, std.getopt, std.process,
std.stdio;
string GTKD = "";
string DERELICT = "";
version(GNU)
string OPMODE = " -version=OpSwitch ";
else version(DigitalMars)
string OPMODE = " -version=OpNestedSwitch ";
else
static assert(0, "Unsupported compiler");
bool notGTKD(string a)
{
return indexOf(a, GTKD) == -1;
}
bool compilable(string a)
{
return endsWith(a, ".d") && indexOf(a, "ctfe") == -1;
}
int main(string[] args)
{
getopt(
args,
"gtkd", &GTKD,
"derelict", &DERELICT);
string opts = "-Jdata " ~ OPMODE;
if (GTKD.length)
opts ~= " -I" ~ GTKD ~ "/src -I" ~ GTKD ~ "/srcgl ";
if (DERELICT.length)
opts ~= " -I" ~ DERELICT ~ "/import ";
try
{
auto deps = split(shell("rdmd --makedepend " ~ opts ~ " twoapple.d"));
auto d_files = array(filter!compilable(deps));
auto without_gtkd = array(filter!notGTKD(d_files));
opts = " -inline -release -O -noboundscheck " ~ opts ~
" -d -L-lGL -L-ldl -L-lX11 " ~
" -L-L" ~ DERELICT ~ "/lib -L-lDerelictSDL -L-lDerelictUtil ";
version(DigitalMars)
{
if (GTKD.length)
opts ~= " -L-L" ~ GTKD ~ " -L-lgtkd -L-lgtkdgl ";
auto files = join(without_gtkd, " ");
return system("dmd " ~ opts ~ " " ~ files);
}
else version(GNU)
{
auto files = join(d_files, " ");
return system("gdmd " ~ opts ~ " " ~ files);
}
}
catch (ErrnoException e)
{
return 1;
}
return 0;
}