dub icon indicating copy to clipboard operation
dub copied to clipboard

how to specify where to output library/executable?

Open timotheecour opened this issue 9 years ago • 10 comments

eg:

could there be options output_file and output_dir?

cd ~/.dub/packages/libdparse-master
dub build --compiler=ldc2 --output_file=libdparse.ldc.a
dub build --compiler=dmd --output_file=libdparse.dmd.a

or:

dub build --compiler=dmd --output_dir=./dmd_build => will build in ./dmd_build/libdparse.a

timotheecour avatar Jul 19 '16 22:07 timotheecour

You can specify in dub.sdl

targetPath "./dmd_build"

MrSmith33 avatar Jul 20 '16 12:07 MrSmith33

This works but requires manually editing the sdl file; Could those --targetPath --targetName be exposed in the command line?

This would be useful, eg, for automating building via dub with different configurations (ldc,dmd)

This is a common use case.

timotheecour avatar Jul 20 '16 21:07 timotheecour

Sounds like a good idea.

s-ludwig avatar Jul 27 '16 06:07 s-ludwig

Today I also stumbled over this issue. Use case: I want to create a Docker container which contains only D-Scanner executable. Therefore I use a multi stage Dockerfile. In first stage I fetch and build scanner and in second stage I copy the executable.

But the hard part is to get the path to the executable. Maybe it is somehow possible using dub describe with target-path and target-name ( the values are separated by a NUL character)

It is possible but for an inexperienced user it is unnecessary hard.

If I could set the executable path in dub build command this would be really elegant

andre2007 avatar Sep 03 '19 20:09 andre2007

Another use case from @adamdruppe https://forum.dlang.org/post/[email protected]

andre2007 avatar Dec 31 '19 14:12 andre2007

Yeah, this would be a big help to me. I tried to implement myself but couldn't follow the code flow... my attempt kept getting overwritten by later loading of the config file :(

adamdruppe avatar Dec 31 '19 14:12 adamdruppe

It just came to my mind, it isn't as easy as thought. A dub package can produce multiple outputs (by using dub sub packages and setting main package to type none). Should the new argument only support setting output path for main dub package or also for the sub packages?

andre2007 avatar Jan 01 '20 14:01 andre2007

On Wed, Jan 01, 2020 at 06:24:24AM -0800, andre2007 wrote:

Should the new argument only support setting output path for main dub package or also for the sub packages?

In my case, it is only the main package I want there.

Could perhaps be several separate options if we need the others to change too.

adamdruppe avatar Jan 01 '20 14:01 adamdruppe

I would like this as well.

redthing1 avatar Mar 23 '24 00:03 redthing1

Implemented that on redub, and here's what I've done:

The main requirement hash does not account anymore for the project name or the target path. But the project cache actually accounts for it, so it will be able to reuse all other already compiled packages.

Subpackages aren't important on that aspect, if someone wants them in the output path, they simply should use copyFiles. This serves at least for the main output path. I've also put targetName, which is a feature that I wished that existed on dub. It is important to rebuild the main project since, at least on windows, their target name is hardcoded inside the .pdb files, which makes it harder to use when you want to hotreload and want to get debug information

MrcSnm avatar Jul 31 '24 13:07 MrcSnm