build,ui: add build timestamp
ci/woodpecker/push/woodpecker Pipeline failed Details
ci/woodpecker/pr/woodpecker Pipeline failed Details

together with the build semver, this should provide stable info for
ndg software version running on a given device.
alex 1 year ago
parent 871422b030
commit 0527ddf5c1
Signed by: x1ddos
GPG Key ID: FDEFB4A63CBD8460

@ -14,6 +14,7 @@ pub fn build(b: *std.build.Builder) void {
const buildopts = b.addOptions(); const buildopts = b.addOptions();
buildopts.addOption(DriverTarget, "driver", drv); buildopts.addOption(DriverTarget, "driver", drv);
buildopts.addOption(u64, "build_timestamp", @intCast(u64, std.time.timestamp()));
const semver_step = VersionStep.create(b, buildopts, inver); const semver_step = VersionStep.create(b, buildopts, inver);
// gui build // gui build

@ -61,7 +61,24 @@ export fn nm_create_info_panel(parent: *lvgl.LvObj) c_int {
} }
fn createInfoPanel(parent: *lvgl.LvObj) !void { fn createInfoPanel(parent: *lvgl.LvObj) !void {
parent.flexFlow(.column);
parent.flexAlign(.start, .start, .start);
var buf: [100]u8 = undefined; var buf: [100]u8 = undefined;
const s = try std.fmt.bufPrintZ(&buf, "ndg version: {any}", .{buildopts.semver}); const sver = try std.fmt.bufPrintZ(&buf, "nakamochi software version: {any}", .{buildopts.semver});
_ = try lvgl.createLabel(parent, s, .{ .long_mode = .wrap, .pos = .none }); _ = try lvgl.createLabel(parent, sver, .{ .long_mode = .wrap, .pos = .none });
const epoch: std.time.epoch.EpochSeconds = .{ .secs = buildopts.build_timestamp };
const daysec = epoch.getDaySeconds();
const yearday = epoch.getEpochDay().calculateYearDay();
const monthday = yearday.calculateMonthDay();
const ts = try std.fmt.bufPrintZ(&buf, "build timestamp: {d}-{d:0>2}-{d:0>2} {d:0>2}:{d:0>2}:{d:0>2} UTC", .{
yearday.year,
monthday.month.numeric(),
monthday.day_index + 1,
daysec.getHoursIntoDay(),
daysec.getMinutesIntoHour(),
daysec.getSecondsIntoMinute(),
});
_ = try lvgl.createLabel(parent, ts, .{ .long_mode = .wrap, .pos = .none });
} }