Specifying executable names in DUB
Jonathan M Davis
newsgroup.d at jmdavisprog.com
Tue Jun 18 05:26:48 UTC 2019
On Monday, June 17, 2019 8:13:46 PM MDT Dave via Digitalmars-d-learn wrote:
> Greetings,
>
> This might be totally obvious, but I can't seem to figure out how
> to specify an executable's name&path to be different for each
> build types in my DUB package. For example, if my project is
> named "dlang_test", I might want something like so:
>
> dub build --build=debug
>
> yields either
>
> bin/dlang_test-debug.exe
>
> or possibly
>
> bin/debug/dlang_test.exe
>
> if I did
>
> dub build --build=release
>
> I might get either
>
> bin/dlang_test-release.exe
>
> or
>
> bin/release/dlang_test.exe
>
> When I read the section on build types
> (https://dub.pm/package-format-json.html#build-types), it
> specifically mentions that a "buildTypes" entry can override the
> build settings, but *not* "targetName" and "targetPath", which is
> what I think I want here.
>
> Is there any reason why this is disallowed? Or is there a more
> canonical way of achieving this with DUB? What I described above
> is often found in other build tools, such as CMake and Visual
> Studio, which makes me think I'm missing something obvious here.
As I understand it, dub does not provide the ability to alter the target
name per build type. I don't know why, though if I had to guess, I would say
that it probably has to do with how it already renames the target based on
what is being generated and what the platform is (e.g. adding lib to the
front and either .a or .so to the end on *nix systems when a library is
being generated). However, it's probably possible to use the
postBuildCommands setting to run cp or mv or whatever to get the target name
you want for that particular configuration.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list