Added Makefile re-export (project.h) `PROG_COMPILED_TIMESTAMP` (u64): UTC unix timestamp (seconds) when TU was compiled.

Show "compiled when" timestamp in usage messaged. TODO: Convert to human-readable UTC time.

Fortune for naka's current commit: Blessing − 吉
generic-project-skeleton
Avril 3 years ago
parent 66f9b0ad55
commit a8e38d292e
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -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)

@ -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 */

@ -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);
}

Loading…
Cancel
Save