Include Git revision in version info.

CMakeLists.txt contains now the version numbers for DMD and (next) LDC release.
If a .git folder is found then the LDC version is replaced by the first 6 chars
of the Git revision.

Possible improvements:

- If the build is not done at the master branch then it could be useful to check for a tag and use the tag instead of the revision. (for release builds)
- Maybe it is useful to include the branch name.

This fixes issue #366.
This commit is contained in:
kai
2013-06-21 06:47:32 +02:00
parent 31d85d0910
commit aa143b560c
8 changed files with 219 additions and 7 deletions

View File

@@ -17,6 +17,7 @@
#include "dmd2/target.h"
#include "driver/cl_options.h"
#include "driver/configfile.h"
#include "driver/ldc-version.h"
#include "driver/linker.h"
#include "driver/target.h"
#include "driver/toobj.h"
@@ -86,7 +87,7 @@ static cl::list<std::string, StringsAdapter> debuglibs("debuglib",
void printVersion() {
printf("LDC - the LLVM D compiler (%s):\n", global.ldc_version);
printf(" based on DMD %s and %s\n", global.version, global.llvm_version);
printf(" based on DMD v%s and LLVM %s\n", global.version, global.llvm_version);
printf(" Default target: %s\n", llvm::sys::getDefaultTargetTriple().c_str());
std::string CPU = llvm::sys::getHostCPUName();
if (CPU == "generic") CPU = "(unknown)";
@@ -165,6 +166,9 @@ int main(int argc, char** argv)
int status = EXIT_SUCCESS;
global.init();
global.version = ldc::dmd_version;
global.ldc_version = ldc::ldc_version;
global.llvm_version = ldc::llvm_version;
// Set some default values
#if _WIN32