including arbitrary files into the binary
mandel
mandel at foobar.com
Sat Sep 8 10:24:27 PDT 2007
Using dmd-1.021 I use this to initialize an AA:
ubyte[][char[]] files;
static this()
{
files = [ cast(char[]) "data.txt" : cast(ubyte[]) import("data.txt") ];
}
Writing a program to generate a D code file is of course possible,
albeit not that elegant.
The only problem left is that I get an error starting my main program:
"object.Exception: Cyclic dependency in module Main"
because I have more that one static this in my application.
Walter Bright Wrote:
> Jarrett Billingsley wrote:
> > You could write a D program that does all this machination for you as a
> > build step or so. It could copy all the files to a directory, come up with
> > an AA, write out a .d file with the AA declaration and the imports, and then
> > compile that into an object, which you then link into your program.
>
>
> For the AA declaration you can use hex string literals for the binary data:
>
> x"00 0A FD EE"
>
> etc. They're easy for a simple D program to generate.
Nice to know, that would spare the process of copying
files around.
More information about the Digitalmars-d
mailing list