diff --git a/.gitignore b/.gitignore index 0819fea..67de7b9 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,7 @@ y.tab.h initial.c sigmsgs.c +version.h es esdump testrun diff --git a/Makefile.in b/Makefile.in index 50c3445..bf98da9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -61,7 +61,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.h y.output sigmsgs.c initial.c +GEN = esdump y.tab.h y.output sigmsgs.c initial.c version.h SIGFILES = @SIGFILES@ @@ -107,6 +107,9 @@ token.h : parse.y y.tab.c : token.h +version.h : mkversion + (cd $(srcdir) && sh mkversion) > version.h + initial.c : esdump $(srcdir)/initial.es ./esdump < $(srcdir)/initial.es > initial.c @@ -139,7 +142,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 @@ -155,4 +158,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 diff --git a/es.h b/es.h index fef74f0..d3a3c9f 100644 --- a/es.h +++ b/es.h @@ -383,7 +383,7 @@ extern int opentty(void); /* version.c */ -extern const char * const version; +extern const List * const version; /* gc.c -- see gc.h for more */ diff --git a/mkversion b/mkversion new file mode 100755 index 0000000..7a31b2e --- /dev/null +++ b/mkversion @@ -0,0 +1,6 @@ +#!/bin/sh + +VERSION=0.9.2 +RELEASEDATE=2-Mar-2022 + +echo "#define VERSION \"es version $VERSION $RELEASEDATE\"" diff --git a/prim-etc.c b/prim-etc.c index c2dd788..de6a0f7 100644 --- a/prim-etc.c +++ b/prim-etc.c @@ -4,6 +4,7 @@ #include "es.h" #include "prim.h" +#include "version.h" PRIM(result) { return list; @@ -33,7 +34,7 @@ PRIM(setnoexport) { } PRIM(version) { - return mklist(mkstr((char *) version), NULL); + return (List *)version; } PRIM(exec) { diff --git a/release.es b/release.es index 1de222b..f8fff66 100755 --- a/release.es +++ b/release.es @@ -1,15 +1,62 @@ #!/usr/bin/env es -# Create a new tarball +# release.es -- release a new es version. This script does the following: +# - Updates the return value of $&version +# - Creates an "update" commit and tags the commit with the new version +# (if write-to-git = true). +# - Generates a tarball for the new release. +# +# To use it to release a new version (e.g., 0.9.3), do the following: +# 1. Start in an es git repo directory called 'es-0.9.3' with a clean +# working tree +# 2. Edit CHANGES to describe the new release +# 3. Run `./release.es 0.9.3`. It will open an editor for you to write the +# tag message. Presumably you should just copy what you added to CHANGES. +# 4. Assuming everything looks good, run `git push && git push origin v0.9.3` +# +# At this point you'll be able to muck about in Github to create a "Release". + +# Whether to actually do the git commit and tag. Mostly for testing purposes. +write-to-git = true + +# make sure everything is on the up and up if {!~ $#* 1} { - echo Must provide a single argument: the release version (e.g. 0.9.1) - exit 1 + echo >[1=2] 'Must provide a single argument: the release version (e.g. 0.9.1)' + exit 1 +} + +version = $1 +cwd = `{basename `pwd} + +if {!~ $cwd es-$version} { + echo >[1=2] 'Must release from a directory named es-'^$version + exit 1 } -if {! grep -q $1 version.c} { - echo 'Must update version.c to '^$1 - echo '(yes, this should be automated)' +let (changes = `` \n {git status -s}) +if {$write-to-git && {!~ $#changes 1 || !~ $changes ' M CHANGES'}} { + echo >[1=2] 'Must start with a clean workspace with updated CHANGES file' + exit 1 } -tar chzvf ../es-$1.tar.gz --exclude\=.circleci --exclude\=.gitignore --exclude\=release.es `{git ls-files} config.guess config.sub config.h.in configure install-sh +# update mkversion, commit and then tag + +sed -i \ + -e 's/VERSION=.*/VERSION='^$version^'/' \ + -e 's/RELEASEDATE=.*/RELEASEDATE='^`^{date +%e-%b-%Y}^'/' \ + mkversion + +if $write-to-git { + git commit -am 'Version '^$version + git tag -a v$version +} + +# generate tarball + +files = `{git ls-files} +cd .. +tar chzvf es-$version.tar.gz \ + --exclude=.circleci --exclude=.gitignore \ + --exclude=.gitattributes --exclude=release.es \ + $cwd/^($files config.guess config.sub config.h.in configure install-sh) diff --git a/version.c b/version.c index 2c16f0e..3bc448c 100644 --- a/version.c +++ b/version.c @@ -1,3 +1,8 @@ #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_term = { VERSION, NULL }; +static const List versionstruct = { (Term *) &version_term, NULL }; +const List * const version = &versionstruct;