On 11/4/21 12:43 PM, Andrey Zherikov wrote:
I want to embed some info from build system - version info, for example. I can easily do this with C++ compiler by `-DVERSION="1.2.3"` but there is no such an option in dmd. So I'm wondering how do people workaround this? I see only one way: generate a file and add it to the build (file might be `.d` source or something included by import expression).

D doesn't have any equivalent for this. The closest you can get is to turn on `version` identifiers.

There is also a quirky `-version=123` which is IMO, a completely useless feature.

Your best bet is to do what you are doing -- generate a d file, and then include it.

Note, there is at least one dub package which does this for you: https://code.dlang.org/packages/gen-package-version

I use it in my build and it works OK. You just have to remember to attribute your tag in git.

-Steve

Reply via email to