another iteration of the version number system; simpler and more efficient

The release version is defined in VERSION, make or make release do the rest.
This commit is contained in:
Simon Michael 2009-02-27 02:55:54 +00:00
parent ea0c32641d
commit c0885f7c76
6 changed files with 131 additions and 89 deletions

134
Makefile
View File

@ -1,21 +1,29 @@
# hledger project makefile # hledger project makefile
default: tag build
# patches since last release tag (as a haskell string literal)
PATCHES:="\"`expr \`darcs changes --count --from-tag=\\\\\.\` - 1`\""
# build the normal hledger binary # build the normal hledger binary
BUILD=ghc --make hledger.hs -o hledger -O BUILD=ghc --make hledger.hs -o hledger -O
BUILDFLAGS=-DVTY -DANSI -DHAPPS FLAGS=-DPATCHES=$(PATCHES)
build: setbuildversion tag # optional extras described in README, turn em on if you've got the libs
$(BUILD) $(BUILDFLAGS) OPTFLAGS=-DVTY -DANSI -DHAPPS
BUILDFLAGS=$(FLAGS) $(OPTFLAGS)
build: setversion
@$(BUILD) $(BUILDFLAGS)
# build the fastest binary we can, as hledgeropt # build the fastest binary we can, as hledgeropt
BUILDOPT=ghc --make hledger.hs -o hledgeropt -O2 -fvia-C BUILDOPT=ghc --make hledger.hs -o hledgeropt -O2 -fvia-C
buildopt opt: buildopt opt: setversion
$(BUILDOPT) $(BUILDOPT) $(BUILDFLAGS)
# recompile and run tests (or another command) whenever a module changes # recompile and run tests (or another command) whenever a module changes
# see http://searchpath.org , you may need the patched version from # see http://searchpath.org , you may need the patched version from
# http://joyful.com/repos/searchpath # http://joyful.com/repos/searchpath
CICMD=test CICMD=test
continuous ci: continuous ci: setversion
sp --no-exts --no-default-map -o hledger ghc --make hledger.hs $(BUILDFLAGS) --run $(CICMD) sp --no-exts --no-default-map -o hledger ghc --make hledger.hs $(BUILDFLAGS) --run $(CICMD)
# force a full rebuild with normal optimisation # force a full rebuild with normal optimisation
@ -39,7 +47,7 @@ profile:
cat simple.prof cat simple.prof
# run performance benchmarks and save results in profs # run performance benchmarks and save results in profs
# prepend ./ to these if not in $PATH # executables to test, prepend ./ to these if not in $PATH
BENCHEXES=hledger ledger BENCHEXES=hledger ledger
bench: buildbench sampleledgers bench: buildbench sampleledgers
./bench $(BENCHEXES) | tee profs/`date +%Y%m%d%H%M%S`.bench ./bench $(BENCHEXES) | tee profs/`date +%Y%m%d%H%M%S`.bench
@ -67,79 +75,97 @@ push:
# #
# Places where hledger's version number makes an appearance: # Places where hledger's version number makes an appearance:
# hledger --version # hledger --version
# the darcs release tag # hledger's cabal file
# the cabal file # darcs tags
# the hackage pages and tarball filenames # hackage tarball filenames
# hackage pages
# #
# Goals and constraints for version numbering: # Goals and constraints for our version number system:
# 1 automation, robustness, simplicity, platform independence # 1 automation, robustness, simplicity, platform independence
# 2 cabal versions must be all-numeric # 2 cabal versions must be all-numeric
# 3 release versions should be concise # 3 release versions can be concise (without extra .0's)
# 4 releases should have a corresponding darcs tag # 4 releases should have a corresponding darcs tag
# 5 development builds should have a precise version appearing in --version # 5 development builds should have a precise version appearing in --version
# 6 development builds should generate cabal packages with non-confusing versions # 6 development builds should generate cabal packages with non-confusing versions
# 7 would like a way to mark builds/releases as alpha or beta # 7 there should be a way to mark builds/releases as alpha or beta
# 8 would like to easily darcs get the .0 even with bugfix releases present # 8 it should be easy to darcs get the .0 release even after bugfix releases
# 9 avoid unnecessary compiling and linking
# 10 minimise rcs noise and syncing issues (commits, unrecorded changes)
# #
# Current plan: # Current plan:
# - Update the release version below, and record, before and/or after
# "make release".
# - The release version looks like major.minor[.bugfix]. bugfix is 0 (and # - The release version looks like major.minor[.bugfix]. bugfix is 0 (and
# elided) for a normal release, or 1..n for a bugfix release, or if # may be elided) for a normal release, or 1..n for a bugfix release, or
# desired may be set to 98 meaning an alpha for the forthcoming release # 98 meaning an alpha for the forthcoming release, or 99 meaning a beta.
# or 99 meaning a beta. This is propagated during "make release". # - The build version looks like major.minor.bugfix.patches, where patches
# - The development build version is the non-elided release version plus # is the number of patches applied since the last release tag.
# the number of patches added since the last release, ie # - Set the release version in VERSION before "make" or "make release".
# major.minor.bugfix.patches. This is propagated during "make". # - "make" updates version strings where needed, and defines PATCHES.
# "make release" also records the version number changes and tags the
# repo. (Todo: make cabal build set the version and PATCHES, also)
# - hledger --version shows the build version
# - The cabal package uses the release version
# - The release tag is the non-elided release version. # - The release tag is the non-elided release version.
RELEASE:=0.3.98
# build a cabal release, tag the repo and upload to hackage # run pre-release checks: cabal is happy, the code builds, tests pass..
# don't forget to first update and record RELEASE, if needed check: setversion
release: check setreleaseversion tagrelease sdist #upload cabal clean
ifeq ($(shell ghc -e "length (filter (=='.') \"$(RELEASE)\")"), 1)
RELEASE3:=$(RELEASE).0
else
RELEASE3:=$(RELEASE)
endif
# pre-release checks - cabal is happy, the code builds, tests pass..
check:
cabal check cabal check
cabal configure cabal configure
cabal build cabal build
dist/build/hledger/hledger test 2>&1 | tail -1 | grep -q 'Errors: 0 Failures: 1' dist/build/hledger/hledger test 2>&1 | tail -1 | grep -q 'Errors: 0 Failures: 1' # XXX
# set the precise build version in local files, but don't record. # Build a cabal release, tag the repo and maybe upload to hackage.
# This is used for development builds ("make"). # Don't forget to update VERSION if needed. Examples:
setbuildversion: # releasing 0.5: set VERSION to 0.5, make release hackageupload
(export BUILD=$(RELEASE3).`expr \`darcs changes --count --from-tag=.\` - 1` \ # doing a bugfix release: set VERSION to 0.5.1, make release hackageupload
&& perl -p -e "s/(^version *= *)\".*?\"/\1\"$$BUILD\"/" -i Options.hs \ # building 0.6 alpha: set VERSION to 0.5.98, make
&& perl -p -e "s/(^Version: *) .*/\1 $$BUILD/" -i hledger.cabal \ # releasing 0.6 beta: set VERSION to 0.5.99, make release
) release: check setandrecordversion tagrelease sdist
# set the release version in local files (which should not have other # file where the current release version is defined
# pending edits!), and record. VERSIONFILE=VERSION
setreleaseversion:
perl -p -e "s/(^version *= *)\".*?\"/\1\"$(RELEASE)\"/" -i Options.hs \ # two or three-part version string
&& perl -p -e "s/(^Version: *) .*/\1 $(RELEASE)/" -i hledger.cabal \ VERSION:=`grep -v '^--' $(VERSIONFILE)`
&& darcs record -a -m "bump version" Options.hs hledger.cabal
# three-part version string
ifeq ($(shell ghc -e "length (filter (=='.') \"$(VERSION)\")"), 1)
VERSION3:=$(VERSION).0
else
VERSION3:=$(VERSION)
endif
# other files containing the version string
VERSIONFILES=hledger.cabal Version.hs
hledger.cabal: $(VERSIONFILE)
perl -p -e "s/(^Version: *) .*/\1 $(VERSION)/" -i $@
Version.hs: $(VERSIONFILE)
perl -p -e "s/(^version *= *)\".*?\"/\1\"$(VERSION3)\"/" -i $@
# update the version string in local files. Triggered by "make".
setversion: $(VERSIONFILES)
# update the version string in local files, and record them (and
# $VERSIONFILE) if changed. Be careful, will record all changes in those
# files (so prompts interactively). Triggered by "make release".
setandrecordversion: setversion
darcs record -m "bump version" $(VERSIONFILE) $(VERSIONFILES)
tagrelease: tagrelease:
darcs tag $(RELEASE3) darcs tag $(VERSION3)
sdist: sdist:
cabal sdist cabal sdist
upload: hackageupload:
cabal upload dist/hledger-$(RELEASE).tar.gz cabal upload dist/hledger-$(VERSION).tar.gz
# update emacs TAGS file # update emacs TAGS file
tag: tag:
rm -f TAGS; hasktags -e *hs Ledger/*hs @rm -f TAGS; hasktags -e *hs Ledger/*hs
clean: clean:
rm -f {,Ledger/}*{.o,.hi,~} darcs-amend-record* rm -f {,Ledger/}*{.o,.hi,~} darcs-amend-record*

View File

@ -12,41 +12,7 @@ import Ledger.Utils
import Ledger.Types import Ledger.Types
import Ledger.Dates import Ledger.Dates
configflags = tail [""
#ifdef VTY
,"vty"
#endif
#ifdef ANSI
,"ansi"
#endif
#ifdef HAPPS
,"happs"
#endif
]
configmsg = if null configflags
then ""
else " with " ++ intercalate ", " configflags
progname = "hledger" progname = "hledger"
-- updated by makefile, see notes there
version = "0.3.98"
versionstr = prettify $ splitAtElement '.' version
where
prettify (major:minor:bugfix:patches:[]) =
printf "%s.%s%s%s%s" major minor bugfix' patches' desc
where
bugfix'
| bugfix `elem` ["0"{-,"98","99"-}] = ""
| otherwise = "."++bugfix
patches'
| patches/="0" = " + "++patches++" patches"
| otherwise = ""
desc
| bugfix=="98" = " (alpha)"
| bugfix=="99" = " (beta)"
| otherwise = ""
prettify s = intercalate "." s
versionmsg = progname ++ " " ++ versionstr ++ configmsg ++ "\n"
ledgerpath = "~/.ledger" ledgerpath = "~/.ledger"
ledgerenvvar = "LEDGER" ledgerenvvar = "LEDGER"
timeprogname = "hours" timeprogname = "hours"

3
VERSION Normal file
View File

@ -0,0 +1,3 @@
-- the release version. Normally major.minor[.bugfix], must be numeric.
-- Eg: 0.5, 0.5.1 (a bugfix release), 0.5.98 (= 0.6 alpha), 0.5.99 (= 0.6 beta)
0.3.98

44
Version.hs Normal file
View File

@ -0,0 +1,44 @@
{-# OPTIONS_GHC -cpp #-}
module Version
where
import Ledger.Utils
import Options (progname)
-- updated by build process from VERSION
version = "0.3.98"
-- PATCHES defined by build process from repo state
buildversion = version ++ "." ++ PATCHES
versionstr = prettify $ splitAtElement '.' buildversion
where
prettify (major:minor:bugfix:patches:[]) =
printf "%s.%s%s%s%s" major minor bugfix' patches' desc
where
bugfix'
| bugfix `elem` ["0"{-,"98","99"-}] = ""
| otherwise = "."++bugfix
patches'
| patches/="0" = " + "++patches++" patches"
| otherwise = ""
desc
-- | bugfix=="98" = " (alpha)"
-- | bugfix=="99" = " (beta)"
| otherwise = ""
prettify s = intercalate "." s
versionmsg = progname ++ " " ++ versionstr ++ configmsg ++ "\n"
where configmsg
| null configflags = ""
| otherwise = ", built with " ++ intercalate ", " configflags
configflags = tail [""
#ifdef VTY
,"vty"
#endif
#ifdef ANSI
,"ansi"
#endif
#ifdef HAPPS
,"happs"
#endif
]

View File

@ -1,5 +1,5 @@
Name: hledger Name: hledger
-- updated by makefile, see notes there -- updated by build process from VERSION
Version: 0.3.98 Version: 0.3.98
Category: Finance Category: Finance
Synopsis: A ledger-compatible text-based accounting tool. Synopsis: A ledger-compatible text-based accounting tool.
@ -64,6 +64,8 @@ Executable hledger
Ledger.Transaction Ledger.Transaction
Ledger.Types Ledger.Types
Ledger.Utils Ledger.Utils
-- the cabal build does not yet report patches since last release
cpp-options: -DPATCHES="0"
if flag(vty) if flag(vty)
Build-Depends:vty>=3.1.8.2 Build-Depends:vty>=3.1.8.2
Other-Modules:UICommand Other-Modules:UICommand

View File

@ -46,6 +46,7 @@ import Control.Monad.Error
import qualified Data.Map as Map (lookup) import qualified Data.Map as Map (lookup)
import System.IO import System.IO
import Version (versionmsg)
import Ledger import Ledger
import Utils import Utils
import Options import Options