ref: 5b97c637b7a4148cd007d3ca35f7dea94375cc89
parent: f0adf4345753abac945bc9b57b4958c70dce766e
author: Andrew Chambers <ac@acha.ninja>
date: Sun Apr 10 19:52:46 CDT 2022
Generate version header.
--- a/Makefile
+++ b/Makefile
@@ -4,8 +4,8 @@
MANDIR = $(DESTDIR)$(PREFIX)/man/man1
CFLAGS = -g -O2 -Wall
-SRC = version.h tree.h compile.c tree.c peg.c
-GENSRC = minipeg-new.c peg.c www/index.html
+SRC = tree.h compile.c tree.c peg.c
+GENSRC = version.h minipeg-new.c peg.c www/index.html
OBJ = compile.o tree.o peg.o
all: minipeg
@@ -24,17 +24,24 @@
peg.c: peg.peg bootstrap-minipeg
./bootstrap-minipeg -o $@ peg.peg
+%.o : %.c tree.h version.h
+ $(CC) $(CFLAGS) -c -o $@ $<
+
minipeg: $(OBJ)
$(CC) $(CFLAGS) -o $@ $(OBJ)
-minipeg-new.c: $(SRC) amalg.sh
- sh amalg.sh $(SRC) > $@
+version.h:
+ echo "#define MINIPEG_VERSION"\
+ "\"$(shell git describe --tags --always || date +%Y.%m.%d)\"" > version.h
+minipeg-new.c: version.h $(SRC) amalg.sh
+ sh amalg.sh version.h $(SRC) > $@
+
www/index.html: .FORCE
sh ./www/index.html.sh > $@
%.c.noversion : %.c
- grep -v -e '#define MINIPEG_VERSION' $< > $@
+ grep -v -e "^/\* Parser generated by minipeg " -e '#define MINIPEG_VERSION' $< > $@
# Check the bootstrap minipeg.c matches the built minipeg-new.c (without version info).
check-self-host: minipeg.c.noversion minipeg-new.c.noversion .FORCE
--- a/compile.c
+++ b/compile.c
@@ -715,7 +715,7 @@
void Rule_compile_c_header(void)
{
- fprintf(output, "/* A recursive-descent parser generated by minipeg %s */\n", MINIPEG_VERSION);
+ fprintf(output, "/* Parser generated by minipeg %s */\n", MINIPEG_VERSION);
fprintf(output, "\n");
fprintf(output, "%s", header);
fprintf(output, "#define YYRULECOUNT %d\n", ruleCount);
--- a/minipeg.c
+++ b/minipeg.c
@@ -27,7 +27,7 @@
#include <string.h>
#include <unistd.h>
#line 0 "version.h"
-#define MINIPEG_VERSION "unreleased"
+#define MINIPEG_VERSION "f0adf43"
#line 0 "tree.h"
enum { Unknown= 0, Rule, Variable, Name, Dot, Character, String, Class, Action, Inline, Predicate, Error, Alternate, Sequence, PeekFor, PeekNot, Query, Star, Plus };
@@ -836,7 +836,7 @@
void Rule_compile_c_header(void)
{
- fprintf(output, "/* A recursive-descent parser generated by minipeg %s */\n", MINIPEG_VERSION);
+ fprintf(output, "/* Parser generated by minipeg %s */\n", MINIPEG_VERSION);
fprintf(output, "\n");
fprintf(output, "%s", header);
fprintf(output, "#define YYRULECOUNT %d\n", ruleCount);
@@ -1274,7 +1274,7 @@
void Rule_print(Node *node) { Rule_fprint(stderr, node); }
#line 0 "peg.c"
-/* A recursive-descent parser generated by minipeg unreleased */
+/* Parser generated by minipeg f0adf43 */
#define YYRULECOUNT 38
#line 1 "peg.peg"
--- a/version.h
+++ /dev/null
@@ -1,1 +1,0 @@
-#define MINIPEG_VERSION "unreleased"