digitalmars.D.learn - Set output location for dub --single
- Chris Piker (46/46) Feb 27 2022 Hi D
- Basile B. (10/20) Feb 28 2022 That 's not exactly what you ask for but you can define the path
- Chris Piker (6/15) Feb 28 2022 Hey thanks! Not perfect, but it'll probably work.
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:
```
rootdir/
   |
   +- 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:
```d
/+ 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:
```bash
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.
 Feb 27 2022
On Sunday, 27 February 2022 at 16:58:34 UTC, Chris Piker wrote: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: [...] 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.That 's not exactly what you ask for but you can define the path in the embedded recipe (targetPath) ```d /+ dub.sdl: dependency "mypackage" version="*" path=".." targetPath "./bin" +/ ```
 Feb 28 2022
On Monday, 28 February 2022 at 08:03:24 UTC, Basile B. wrote:
 That 's not exactly what you ask for but you can define the 
 path in the embedded recipe (targetPath)
 ```d
 /+ dub.sdl:
    dependency "mypackage" version="*" path=".."
    targetPath "./bin"
 +/
 ```
Hey thanks!  Not perfect, but it'll probably work.
I'll bring up the idea of overriding some settings (such as 
targetPath) on the command line in a similar manner to ssh in the 
dub [discussions](https://github.com/dlang/dub/discussions) area 
and see how well that goes over.
 Feb 28 2022








 
  
  
  Chris Piker <chris hoopjump.com>
 Chris Piker <chris hoopjump.com>