From db53602d19e2d9c42400d7734a21843ddc47577b Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Fri, 11 Jun 2021 14:36:48 -0400 Subject: added version generation --- Makefile | 13 +++++++++++-- version.lua | 2 ++ version.template | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 version.lua create mode 100644 version.template diff --git a/Makefile b/Makefile index 5dcd4f6..ddfa42c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ # -*- make -*- # (C) 2016 by Eugeniy Mikhailov, +TOPDIR=. + include ./local.mk # this file is a bit complex since it tries to be general enough to use @@ -28,7 +30,7 @@ endif UPLOAD_STAMPS = .upload_stamps -lua_files = $(wildcard *.lua) +lua_files = $(wildcard *.lua) version.lua httpserver_lua_files = $(wildcard nodemcu-httpserver/httpserver*.lua) html_files = $(wildcard http/*) @@ -36,7 +38,7 @@ lua_files_upload_stamps = $(lua_files:%=$(UPLOAD_STAMPS)/%.uploaded) httpserver_files_upload_stamps = $(httpserver_lua_files:%=$(UPLOAD_STAMPS)/%.uploaded) html_files_upload_stamps = $(html_files:%=$(UPLOAD_STAMPS)/%.uploaded) -upload: $(UPLOAD_STAMPS) $(html_files_upload_stamps) $(lua_files_upload_stamps) $(httpserver_files_upload_stamps) +upload: $(UPLOAD_STAMPS) $(html_files_upload_stamps) version $(lua_files_upload_stamps) $(httpserver_files_upload_stamps) $(UPLOAD_STAMPS): mkdir -p $(UPLOAD_STAMPS) @@ -65,6 +67,13 @@ else ($(upload_cmd) --src $< --dest $<) && touch $@ endif +GIT_VERSION:="$(shell git describe --tags --always) ($(shell git log --pretty=format:%cd --date=short -n1), branch $(shell [ -f $(TOPDIR)/.git/HEAD ] && sed 's/ref: refs\/heads\/\(.*\)/\\\\\\"\1\\\\\\"/g' $(TOPDIR)/.git/HEAD || echo 'unknown'))" +VERSION:=$(shell git describe --tags --abbrev=0) + +version: version.lua + +version.lua: version.template $(lua_files%version.lua%) + sed s/__VERSION__/{$(GIT_VERSION)}/ < $< > $@ term: $(term_cmd) diff --git a/version.lua b/version.lua new file mode 100644 index 0000000..5fa212c --- /dev/null +++ b/version.lua @@ -0,0 +1,2 @@ +print("{v1.0-home-cooked-binary-25-g5892768 (2021-06-11, branch "binary-speedup")}") + diff --git a/version.template b/version.template new file mode 100644 index 0000000..5a64f5c --- /dev/null +++ b/version.template @@ -0,0 +1,2 @@ +print("__VERSION__") + -- cgit v1.2.3