Add "built with D compiler version" to --version output.

This commit is contained in:
Johan Engelen 2016-03-21 14:10:15 +01:00
parent 60dde96177
commit febfcad3a2
4 changed files with 15 additions and 1 deletions

View file

@ -6,6 +6,8 @@
# D_COMPILER_FOUND - true if a D compiler was found
# D_COMPILER - D compiler
# D_COMPILER_FLAGS - D compiler flags (could be passed in the DMD environment variable)
# D_COMPILER_ID = {"DigitalMars", "LDMD", "LDC", "GDC"}
# D_COMPILER_VERSION_STRING - String containing the compiler version, e.g. "DMD64 D Compiler v2.070.2"
set(D_COMPILER_FOUND "FALSE")
@ -40,11 +42,19 @@ if (D_COMPILER)
elseif (__D_COMPILER_NAME STREQUAL "gdc")
set(D_COMPILER_ID "GDC")
endif()
# Older versions of ldmd do not have --version cmdline option, but the error message still contains the version info in the first line.
execute_process(COMMAND ${D_COMPILER} --version
OUTPUT_VARIABLE D_COMPILER_VERSION_STRING
ERROR_VARIABLE D_COMPILER_VERSION_STRING
ERROR_QUIET)
string(REGEX MATCH "^[^\r\n:]*" D_COMPILER_VERSION_STRING "${D_COMPILER_VERSION_STRING}")
endif()
if (D_COMPILER_FOUND)
message(STATUS "Found D compiler ${D_COMPILER}, with default flags '${D_COMPILER_FLAGS}'")
message(STATUS "D compiler version: ${D_COMPILER_VERSION_STRING}")
else()
message(FATAL_ERROR "Did not find D compiler! Try setting the 'DMD' environment variable.")
endif()

View file

@ -14,5 +14,6 @@ namespace ldc {
const char * const ldc_version = "@LDC_VERSION@";
const char * const dmd_version = "v@DMD_VERSION@";
const char * const llvm_version = "@LLVM_VERSION_STRING@";
const char * const built_with_Dcompiler_version = "@D_COMPILER_VERSION_STRING@";
}

View file

@ -15,6 +15,8 @@ namespace ldc {
extern const char *const ldc_version;
extern const char *const dmd_version;
extern const char *const llvm_version;
extern const char *const built_with_Dcompiler_version;
}
#endif

View file

@ -121,6 +121,7 @@ void printVersion() {
printf("LDC - the LLVM D compiler (%s):\n", global.ldc_version);
printf(" based on DMD %s and LLVM %s\n", global.version,
global.llvm_version);
printf(" built with %s\n", ldc::built_with_Dcompiler_version);
#if defined(__has_feature)
#if __has_feature(address_sanitizer)
printf(" compiled with address sanitizer enabled\n");