git version

This commit is contained in:
folkert van heusden 2024-04-11 16:49:22 +02:00
parent c7f8d83c2b
commit 21558d7383
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1
4 changed files with 22 additions and 1 deletions

View file

@ -43,6 +43,7 @@
#include "memory.h" #include "memory.h"
#include "tty.h" #include "tty.h"
#include "utils.h" #include "utils.h"
#include "version.h"
constexpr const char NET_DISK_CFG_FILE[] = "/net-disk.json"; constexpr const char NET_DISK_CFG_FILE[] = "/net-disk.json";
@ -547,7 +548,8 @@ void setup() {
delay(100); delay(100);
Serial.println(F("This PDP-11 emulator is called \"kek\" (reason for that is forgotten) and was written by Folkert van Heusden.")); Serial.println(F("This PDP-11 emulator is called \"kek\" (reason for that is forgotten) and was written by Folkert van Heusden."));
Serial.print(F("GIT hash: "));
Serial.println(version_str);
Serial.println(F("Build on: " __DATE__ " " __TIME__)); Serial.println(F("Build on: " __DATE__ " " __TIME__));
Serial.print(F("Size of int: ")); Serial.print(F("Size of int: "));

View file

@ -19,6 +19,7 @@ lib_deps = greiman/SdFat@^2.1.2
bblanchon/ArduinoJson@^6.19.4 bblanchon/ArduinoJson@^6.19.4
build_flags = -std=gnu++17 -Ofast -DESP32=1 -ggdb3 -D_GLIBCXX_USE_C99 build_flags = -std=gnu++17 -Ofast -DESP32=1 -ggdb3 -D_GLIBCXX_USE_C99
build_unflags = -std=gnu++11 -Os build_unflags = -std=gnu++11 -Os
extra_scripts = pre:prepare.py
[env:SHA2017-badge] [env:SHA2017-badge]
build_src_filter = +<*> -<.git/> -<.svn/> -<example/> -<examples/> -<test/> -<tests/> -<build> -<player.cpp> -<SHAdisplay/main/> -<SHAdisplay/components> -<SHAdisplay/Arduino/epd2in9-badge> build_src_filter = +<*> -<.git/> -<.svn/> -<example/> -<examples/> -<test/> -<tests/> -<build> -<player.cpp> -<SHAdisplay/main/> -<SHAdisplay/components> -<SHAdisplay/Arduino/epd2in9-badge>

17
ESP32/prepare.py Executable file
View file

@ -0,0 +1,17 @@
#! /usr/bin/python3
import json
import subprocess
import sys
def get_git_hash():
ret = subprocess.run(["git", "diff", "--quiet"], stdout=subprocess.PIPE, text=True)
add = '*' if ret.returncode != 0 else ''
ret = subprocess.run(["git", "rev-parse", "--short", "HEAD"], stdout=subprocess.PIPE, text=True)
return ret.stdout.strip() + add
fh = open('version.cpp', 'w')
fh.write('const char *version_str = "' + get_git_hash() + '";\n')
fh.close()

1
ESP32/version.h Normal file
View file

@ -0,0 +1 @@
extern const char *version_str;