Skip to content

Include git commit information in $&version #172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ y.*
initial.c
sigmsgs.c
token.h
version.h
es
esdump
testrun
9 changes: 6 additions & 3 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ OFILES = access.o closure.o conv.o dict.o eval.o except.o fd.o gc.o glob.o \
sigmsgs.o signal.o split.o status.o str.o syntax.o term.o token.o \
tree.o util.o var.o vec.o version.o y.tab.o
OTHER = Makefile parse.y mksignal
GEN = esdump y.tab.c y.tab.h y.output token.h sigmsgs.c initial.c
GEN = esdump y.tab.c y.tab.h y.output token.h version.h sigmsgs.c initial.c

SIGFILES = @SIGFILES@

Expand Down Expand Up @@ -109,6 +109,9 @@ y.tab.c y.tab.h : parse.y
token.h : y.tab.h
-cmp -s y.tab.h token.h || cp y.tab.h token.h

version.h : mkversion .git/index
sh $(srcdir)/mkversion > version.h

initial.c : esdump $(srcdir)/initial.es
./esdump < $(srcdir)/initial.es > initial.c

Expand Down Expand Up @@ -140,7 +143,7 @@ open.o : open.c es.h config.h stdenv.h
opt.o : opt.c es.h config.h stdenv.h
prim.o : prim.c es.h config.h stdenv.h prim.h
prim-ctl.o : prim-ctl.c es.h config.h stdenv.h prim.h
prim-etc.o : prim-etc.c es.h config.h stdenv.h prim.h
prim-etc.o : prim-etc.c es.h config.h stdenv.h prim.h version.h
prim-io.o : prim-io.c es.h config.h stdenv.h gc.h prim.h
prim-sys.o : prim-sys.c es.h config.h stdenv.h prim.h
print.o : print.c es.h config.h stdenv.h print.h
Expand All @@ -156,4 +159,4 @@ tree.o : tree.c es.h config.h stdenv.h gc.h
util.o : util.c es.h config.h stdenv.h
var.o : var.c es.h config.h stdenv.h gc.h var.h term.h
vec.o : vec.c es.h config.h stdenv.h gc.h
version.o : version.c es.h config.h stdenv.h
version.o : version.c es.h config.h stdenv.h version.h
2 changes: 1 addition & 1 deletion es.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ extern int opentty(void);

/* version.c */

extern const char * const version;
extern const List * const version;


/* gc.c -- see gc.h for more */
Expand Down
3 changes: 2 additions & 1 deletion initial.es
Original file line number Diff line number Diff line change
Expand Up @@ -767,4 +767,5 @@ noexport = noexport pid signals apid bqstatus fn-%dispatch path home matchexpr
# is printed in the header comment in initial.c; nobody really
# wants to look at initial.c anyway.

result es initial state built in `/bin/pwd on `/bin/date for <=$&version
let ((version date) = <=$&version)
result es initial state generated from version $version from $date
7 changes: 7 additions & 0 deletions mkversion
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

v=$(git describe --tags 2>/dev/null)
d=$(git show --no-patch --format=%ci | cut -f1 -d' ')

echo "#define VERSION \"$v\""
echo "#define VERSION_DATE \"$d\""
3 changes: 2 additions & 1 deletion prim-etc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "es.h"
#include "prim.h"
#include "version.h"

PRIM(result) {
return list;
Expand Down Expand Up @@ -33,7 +34,7 @@ PRIM(setnoexport) {
}

PRIM(version) {
return mklist(mkstr((char *) version), NULL);
return (List *)version;
}

PRIM(exec) {
Expand Down
11 changes: 9 additions & 2 deletions version.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#include "es.h"
static const char id[] = "@(#)es version 0.9.2 2-Mar-2022";
const char * const version = id + (sizeof "@(#)" - 1);
#include "term.h"
#include "version.h"

static const Term
version_date_term = { VERSION_DATE, NULL },
version_term = { VERSION, NULL };
static const List vdl = { (Term *) &version_date_term, NULL };
static const List versionstruct = { (Term *) &version_term, (List *)&vdl };
const List * const version = &versionstruct;