mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
Version: detect compiler and compile time
This commit is contained in:
@@ -20,6 +20,9 @@
|
||||
#define FF_ARCHITECTURE "unknown"
|
||||
#endif
|
||||
|
||||
#define FF_STR_INDIR(x) #x
|
||||
#define FF_STR(x) FF_STR_INDIR(x)
|
||||
|
||||
void ffDetectVersion(FFVersionResult* version)
|
||||
{
|
||||
version->projectName = FASTFETCH_PROJECT_NAME;
|
||||
@@ -27,6 +30,16 @@ void ffDetectVersion(FFVersionResult* version)
|
||||
version->version = FASTFETCH_PROJECT_VERSION;
|
||||
version->versionTweak = FASTFETCH_PROJECT_VERSION_TWEAK;
|
||||
version->cmakeBuiltType = FASTFETCH_PROJECT_CMAKE_BUILD_TYPE;
|
||||
version->compileTime = __DATE__ ", " __TIME__;
|
||||
#ifdef __clang__
|
||||
version->compiler = "clang " FF_STR(__clang_major__) "." FF_STR(__clang_minor__) "." FF_STR(__clang_patchlevel__);
|
||||
#elif defined(__GNUC__)
|
||||
version->compiler = "gcc " FF_STR(__GNUC__) "." FF_STR(__GNUC_MINOR__) "." FF_STR(__GNUC_PATCHLEVEL__);
|
||||
#elif defined(_MSC_VER)
|
||||
version->compiler = "msvc " FF_STR(_MSC_VER);
|
||||
#else
|
||||
version->compiler = "unknown";
|
||||
#endif
|
||||
#ifndef NDEBUG
|
||||
version->debugMode = true;
|
||||
#else
|
||||
|
||||
@@ -12,6 +12,8 @@ typedef struct FFVersionResult
|
||||
const char* version;
|
||||
const char* versionTweak;
|
||||
const char* cmakeBuiltType;
|
||||
const char* compileTime;
|
||||
const char* compiler;
|
||||
bool debugMode;
|
||||
} FFVersionResult;
|
||||
|
||||
|
||||
+3
-1
@@ -459,7 +459,9 @@ static inline void printCommandHelp(const char* command)
|
||||
"Version tweak",
|
||||
"Build type (debug or release)",
|
||||
"Architecture",
|
||||
"CMake build type (Debug, Release, RelWithDebInfo, MinSizeRel)"
|
||||
"CMake build type (Debug, Release, RelWithDebInfo, MinSizeRel)",
|
||||
"Date time when compiling",
|
||||
"Compiler used"
|
||||
);
|
||||
}
|
||||
else if(ffStrEqualsIgnCase(command, "vulkan-format"))
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "modules/version/version.h"
|
||||
#include "util/stringUtils.h"
|
||||
|
||||
#define FF_VERSION_NUM_FORMAT_ARGS 6
|
||||
#define FF_VERSION_NUM_FORMAT_ARGS 8
|
||||
|
||||
void ffPrintVersion(FFVersionOptions* options)
|
||||
{
|
||||
@@ -25,6 +25,8 @@ void ffPrintVersion(FFVersionOptions* options)
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.debugMode ? "debug" : "release"},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.architecture},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.cmakeBuiltType},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.compileTime},
|
||||
{FF_FORMAT_ARG_TYPE_STRING, result.compiler},
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -78,5 +80,7 @@ void ffGenerateVersionJson(FF_MAYBE_UNUSED FFVersionOptions* options, yyjson_mut
|
||||
yyjson_mut_obj_add_str(doc, obj, "version", result.version);
|
||||
yyjson_mut_obj_add_str(doc, obj, "versionTweak", result.versionTweak);
|
||||
yyjson_mut_obj_add_str(doc, obj, "cmakeBuiltType", result.cmakeBuiltType);
|
||||
yyjson_mut_obj_add_str(doc, obj, "compileTime", result.compileTime);
|
||||
yyjson_mut_obj_add_str(doc, obj, "compiler", result.compiler);
|
||||
yyjson_mut_obj_add_bool(doc, obj, "debugMode", result.debugMode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user