From a8e38d292e94146cf041a9789eb5eb976b64b07e Mon Sep 17 00:00:00 2001 From: Avril Date: Fri, 9 Jul 2021 18:15:48 +0100 Subject: [PATCH] Added Makefile re-export (project.h) `PROG_COMPILED_TIMESTAMP` (u64): UTC unix timestamp (seconds) when TU was compiled. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Show "compiled when" timestamp in usage messaged. TODO: Convert to human-readable UTC time. Fortune for naka's current commit: Blessing − 吉 --- Makefile | 5 ++++- include/project.h | 4 ++++ src/main.c | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e28ae96..912af0d 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,8 @@ VERSION_REV=0 VERSION:=$(VERSION_MAJ).$(VERSION_MIN).$(VERSION_BF).$(VERSION_REV) +COMP_TIME:=$(shell date -u +%s) + SRC_C = $(wildcard src/*.c) $(wildcard src/tests/*.c) SRC_CXX = $(wildcard src/*.cpp) @@ -21,7 +23,8 @@ INCLUDE=include META_FLAGS:=-D_PROJECT_AUTHOR="\"$(AUTHOR)\"" -D_PROJECT_DESCRIPTION="\"$(DESCRIPTION)\"" -D_PROJECT_NAME="\"$(PROJECT)\"" \ -D_PROJECT_LICENSE="\"$(LICENSE)\"" \ -D_VERSION_MAJOR=$(VERSION_MAJ) -D_VERSION_MINOR=$(VERSION_MIN) \ - -D_VERSION_BUGFIX=$(VERSION_BF) -D_VERSION_REVISION=$(VERSION_REV) + -D_VERSION_BUGFIX=$(VERSION_BF) -D_VERSION_REVISION=$(VERSION_REV) \ + -D_PROJECT_COMPILED=$(COMP_TIME) COMMON_FLAGS+= -W -Wall -fno-strict-aliasing $(addprefix -I,$(INCLUDE)) $(META_FLAGS) diff --git a/include/project.h b/include/project.h index c8b260c..294af40 100644 --- a/include/project.h +++ b/include/project.h @@ -2,6 +2,8 @@ #ifndef _PROJECT_H #define _PROJECT_H +#include "macros.h" +#include "ints.h" #include "version.h" /// Project version, as a raw version identifier (u32). @@ -19,5 +21,7 @@ #define PROG_AUTHOUR _PROJECT_AUTHOR /// Project license #define PROG_LICENSE _PROJECT_LICENSE +/// Compiled time (UTC unix timestamp) +#define PROG_COMPILED_TIMESTAMP AS(_PROJECT_COMPILED, u64) #endif /* _PROJECT_H */ diff --git a/src/main.c b/src/main.c index 91908e8..3e3b70f 100644 --- a/src/main.c +++ b/src/main.c @@ -15,9 +15,10 @@ void prog_info(FILE* out) { fprintf(out, PROG_NAME " v%s - " PROG_DESCRIPTION - "\n written by %s with <3\n license %s.\n", + "\n written by %s with <3 (compiled at %lu UTC (unix ts))\n license %s.\n", v_ctoss(v_rawtoc(PROG_VERSION)), PROG_AUTHOUR, + PROG_COMPILED_TIMESTAMP, PROG_LICENSE); }