dev: automatic version.h generation

also added compiler information as a feature
This commit is contained in:
2025-07-04 15:19:25 +02:00
parent 3ec1eec56f
commit 19a1355b06
5 changed files with 66 additions and 17 deletions

View File

@@ -4,17 +4,20 @@
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include "chvt.h"
#include "config.h"
#include "log.h"
#include "macros.h"
#include "sessions.h"
#include "ui.h"
#include "users.h"
#include "util.h"
#include "version.h"
#define DATESTR_MAXBUFSIZE 0x20
int main(int argc, char* argv[]) {
// Logger
char* log_output = getenv("LIDM_LOG");
@@ -31,20 +34,40 @@ int main(int argc, char* argv[]) {
if (argc == 2) {
if (strcmp(argv[1], "-v") == 0 || strcmp(argv[1], "--version") == 0) {
printf("lidm version %s (git %s, build date %s)\n", LIDM_VERSION,
LIDM_GIT_DESCRIPTION, LIDM_BUILD_DATE);
char* version = "?";
char* revision = "?";
char* builddate = "?";
char* compilever = "?";
#ifdef LIDM_VERSION
version = LIDM_VERSION;
#endif
#ifdef LIDM_GIT_REV
revision = LIDM_GIT_REV;
#endif
#ifdef LIDM_BUILD_TS
time_t ts = LIDM_BUILD_TS;
char date_buf[DATESTR_MAXBUFSIZE];
builddate = date_buf;
if (strftime(date_buf, 0xff, "%Y-%m-%dT%H:%M:%SZ", localtime(&ts)) > 0)
builddate = date_buf;
#endif
#ifdef COMPILER_VERSION
compilever = COMPILER_VERSION;
#endif
printf("lidm version %s (git %s, build date %s, compiler %s)\n", version,
revision, builddate, compilever);
return 0;
} else if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) {
}
if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) {
printf(
"Usage: lidm [vt number]\n"
"Options:\n"
" -h, --help Display help menu\n"
" -v, --version Display version information\n");
return 0;
} else {
// Chvt
chvt_str(argv[1]);
}
// Chvt
chvt_str(argv[1]);
}
struct config config = DEFAULT_CONFIG;