implementing --version?
Meta via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Nov 21 16:41:42 PST 2016
On Monday, 21 November 2016 at 21:32:16 UTC, mab-on wrote:
> On Monday, 21 November 2016 at 20:56:41 UTC, Karabuta wrote:
>>
>> There is a package in the dub registry called commando
>> (https://code.dlang.org/packages/commando) for that.
>
> Hm.. maybe i explained it wrong.
> My problem is not to pass a argument to the application.
>
> What i want is a clever mechanism to store the SemVer (or
> Commit-ID) in the binary at compiletime - automatically.
> Otherwise i have to think to update a const in the code every
> time i build a new Version.
You could write a little script to generate an increasing version
and save it in a file. Then with Dub you can use a pre-build or
pre-generate command to call that script, and in your D code do
`enum version = import("version.txt");`. You can do whatever you
want with this text; process it, convert it to an internal data
structure, populate settings, etc.
I created a thread a little while ago that's somewhat on this
topic... It was partially about Dub pre-build and pre-generate
commands so you may find it useful.
http://forum.dlang.org/thread/mzipqtnimvexeddjtcju@forum.dlang.org
More information about the Digitalmars-d-learn
mailing list