implementing --version?

Basile B. via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Nov 21 15:46:41 PST 2016


On Monday, 21 November 2016 at 21:32:16 UTC, mab-on wrote:
> 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.

     enum versionData = import("version.dat");
     enum min = anyCTFEFunctionThatParsesMin(versionData);
     enum maj = anyCTFEFunctionThatParsesMaj(versionData);
     // etc... you can even use compile-time regex...


The path to the file "version.dat" must be specified with the -J 
DMD command line.
Generating the file is another story, maybe a git script could do 
that.


More information about the Digitalmars-d-learn mailing list