DUB: Is it possible to set release as a default build for a dub package?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Sat Nov 4 20:14:23 UTC 2023


On Friday, November 3, 2023 1:21:42 PM MDT BoQsc via Digitalmars-d-learn 
wrote:
> While using `dub`, you might notice that after running `dub` or
> `dub run` command you will end up with notice:
>
> ```
> Starting Performing "debug" build using
> C:\D\dmd2\windows\bin64\dmd.exe for x86_64.
> ```
>
> Example output:
>
> ```
> C:\Users\Windows10\Documents\Dlang winsock\datatypes>dub
>       Pre-gen Running commands for datatypes
>               Public Domain. No rights reserved.
>      Starting Performing "debug" build using
> C:\D\dmd2\windows\bin64\dmd.exe for x86_64.
>      Building datatypes 0.0.0: building configuration [application]
>       Linking datatypes
>       Running builds/datatypes.exe
> ```
>
> **Question:** is it possible to set it to release build in a
> `dub.json` or `dub.sdl` file?
>
> Yes, it is possible using command line `dub --build=release`
>
> ```
> C:\Users\Windows10\Documents\Dlang winsock\datatypes>dub
> --build=release
>       Pre-gen Running commands for datatypes
>               Public Domain. No rights reserved.
>      Starting Performing "release" build using
> C:\D\dmd2\windows\bin64\dmd.exe for x86_64.
>      Building datatypes 0.0.0: building configuration [application]
>       Linking datatypes
>       Running builds/datatypes.exe
> ```
>
> However I would want to try to enforce this behaviour from the
> `dub.json` or `dub.sdl` file.

I would suggest that you just use a script to run the command that you want.

AFAIK, the only way to make "dub build" do anything different would be to
change the definition of the default build config in your project's dub.json
file, but that's going to be _very_ surprising to anyone else using your
project and might cause issues if it's a project that other projects end up
depending on.

- Jonathan M Davis





More information about the Digitalmars-d-learn mailing list