Add optional version tag when build in between releases

Also add REPL :version command to show the current version
This commit is contained in:
Kamil Shakirov 2019-09-27 22:26:04 +06:00
parent 4e019d8093
commit b87fd0beb3
7 changed files with 90 additions and 54 deletions

View File

@ -2,13 +2,27 @@
MAJOR=0
MINOR=0
PATCH=0
IDRIS2_VERSION=${MAJOR}.${MINOR}.${PATCH}
GIT_SHA1=
VER_TAG=
ifeq ($(shell git status >/dev/null 2>&1; echo $$?), 0)
# inside a git repo
ifneq ($(shell git describe --exact-match --tags >/dev/null 2>&1; echo $$?), 0)
# not tagged as a released version, so add sha1 of this build in between releases
GIT_SHA1 := $(shell git rev-parse --short=9 HEAD)
VER_TAG := -${GIT_SHA1}
endif
endif
IDRIS2_VERSION=${MAJOR}.${MINOR}.${PATCH}${VER_TAG}
PREFIX ?= ${HOME}/.idris2
IDRIS_VERSION := $(shell idris --version)
VALID_IDRIS_VERSION_REGEXP = "1.3.2.*"
export IDRIS2_PATH = ${CURDIR}/libs/prelude/build/ttc:${CURDIR}/libs/base/build/ttc
export IDRIS2_DATA = ${CURDIR}/support
IDRIS_VERSION := $(shell idris --version)
VALID_IDRIS_VERSION_REGEXP = "1.3.2.*"
-include custom.mk
.PHONY: ttimp idris2 prelude test base clean lib_clean check_version
@ -16,14 +30,15 @@ export IDRIS2_DATA = ${CURDIR}/support
all: idris2 libs test
check_version:
@echo "Using idris version: $(IDRIS_VERSION)"
@echo "Using Idris 1 version: $(IDRIS_VERSION)"
@if [ $(shell expr $(IDRIS_VERSION) : $(VALID_IDRIS_VERSION_REGEXP)) -eq 0 ]; then echo "Wrong idris version, expected version matching $(VALID_IDRIS_VERSION_REGEXP)"; exit 1; fi
idris2: src/YafflePaths.idr check_version
@echo "Building Idris 2 version: $(IDRIS2_VERSION)"
idris --build idris2.ipkg
src/YafflePaths.idr:
echo 'module YafflePaths; export yversion : ((Nat,Nat,Nat), String); yversion = ((${MAJOR},${MINOR},${PATCH}), "")' > src/YafflePaths.idr
echo 'module YafflePaths; export yversion : ((Nat,Nat,Nat), String); yversion = ((${MAJOR},${MINOR},${PATCH}), "${GIT_SHA1}")' > src/YafflePaths.idr
echo 'export yprefix : String; yprefix = "${PREFIX}"' >> src/YafflePaths.idr
prelude:

View File

@ -1462,6 +1462,8 @@ nonEmptyCommand
pure (SetLog (fromInteger i))
<|> do symbol ":"; replCmd ["m", "metavars"]
pure Metavars
<|> do symbol ":"; replCmd ["version"]
pure ShowVersion
<|> do symbol ":"; cmd <- editCmd
pure (Editing cmd)
<|> do tm <- expr pdef "(interactive)" init

View File

@ -568,7 +568,8 @@ process NOP
process ShowVersion
= do opts <- get ROpts
case idemode opts of
REPL _ => iputStrLn $ showVersion version
REPL _ => do iputStrLn $ showVersion version
pure True
IDEMode i _ f => do
let MkVersion (maj, min, patch) t = version
send f (SExpList [SymbolAtom "return",

2
tests/ideMode/ideMode002/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/expected

View File

@ -1,3 +1,3 @@
000018(:protocol-version 2 0)
000021(:return (:ok ((0 0 0) (""))) 1)
__EXPECTED_LINE__
Alas the file is done, aborting

View File

@ -0,0 +1,15 @@
#!/usr/bin/env sh
INPUT=`cat`
VERSION=`echo $INPUT | cut -d- -f1`
TAG=`echo $INPUT | cut -s -d- -f2`
MAJOR=`echo $VERSION | cut -d. -f1`
MINOR=`echo $VERSION | cut -d. -f2`
PATCH=`echo $VERSION | cut -d. -f3`
EXPECTED_LINE="(:return (:ok ((${MAJOR} ${MINOR} ${PATCH}) (\"${TAG}\"))) 1)"
EXPECTED_LENGTH=$(expr ${#EXPECTED_LINE} + 1) # +LF
sed -e "s/__EXPECTED_LINE__/$(printf '%06x' ${EXPECTED_LENGTH})${EXPECTED_LINE}/g" expected.in > expected

View File

@ -1,3 +1,4 @@
$1 --version | awk '{print $4}' | ./gen_expected.sh
$1 --ide-mode < input
rm -rf build