mirror of
https://codeberg.org/armin/chromaflock.git
synced 2026-09-01 04:10:47 +02:00
Add bottom status bar with git build info and compile time
This commit is contained in:
parent
cd2caf7821
commit
a2485907ef
6 changed files with 118 additions and 1 deletions
32
Source/BuildInfo.cpp
Normal file
32
Source/BuildInfo.cpp
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#include "BuildInfo.h"
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
std::string getBuildInfoString() {
|
||||
// Actual compilation time from compiler built-ins.
|
||||
// __DATE__ -> "Mmm dd yyyy", __TIME__ -> "HH:MM:SS"
|
||||
const char* date = __DATE__;
|
||||
const char* time = __TIME__;
|
||||
|
||||
static const char* months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
char mon[4] = {0};
|
||||
int day = 0, year = 0, hh = 0, mm = 0, ss = 0;
|
||||
std::sscanf(date, "%3s %d %d", mon, &day, &year);
|
||||
std::sscanf(time, "%d:%d:%d", &hh, &mm, &ss);
|
||||
|
||||
int mi = 1;
|
||||
for (int i = 0; i < 12; ++i)
|
||||
if (std::strcmp(mon, months[i]) == 0) { mi = i + 1; break; }
|
||||
|
||||
char buf[64];
|
||||
std::snprintf(buf, sizeof(buf), "%04d-%02d-%02d__%02d-%02d-%02d",
|
||||
year, mi, day, hh, mm, ss);
|
||||
|
||||
std::string s = std::string("build ") + CHROMAFLOCK_GIT_HASH
|
||||
+ " (" + CHROMAFLOCK_GIT_BRANCH + ")";
|
||||
if (CHROMAFLOCK_GIT_DIRTY)
|
||||
s += " *";
|
||||
s += " built " + std::string(buf);
|
||||
return s;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue