Set output location for dub --single

Chris Piker chris at
Sun Feb 27 16:58:34 UTC 2022

Hi D

Coming from a python background it's worked well to organize my D 
projects as a dub `sourceLibrary` and then to put top level 
programs in a directory named `scripts` that are just dub single 
file projects.  So the layout looks like this:

   +- mypackage/
   |    |
   |    +- libfile1.d
   |    +- libfile2.d
   +- scripts/
   |    |
   |    +- prog1.d
   |    +- prog2.d
   +- dub.json
In dub.json "scripts" are ignored via 
`"excludedSourceFiles":["scripts/*"]`.  Each "script" includes 
`mypackage` via:
#!/usr/bin/env dub
/+ dub.sdl:
    dependency "mypackage" version="*" path=".."
    dependency (other nonlocal packages)

...and all seems rather familiar to a python programmer and I 
avoid the complexities of dub sub-projects.

For building the individual "scripts" as binaries, it be nice 
output the binaries to another directory, say `bin`.  Is there an 
override for the dub command line that would specify the output 
location?  Maybe something like:
dub --single -o targetPath=./bin ./script/prog1.d
(Here the mythical argument `-o` overrides a single build 
configuration setting.)

After reading over the dub documentation I don't see a general 
way to override project options via the command line, but maybe 
it's there and I couldn't understand what the dub docs were 
trying to say.

More information about the Digitalmars-d-learn mailing list