Get fils at compile-time
rikki cattermole via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Dec 14 23:52:07 PST 2016
On 15/12/2016 8:11 PM, Bauss wrote:
> On Thursday, 15 December 2016 at 02:58:11 UTC, rikki cattermole wrote:
>> I did a lot of work in this area.
>> There are two solutions:
>>
>> 1) Use a package file and public import all modules via it. From this
>> do some form of 'registration' in a module constructor. Using
>> __traits(allMembers, retrieve the imports and with that the other
>> modules.
>> 2) Before compilation create a file that contains a list of all the
>> module names.
>>
>> I prefer 2 now days.
>
> It's not D modules. I'm talking about loading dynamic file content from
> dynamically created files. The first one won't work, because it only
> imports modules and you still have to give DMD each module that you
> compile.
>
> The second one won't work either, because again the files are not D
> modules. They're regular files that I need to handle at compile-time.
>
> Besides your suggestion still requires manual work, which is what I need
> to avoid. I know how I can do it by specifying the files, but that's
> exactly what I want to avoid. I don't want to specify which files I need
> to handle, I just need to be able to handle all files in a folder
> without having to specify them somewhere after the creation.
The second will still work, that file that contains a list of modules
names can just as easily be a list of files to string import. Or is the
files themselves it is after all generated by an external program before
compilation.
An example of this would be bin2d (looks like I never bothered to
register it on code.dlang.org)[0].
[0] https://github.com/rikkimax/Bin2D
More information about the Digitalmars-d-learn
mailing list