Is there a way to adjust lookup paths for modules during compilation?

Andre Pany andre at s-e-a-p.de
Wed Jul 31 20:45:45 UTC 2019


On Wednesday, 31 July 2019 at 20:25:44 UTC, Ali Çehreli wrote:
> On 07/31/2019 10:29 AM, Andrey Zherikov wrote:
>> I want my program to add some directories into module lookup 
>> process (like adding -I dmd options). List of directories is 
>> known at compile time but the choice of what exact directories 
>> to add depends on `-version` parameter.
>> Is there a way to achieve this in code?
>> 
>> I can actually do this by creating scripts like 
>> 'build-version1', 'build-version2' but I'm looking for a way 
>> to avoid this.
>
> This seems to be a task for the build system: whatever is 
> setting the -version switch should set the -I switch as well.
>
> Ali

Yes, in dub you can create configurations for your dub project. 
Each configuration can define it's own versions and import paths. 
While executing dub, you would then pass the configuration to be 
build as command line arg: dub build -c myconfig1.
(First config is the default config)

https://dub.pm/package-format-json.html

Kind regards
Andre


More information about the Digitalmars-d-learn mailing list