From 9430ca5109fbb9620f7c47978b758bd564ec67d7 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 9 Dec 2023 07:29:44 -1000 Subject: [PATCH 01/13] just: port INSTALLING make rules --- justfile | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/justfile b/justfile index 95469b58dfd..14649f3a1d9 100644 --- a/justfile +++ b/justfile @@ -2,7 +2,7 @@ # * Light project scripts, without file dependendencies, using https://github.com/casey/just. # https://docs.rs/regex/1.5.4/regex/#syntax Regexps # https://just.systems/man/en/chapter_31.html Functions -# See also Makefile, Shake.hs +# See also Makefile, Shake.hs.. @help: just -lu @@ -125,6 +125,23 @@ _gitSwitchAutoCreate BRANCH: git switch -c {{ BRANCH }} fi +# ** installing + +STACK := 'stack' + +# stack install, then move the hledger executables to bin/old/hledger*-VER +@install-as VER: + {{ STACK }} install --local-bin-path bin/old + for e in hledger hledger-ui hledger-web ; do mv bin/old/$e bin/old/$e-{{ VER }}; echo "bin/$e-{{ VER }}"; done + +# copy the hledger executables from ~/.local/bin to bin/old/hledger*-VER +@copy-as VER: + for e in hledger hledger-ui hledger-web ; do cp ~/.local/bin/$e bin/old/$e-{{ VER }}; echo "bin/$e-{{ VER }}"; done + +# copy just the hledger executable from ~/.local/bin to bin/old/hledger-VER +copy1-as VER: + cp ~/.local/bin/hledger bin/old/hledger-{{ VER }}; echo "bin/hledger-{{ VER }}" + # ** misc # Show last week's activity, for TWIH From e1711f613f0fe4b32d7dd39a4e1b853f57a42020 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 9 Dec 2023 10:47:16 -1000 Subject: [PATCH 02/13] just: port BUILDING make rules --- justfile | 437 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 415 insertions(+), 22 deletions(-) diff --git a/justfile b/justfile index 14649f3a1d9..f9cba64b8be 100644 --- a/justfile +++ b/justfile @@ -1,8 +1,14 @@ #!/usr/bin/env just -# * Light project scripts, without file dependendencies, using https://github.com/casey/just. +# * Light project scripts, without file dependendencies +# using https://github.com/casey/just 0.16. # https://docs.rs/regex/1.5.4/regex/#syntax Regexps # https://just.systems/man/en/chapter_31.html Functions -# See also Makefile, Shake.hs.. +# https://cheatography.com/linux-china/cheat-sheets/justfile Cheatsheet +# https://github.com/casey/just/discussions +# See also Makefile, Shake.hs. + + +# ** prelude @help: just -lu @@ -13,11 +19,395 @@ @_fmt: just -q _check || just --fmt --unstable -# ** dev -# push to github CI branch, wait for CI tests to pass, then push to master -@push *INTERVALSECS: - tools/push {{ INTERVALSECS }} +# ** vars + +# GHC-compiled executables require a locale (and not just C) or they +# will die on encountering non-ascii data. Set LANG to something if not already set. +# export LANG? := 'en_US.UTF-8' + +# command to run during profiling (time and heap) +PROFCMD := 'stack exec --profile -- hledger balance -f examples/10000x1000x10.journal >/dev/null' + +#PROFRTSFLAGS := '-p' +PROFRTSFLAGS := '-P' + +# # command to run during "make coverage" +# COVCMD := 'test' +# COVCMD := '-f test-wf.csv print' + +# misc. system tools +BROWSE := 'open' +# VIEWHTML := '{{ BROWSE }}' +# VIEWPDF := '{{ BROWSE }}' +# PRINT := 'lpr' + +#GHC := 'ghc' +GHCI := 'ghci' #-package ghc-datasize #-package ghc-heap-view +# GHCPKG := 'ghc-pkg' +# HADDOCK := 'haddock' +# CABAL := 'cabal' +# CABALINSTALL := 'cabal install -w {{ GHC }}' + +# Which stack command (and in particular, stack yaml/GHC version) to use for building etc. ? +STACK := 'stack' +#STACK := 'stack --stack-yaml=stack8.10.yaml' +# Or override temporarily with an env var: +# STACK := '"stack --stack-yaml=stack8.10.yaml" make functest' + +# Which stack command (stack yaml, GHC version) to use for ghci[d] operations ? +STACKGHCI := STACK +#STACKGHCI := 'stack --stack-yaml=stack9.2.yaml' + +# if using an unreleased stack with a newer hpack than the one mentioned in */*.cabal, +# it will give warnings. To silence these, put the old hpack-X.Y in $PATH and uncomment: +#STACK := 'stack --with-hpack=hpack-0.20' + +# --threads := '16 sometimes gives "commitAndReleaseBuffer: resource vanished (Broken pipe)" but seems harmless' +# --timeout := 'N is not much use here - can be defeated by multiple threads, unoptimised builds, ' +# slow hackage index or compiler setup on first build, etc. +SHELLTESTOPTS := '--execdir --threads=64 --exclude=/_' + +# make sure shelltest is a released version of shelltestrunner +# run shell tests using the executable specified in tests +# SHELLTEST := 'COLUMNS=80 PATH=~/.local/bin:/usr/bin:/bin shelltest {{ SHELLTESTOPTS }}' +# run shell tests using the stack build of hledger +#SHELLTESTSTK := 'shelltest -w `stack exec which hledger` {{ SHELLTESTOPTS }}' +SHELLTESTSTK := 'COLUMNS=80 ' + STACK + ' exec -- shelltest ' + SHELLTESTOPTS + +WATCHEXEC := 'watchexec' + +PACKAGES := '\ + hledger-lib \ + hledger \ + hledger-ui \ + hledger-web \ + ' + +BINARIES := '\ + hledger \ + hledger-ui \ + hledger-web + ' + +INCLUDEPATHS := '\ + -ihledger-lib \ + -ihledger \ + -ihledger-ui \ + -ihledger-web \ + -ihledger-web/app \ + ' + +MAIN := 'hledger/app/hledger-cli.hs' + +# All source files in the project (plus a few strays like Setup.hs & hlint.hs). +# Used eg for building tags. Doesn't reliably catch all source files. +SOURCEFILES := '\ + dev.hs \ + hledger/*hs \ + hledger/app/*hs \ + hledger/bench/*hs \ + hledger/test/*hs \ + hledger/Hledger/*hs \ + hledger/Hledger/*/*hs \ + hledger/Hledger/*/*/*hs \ + hledger-*/*hs \ + hledger-*/app/*hs \ + hledger-*/test/*hs \ + hledger-*/Hledger/*hs \ + hledger-*/Hledger/*/*hs \ + hledger-*/Hledger/*/*/*hs \ + hledger-lib/Text/*/*hs \ + ' +# hledger-*/src/*hs \ + +HPACKFILES := '\ + hledger/*package.yaml \ + hledger-*/*package.yaml \ + ' + +CABALFILES := '\ + hledger/hledger.cabal \ + hledger-*/*.cabal \ + ' + +MANUALSOURCEFILES := '\ + doc/common.m4 \ + */*.m4.md \ + ' + +MANUALGENFILES := '\ + hledger*/hledger*.{1,5,info,txt} \ + ' + +COMMANDHELPFILES := '\ + hledger/Hledger/Cli/Commands/*.md \ + ' + +WEBTEMPLATEFILES := '\ + hledger-web/templates/* \ + ' + +WEBCODEFILES := '\ + hledger-web/static/*.js \ + hledger-web/static/*.css \ + ' + +DOCSOURCEFILES := '\ + README.md \ + CONTRIBUTING.md' \ + + MANUALSOURCEFILES \ + + COMMANDHELPFILES + +TESTFILES := '\ + hledger/test/*.test \ + hledger/test/*/*.test \ + hledger/test/*/*/*.test \ + ' + +# # file(s) which require recompilation for a build to have an up-to-date version string +# VERSIONSOURCEFILE := 'hledger/Hledger/Cli/Version.hs' + +# Two or three-part version string, set as program version in builds made by this makefile. +# We use hledger CLI's current version (XXX for all packages, which isn't quite right). +export VERSION := `cat hledger/.version` + +# Flags for ghc builds. + +# Warnings to see during dev tasks like make ghci*. See also the warnings in package.yamls. +# XXX redundant with package.yamls ? +WARNINGS := '\ + -Wall \ + -Wno-incomplete-uni-patterns \ + -Wno-missing-signatures \ + -Wno-orphans \ + -Wno-type-defaults \ + -Wno-unused-do-bind \ + ' + +# if you have need to try building in less memory +GHCLOWMEMFLAGS := '' # '+RTS -M200m -RTS' + +# ghc-only builds need the macro definitions generated by cabal +# from cabal's dist or dist-sandbox dir, hopefully there's just one: +#CABALMACROSFLAGS := '-optP-include -optP hledger/dist*/build/autogen/cabal_macros.h' +# or from stack's dist dir: +#CABALMACROSFLAGS := '-optP-include -optP hledger/.stack-work/dist/*/*/build/autogen/cabal_macros.h' +CABALMACROSFLAGS := '' + +BUILDFLAGS := \ + '-rtsopts ' \ + + WARNINGS \ + + GHCLOWMEMFLAGS \ + + CABALMACROSFLAGS \ + + ' -DDEVELOPMENT' \ + + ' -DVERSION=\"'+VERSION+'\"' \ + + INCLUDEPATHS \ + +# -fplugin Debug.Breakpoint \ +# -fhide-source-paths \ + +# PROFBUILDFLAGS := '-prof -fprof-auto -osuf hs_p' + +TIME := "{{ shell date +'%Y%m%d%H%M' }}" +MONTHYEAR := "{{ shell date +'%B %Y' }}" + + +# ** misc + +# sym-link some directories required by hledger-web dev builds +mkwebdirs: + echo "#ln -sf hledger-web/config # disabled, causes makeinfo warnings" + ln -sf hledger-web/messages + ln -sf hledger-web/static + ln -sf hledger-web/templates + + +# ** GHCI + +# run GHCI on hledger-lib + hledger +@ghci: + {{ STACKGHCI }} exec -- {{ GHCI }} {{ BUILDFLAGS }} hledger/Hledger/Cli.hs + +# run GHCI on hledger-lib + hledger with profiling/call stack information +@ghci-prof: + stack build --profile hledger --only-dependencies + {{ STACKGHCI }} exec -- {{ GHCI }} {{ BUILDFLAGS }} -fexternal-interpreter -prof -fprof-auto hledger/Hledger/Cli.hs + +# # run GHCI on hledger-lib + hledger + dev.hs script +# @ghci-dev: +# {{ STACKGHCI }} exec -- {{ GHCI }} {{ BUILDFLAGS }} -fno-warn-unused-imports -fno-warn-unused-binds dev.hs + +# run GHCI on hledger-lib + hledger + hledger-ui +@ghci-ui: + {{ STACKGHCI }} exec -- {{ GHCI }} {{ BUILDFLAGS }} hledger-ui/Hledger/UI/Main.hs + +# run GHCI on hledger-lib + hledger + hledger-web +@ghci-web: + {{ STACKGHCI }} exec -- {{ GHCI }} {{ BUILDFLAGS }} hledger-web/app/main.hs + +# run GHCI on hledger-lib + hledger + hledger-web + hledger-web test suite +@ghci-web-test: + {{ STACKGHCI }} exec -- {{ GHCI }} {{ BUILDFLAGS }} hledger-web/test/test.hs + +# # better than stack exec ? +# # XXX does not see changes to files +# # run GHCI on hledger-lib + test runner +# ghci-lib-test: +# {{ STACKGHCI }} ghci --ghc-options="\'-rtsopts {{ WARNINGS }} -ihledger-lib -DDEVELOPMENT -DVERSION=\"1.26.99\"\'" hledger-lib/test/unittest.hs + +# run GHCI on all the hledger +# ghci-all: +# {{ STACK }} exec -- {{ GHCI }} {{ BUILDFLAGS }} \ +# hledger-ui/Hledger/UI/Main.hs \ +# hledger-web/app/main.hs \ + +# run GHCI on hledger-lib doctests +@ghci-doctest: + cd hledger-lib; {{ STACKGHCI }} ghci hledger-lib:test:doctest + +# run GHCI on Shake.hs +@ghci-shake: + {{ STACK }} exec {{ SHAKEDEPS }} -- ghci Shake.hs + + +# ** ghcid + +# run ghcid on hledger-lib + hledger +@ghcid: + ghcid -c 'just ghci' + +# run ghcid autobuilder on hledger-lib + hledger + hledger-ui +@ghcid-ui: + ghcid -c 'just ghci-ui' + +# run ghcid autobuilder on hledger-lib + hledger + hledger-web +@ghcid-web: + ghcid -c 'just ghci-web' + +# run ghcid autobuilding and running hledger-web with sample journal on port 5001 +@ghcid-web-run: + ghcid -c 'just ghci-web' --test ':main -f examples/sample.journal --port 5001 --serve' + +# # run ghcid autobuilding and running the test command +# ghcid-test: +# ghcid -c 'just ghci' --test ':main test -- --color=always' + +# # run ghcid autobuilding and running the test command with this TESTPATTERN +# ghcid-test-%: +# ghcid -c 'just ghci' --test ':main test -- --color=always -p$*' + +# run ghcid autobuilding and running hledger-lib doctests +@ghcid-doctest: + ghcid -c 'cd hledger-lib; {{ STACK }} ghci hledger-lib:test:doctest' --test ':main' --reload hledger-lib + +GHCIDRESTART := '--restart Makefile --restart Makefile.local' +GHCIDRELOAD := '--reload t.j --reload t.timedot' +GHCIDCMD := ':main -f t.j bal date:today -S' + +# # run ghcid autobuilding and running a custom GHCI command with reload/restart on certain files - customise this +# ghcid-watch watch: +# ghcid -c 'just ghci' --test '{{ GHCIDCMD }}' {{ GHCIDRELOAD }} {{ GHCIDRESTART }} + +# keep synced with Shake.hs header +SHAKEDEPS := '\ + --package base-prelude \ + --package directory \ + --package extra \ + --package process \ + --package regex \ + --package safe \ + --package shake \ + --package time \ + ' +# --package hledger-lib \ # for Hledger.Utils.Debug + +# run ghcid autobuilder on Shake.hs +ghcid-shake: + stack exec {{ SHAKEDEPS }} -- ghcid Shake.hs + + +# ** dev.hs script + +# # hledger-lib/Hledger/Read/TimeclockReaderPP.hs +# # build the dev.hs script for quick experiments (with ghc) +# dev: +# {{ STACK }} ghc -- {{ CABALMACROSFLAGS }} -ihledger-lib dev.hs \ + +# # to get profiling deps installed, first do something like: +# # stack build --library-profiling hledger-lib timeit criterion +# # build the dev.hs script with profiling support +# devprof: +# {{ STACK }} ghc -- {{ CABALMACROSFLAGS }} -ihledger-lib dev.hs -rtsopts -prof -fprof-auto -osuf p_o -o devprof + +# # get a time & space profile of the dev.hs script +# dev-profile: +# time ./devprof +RTS -P \ +# && cp devprof.prof devprof.prof.{{ TIME }} \ +# && profiterole devprof.prof + +# # get heap profiles of the dev.hs script +# dev-heap: +# time ./devprof +RTS -hc -L1000 && cp devprof.hp devprof-hc.hp && hp2ps devprof-hc.hp +# time ./devprof +RTS -hr -L1000 && cp devprof.hp devprof-hr.hp && hp2ps devprof-hr.hp + +# dev-heap-upload: +# curl -F "file=@devprof-hc.hp" -F "title='hledger parser'" http://heap.ezyang.com/upload +# curl -F "file=@devprof-hr.hp" -F "title='hledger parser'" http://heap.ezyang.com/upload + + +# ** special builds + +# build the hledger package showing GHC codegen times/allocations +@buildtimes: + time ({{ STACK }} build hledger --force-dirty --ghc-options='-fforce-recomp -ddump-timings' 2>&1 | grep -E '\bCodeGen \[.*time=') + +# # build an unoptimised hledger at bin/hledger.EXT.unopt (default: git describe) +# build-unopt *EXT: +# #!/usr/bin/env bash +# ext={{ if EXT == '' { `git describe --tags` } else { EXT } }} +# exe="bin/hledger.$ext.unopt" +# {{ STACK }} --verbosity=error install --ghc-options=-O0 hledger --local-bin-path=bin +# mv bin/hledger "$exe" +# echo "$exe" + +# # build hledger with profiling enabled at bin/hledgerprof +# hledgerprof: +# # {{ STACK }} --verbosity=error install --local-bin-path=bin hledger +# {{ STACK }} build --profile hledger +# # hledger-lib --ghc-options=-fprof-auto +# # @echo "to profile, use {{ STACK }} exec --profile -- hledger ..." + +# # build "bin/hledgercov" for coverage reports (with ghc) +# hledgercov: +# {{ STACK }} ghc {{ MAIN }} -fhpc -o bin/hledgercov -outputdir .hledgercovobjs {{ BUILDFLAGS }} + + + +# ** installing + +# # copy the current ~/.local/bin/hledger to bin/old/hledger-VER +# @copy-as VER: +# cp ~/.local/bin/hledger bin/old/hledger-{{ VER }}; echo "bin/hledger-{{ VER }}" + +# stack install, then copy the hledger executables to bin/old/hledger*-VER +@installas VER: + {{ STACK }} install --local-bin-path bin/old + for e in hledger hledger-ui hledger-web ; do cp bin/old/$e bin/old/$e-{{ VER }}; echo "bin/$e-{{ VER }}"; done + +# # make must be GNU Make 4.3+ +# .PHONY: shellcompletions +# # update shell completions in hledger package +# shellcompletions: +# make -C hledger/shell-completion/ clean-all all + + +# ** pushing + +# push to github CI, wait for tests to pass, then push to master +@push: + tools/push + # ** releasing @@ -68,7 +458,9 @@ relprep VER: # assumes the github remote is named "github" git push -f github HEAD:binaries -# *** hledger version numbers + +# *** hledger version number helpers +# (as hidden recipes, since just doesn't support global custom functions) # See doc/RELEASING.md > Glossary. # First 0-2 parts of a dotted version number. @@ -110,7 +502,8 @@ _versionReleaseBranch VER: echo "$MAJOR-branch" fi -# *** git + +# *** git helpers # Does the named branch exist in this git repo ? @_gitBranchExists BRANCH: @@ -125,24 +518,24 @@ _gitSwitchAutoCreate BRANCH: git switch -c {{ BRANCH }} fi -# ** installing - -STACK := 'stack' -# stack install, then move the hledger executables to bin/old/hledger*-VER -@install-as VER: - {{ STACK }} install --local-bin-path bin/old - for e in hledger hledger-ui hledger-web ; do mv bin/old/$e bin/old/$e-{{ VER }}; echo "bin/$e-{{ VER }}"; done +# ** misc -# copy the hledger executables from ~/.local/bin to bin/old/hledger*-VER -@copy-as VER: - for e in hledger hledger-ui hledger-web ; do cp ~/.local/bin/$e bin/old/$e-{{ VER }}; echo "bin/$e-{{ VER }}"; done +# run some tests to validate the development environment +# check-setup: +# run some tests to validate the development environment\ +# ) +# @echo sanity-checking developer environment: +# @({{ SHELLTEST }} checks \ +# && echo $@ PASSED) || echo $@ FAILED -# copy just the hledger executable from ~/.local/bin to bin/old/hledger-VER -copy1-as VER: - cp ~/.local/bin/hledger bin/old/hledger-{{ VER }}; echo "bin/hledger-{{ VER }}" +# show the sorted, unique files matched by SOURCEFILES +@listsourcefiles: + for f in {{ SOURCEFILES }}; do echo $f; done | sort | uniq -# ** misc +# show the sorted, unique subdirectories containing hs files +@listsourcedirs: + find . -name '*hs' | sed -e 's%[^/]*hs$%%' | sort | uniq # Show last week's activity, for TWIH @lastweek: From 5798a73a9617fa4a5752ace43b50dba60a560592 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 9 Dec 2023 10:49:11 -1000 Subject: [PATCH 03/13] ;just: format --- justfile | 112 +++++++++++++++++-------------------------------------- 1 file changed, 34 insertions(+), 78 deletions(-) diff --git a/justfile b/justfile index f9cba64b8be..e885aa5309c 100644 --- a/justfile +++ b/justfile @@ -6,8 +6,6 @@ # https://cheatography.com/linux-china/cheat-sheets/justfile Cheatsheet # https://github.com/casey/just/discussions # See also Makefile, Shake.hs. - - # ** prelude @help: @@ -19,53 +17,55 @@ @_fmt: just -q _check || just --fmt --unstable - # ** vars - # GHC-compiled executables require a locale (and not just C) or they # will die on encountering non-ascii data. Set LANG to something if not already set. # export LANG? := 'en_US.UTF-8' - # command to run during profiling (time and heap) + PROFCMD := 'stack exec --profile -- hledger balance -f examples/10000x1000x10.journal >/dev/null' #PROFRTSFLAGS := '-p' + PROFRTSFLAGS := '-P' # # command to run during "make coverage" # COVCMD := 'test' # COVCMD := '-f test-wf.csv print' - # misc. system tools + BROWSE := 'open' + # VIEWHTML := '{{ BROWSE }}' # VIEWPDF := '{{ BROWSE }}' # PRINT := 'lpr' - #GHC := 'ghc' -GHCI := 'ghci' #-package ghc-datasize #-package ghc-heap-view + +GHCI := 'ghci' + # GHCPKG := 'ghc-pkg' # HADDOCK := 'haddock' # CABAL := 'cabal' # CABALINSTALL := 'cabal install -w {{ GHC }}' - # Which stack command (and in particular, stack yaml/GHC version) to use for building etc. ? + STACK := 'stack' + #STACK := 'stack --stack-yaml=stack8.10.yaml' # Or override temporarily with an env var: # STACK := '"stack --stack-yaml=stack8.10.yaml" make functest' - # Which stack command (stack yaml, GHC version) to use for ghci[d] operations ? + STACKGHCI := STACK -#STACKGHCI := 'stack --stack-yaml=stack9.2.yaml' +#STACKGHCI := 'stack --stack-yaml=stack9.2.yaml' # if using an unreleased stack with a newer hpack than the one mentioned in */*.cabal, # it will give warnings. To silence these, put the old hpack-X.Y in $PATH and uncomment: #STACK := 'stack --with-hpack=hpack-0.20' - # --threads := '16 sometimes gives "commitAndReleaseBuffer: resource vanished (Broken pipe)" but seems harmless' # --timeout := 'N is not much use here - can be defeated by multiple threads, unoptimised builds, ' # slow hackage index or compiler setup on first build, etc. + SHELLTESTOPTS := '--execdir --threads=64 --exclude=/_' # make sure shelltest is a released version of shelltestrunner @@ -73,23 +73,20 @@ SHELLTESTOPTS := '--execdir --threads=64 --exclude=/_' # SHELLTEST := 'COLUMNS=80 PATH=~/.local/bin:/usr/bin:/bin shelltest {{ SHELLTESTOPTS }}' # run shell tests using the stack build of hledger #SHELLTESTSTK := 'shelltest -w `stack exec which hledger` {{ SHELLTESTOPTS }}' -SHELLTESTSTK := 'COLUMNS=80 ' + STACK + ' exec -- shelltest ' + SHELLTESTOPTS +SHELLTESTSTK := 'COLUMNS=80 ' + STACK + ' exec -- shelltest ' + SHELLTESTOPTS WATCHEXEC := 'watchexec' - PACKAGES := '\ hledger-lib \ hledger \ hledger-ui \ hledger-web \ ' - BINARIES := '\ hledger \ hledger-ui \ hledger-web ' - INCLUDEPATHS := '\ -ihledger-lib \ -ihledger \ @@ -97,11 +94,11 @@ INCLUDEPATHS := '\ -ihledger-web \ -ihledger-web/app \ ' - MAIN := 'hledger/app/hledger-cli.hs' # All source files in the project (plus a few strays like Setup.hs & hlint.hs). # Used eg for building tags. Doesn't reliably catch all source files. + SOURCEFILES := '\ dev.hs \ hledger/*hs \ @@ -119,46 +116,37 @@ SOURCEFILES := '\ hledger-*/Hledger/*/*/*hs \ hledger-lib/Text/*/*hs \ ' + # hledger-*/src/*hs \ HPACKFILES := '\ hledger/*package.yaml \ hledger-*/*package.yaml \ ' - CABALFILES := '\ hledger/hledger.cabal \ hledger-*/*.cabal \ ' - MANUALSOURCEFILES := '\ doc/common.m4 \ */*.m4.md \ ' - MANUALGENFILES := '\ hledger*/hledger*.{1,5,info,txt} \ ' - COMMANDHELPFILES := '\ hledger/Hledger/Cli/Commands/*.md \ ' - WEBTEMPLATEFILES := '\ hledger-web/templates/* \ ' - WEBCODEFILES := '\ hledger-web/static/*.js \ hledger-web/static/*.css \ ' - DOCSOURCEFILES := '\ README.md \ - CONTRIBUTING.md' \ - + MANUALSOURCEFILES \ - + COMMANDHELPFILES - + CONTRIBUTING.md' + MANUALSOURCEFILES + COMMANDHELPFILES TESTFILES := '\ hledger/test/*.test \ hledger/test/*/*.test \ @@ -167,15 +155,15 @@ TESTFILES := '\ # # file(s) which require recompilation for a build to have an up-to-date version string # VERSIONSOURCEFILE := 'hledger/Hledger/Cli/Version.hs' - # Two or three-part version string, set as program version in builds made by this makefile. # We use hledger CLI's current version (XXX for all packages, which isn't quite right). + export VERSION := `cat hledger/.version` # Flags for ghc builds. - # Warnings to see during dev tasks like make ghci*. See also the warnings in package.yamls. # XXX redundant with package.yamls ? + WARNINGS := '\ -Wall \ -Wno-incomplete-uni-patterns \ @@ -186,33 +174,25 @@ WARNINGS := '\ ' # if you have need to try building in less memory -GHCLOWMEMFLAGS := '' # '+RTS -M200m -RTS' + +GHCLOWMEMFLAGS := '' # ghc-only builds need the macro definitions generated by cabal # from cabal's dist or dist-sandbox dir, hopefully there's just one: #CABALMACROSFLAGS := '-optP-include -optP hledger/dist*/build/autogen/cabal_macros.h' # or from stack's dist dir: #CABALMACROSFLAGS := '-optP-include -optP hledger/.stack-work/dist/*/*/build/autogen/cabal_macros.h' -CABALMACROSFLAGS := '' -BUILDFLAGS := \ - '-rtsopts ' \ - + WARNINGS \ - + GHCLOWMEMFLAGS \ - + CABALMACROSFLAGS \ - + ' -DDEVELOPMENT' \ - + ' -DVERSION=\"'+VERSION+'\"' \ - + INCLUDEPATHS \ +CABALMACROSFLAGS := '' +BUILDFLAGS := '-rtsopts ' + WARNINGS + GHCLOWMEMFLAGS + CABALMACROSFLAGS + ' -DDEVELOPMENT' + ' -DVERSION=\"' + VERSION + '\"' + INCLUDEPATHS # -fplugin Debug.Breakpoint \ # -fhide-source-paths \ - # PROFBUILDFLAGS := '-prof -fprof-auto -osuf hs_p' TIME := "{{ shell date +'%Y%m%d%H%M' }}" MONTHYEAR := "{{ shell date +'%B %Y' }}" - # ** misc # sym-link some directories required by hledger-web dev builds @@ -222,7 +202,6 @@ mkwebdirs: ln -sf hledger-web/static ln -sf hledger-web/templates - # ** GHCI # run GHCI on hledger-lib + hledger @@ -255,7 +234,6 @@ mkwebdirs: # # run GHCI on hledger-lib + test runner # ghci-lib-test: # {{ STACKGHCI }} ghci --ghc-options="\'-rtsopts {{ WARNINGS }} -ihledger-lib -DDEVELOPMENT -DVERSION=\"1.26.99\"\'" hledger-lib/test/unittest.hs - # run GHCI on all the hledger # ghci-all: # {{ STACK }} exec -- {{ GHCI }} {{ BUILDFLAGS }} \ @@ -270,7 +248,6 @@ mkwebdirs: @ghci-shake: {{ STACK }} exec {{ SHAKEDEPS }} -- ghci Shake.hs - # ** ghcid # run ghcid on hledger-lib + hledger @@ -285,14 +262,13 @@ mkwebdirs: @ghcid-web: ghcid -c 'just ghci-web' -# run ghcid autobuilding and running hledger-web with sample journal on port 5001 +# run ghcid autobuilding and running hledger-web with sample journal on port 5001 @ghcid-web-run: ghcid -c 'just ghci-web' --test ':main -f examples/sample.journal --port 5001 --serve' # # run ghcid autobuilding and running the test command # ghcid-test: # ghcid -c 'just ghci' --test ':main test -- --color=always' - # # run ghcid autobuilding and running the test command with this TESTPATTERN # ghcid-test-%: # ghcid -c 'just ghci' --test ':main test -- --color=always -p$*' @@ -302,14 +278,14 @@ mkwebdirs: ghcid -c 'cd hledger-lib; {{ STACK }} ghci hledger-lib:test:doctest' --test ':main' --reload hledger-lib GHCIDRESTART := '--restart Makefile --restart Makefile.local' -GHCIDRELOAD := '--reload t.j --reload t.timedot' -GHCIDCMD := ':main -f t.j bal date:today -S' +GHCIDRELOAD := '--reload t.j --reload t.timedot' +GHCIDCMD := ':main -f t.j bal date:today -S' # # run ghcid autobuilding and running a custom GHCI command with reload/restart on certain files - customise this # ghcid-watch watch: # ghcid -c 'just ghci' --test '{{ GHCIDCMD }}' {{ GHCIDRELOAD }} {{ GHCIDRESTART }} - # keep synced with Shake.hs header + SHAKEDEPS := '\ --package base-prelude \ --package directory \ @@ -320,42 +296,35 @@ SHAKEDEPS := '\ --package shake \ --package time \ ' + # --package hledger-lib \ # for Hledger.Utils.Debug # run ghcid autobuilder on Shake.hs ghcid-shake: stack exec {{ SHAKEDEPS }} -- ghcid Shake.hs - # ** dev.hs script - # # hledger-lib/Hledger/Read/TimeclockReaderPP.hs -# # build the dev.hs script for quick experiments (with ghc) +# # build the dev.hs script for quick experiments (with ghc) # dev: # {{ STACK }} ghc -- {{ CABALMACROSFLAGS }} -ihledger-lib dev.hs \ - # # to get profiling deps installed, first do something like: # # stack build --library-profiling hledger-lib timeit criterion -# # build the dev.hs script with profiling support +# # build the dev.hs script with profiling support # devprof: # {{ STACK }} ghc -- {{ CABALMACROSFLAGS }} -ihledger-lib dev.hs -rtsopts -prof -fprof-auto -osuf p_o -o devprof - -# # get a time & space profile of the dev.hs script +# # get a time & space profile of the dev.hs script # dev-profile: # time ./devprof +RTS -P \ # && cp devprof.prof devprof.prof.{{ TIME }} \ # && profiterole devprof.prof - -# # get heap profiles of the dev.hs script +# # get heap profiles of the dev.hs script # dev-heap: # time ./devprof +RTS -hc -L1000 && cp devprof.hp devprof-hc.hp && hp2ps devprof-hc.hp # time ./devprof +RTS -hr -L1000 && cp devprof.hp devprof-hr.hp && hp2ps devprof-hr.hp - # dev-heap-upload: # curl -F "file=@devprof-hc.hp" -F "title='hledger parser'" http://heap.ezyang.com/upload # curl -F "file=@devprof-hr.hp" -F "title='hledger parser'" http://heap.ezyang.com/upload - - # ** special builds # build the hledger package showing GHC codegen times/allocations @@ -370,45 +339,36 @@ ghcid-shake: # {{ STACK }} --verbosity=error install --ghc-options=-O0 hledger --local-bin-path=bin # mv bin/hledger "$exe" # echo "$exe" - # # build hledger with profiling enabled at bin/hledgerprof # hledgerprof: # # {{ STACK }} --verbosity=error install --local-bin-path=bin hledger # {{ STACK }} build --profile hledger # # hledger-lib --ghc-options=-fprof-auto # # @echo "to profile, use {{ STACK }} exec --profile -- hledger ..." - -# # build "bin/hledgercov" for coverage reports (with ghc) +# # build "bin/hledgercov" for coverage reports (with ghc) # hledgercov: # {{ STACK }} ghc {{ MAIN }} -fhpc -o bin/hledgercov -outputdir .hledgercovobjs {{ BUILDFLAGS }} - - - # ** installing - # # copy the current ~/.local/bin/hledger to bin/old/hledger-VER # @copy-as VER: # cp ~/.local/bin/hledger bin/old/hledger-{{ VER }}; echo "bin/hledger-{{ VER }}" # stack install, then copy the hledger executables to bin/old/hledger*-VER @installas VER: - {{ STACK }} install --local-bin-path bin/old - for e in hledger hledger-ui hledger-web ; do cp bin/old/$e bin/old/$e-{{ VER }}; echo "bin/$e-{{ VER }}"; done + {{ STACK }} install --local-bin-path bin/old + for e in hledger hledger-ui hledger-web ; do cp bin/old/$e bin/old/$e-{{ VER }}; echo "bin/$e-{{ VER }}"; done # # make must be GNU Make 4.3+ # .PHONY: shellcompletions # # update shell completions in hledger package # shellcompletions: # make -C hledger/shell-completion/ clean-all all - - # ** pushing # push to github CI, wait for tests to pass, then push to master @push: tools/push - # ** releasing # Symlink/copy important files temporarily in .relfiles/. @@ -458,7 +418,6 @@ relprep VER: # assumes the github remote is named "github" git push -f github HEAD:binaries - # *** hledger version number helpers # (as hidden recipes, since just doesn't support global custom functions) # See doc/RELEASING.md > Glossary. @@ -502,7 +461,6 @@ _versionReleaseBranch VER: echo "$MAJOR-branch" fi - # *** git helpers # Does the named branch exist in this git repo ? @@ -518,9 +476,7 @@ _gitSwitchAutoCreate BRANCH: git switch -c {{ BRANCH }} fi - # ** misc - # run some tests to validate the development environment # check-setup: # run some tests to validate the development environment\ From 4333694bd3fc97fadaf71477bedbd86c476ed295 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 9 Dec 2023 11:36:49 -1000 Subject: [PATCH 04/13] ;just: show some group headings; cleanup --- justfile | 58 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/justfile b/justfile index e885aa5309c..54e031fc592 100644 --- a/justfile +++ b/justfile @@ -193,17 +193,10 @@ BUILDFLAGS := '-rtsopts ' + WARNINGS + GHCLOWMEMFLAGS + CABALMACROSFLAGS + ' -DD TIME := "{{ shell date +'%Y%m%d%H%M' }}" MONTHYEAR := "{{ shell date +'%B %Y' }}" -# ** misc - -# sym-link some directories required by hledger-web dev builds -mkwebdirs: - echo "#ln -sf hledger-web/config # disabled, causes makeinfo warnings" - ln -sf hledger-web/messages - ln -sf hledger-web/static - ln -sf hledger-web/templates - # ** GHCI +GHCI: + # run GHCI on hledger-lib + hledger @ghci: {{ STACKGHCI }} exec -- {{ GHCI }} {{ BUILDFLAGS }} hledger/Hledger/Cli.hs @@ -250,6 +243,8 @@ mkwebdirs: # ** ghcid +GHCID: + # run ghcid on hledger-lib + hledger @ghcid: ghcid -c 'just ghci' @@ -325,7 +320,9 @@ ghcid-shake: # dev-heap-upload: # curl -F "file=@devprof-hc.hp" -F "title='hledger parser'" http://heap.ezyang.com/upload # curl -F "file=@devprof-hr.hp" -F "title='hledger parser'" http://heap.ezyang.com/upload -# ** special builds +# ** building + +BUILDING: # build the hledger package showing GHC codegen times/allocations @buildtimes: @@ -349,6 +346,9 @@ ghcid-shake: # hledgercov: # {{ STACK }} ghc {{ MAIN }} -fhpc -o bin/hledgercov -outputdir .hledgercovobjs {{ BUILDFLAGS }} # ** installing + +INSTALLING: + # # copy the current ~/.local/bin/hledger to bin/old/hledger-VER # @copy-as VER: # cp ~/.local/bin/hledger bin/old/hledger-{{ VER }}; echo "bin/hledger-{{ VER }}" @@ -363,14 +363,10 @@ ghcid-shake: # # update shell completions in hledger package # shellcompletions: # make -C hledger/shell-completion/ clean-all all -# ** pushing - -# push to github CI, wait for tests to pass, then push to master -@push: - tools/push - # ** releasing +RELEASING: + # Symlink/copy important files temporarily in .relfiles/. relfiles: #!/usr/bin/env bash @@ -477,6 +473,13 @@ _gitSwitchAutoCreate BRANCH: fi # ** misc + +MISC: + +# push to github CI, wait for tests to pass, then push to master +@push: + tools/push + # run some tests to validate the development environment # check-setup: # run some tests to validate the development environment\ @@ -485,16 +488,15 @@ _gitSwitchAutoCreate BRANCH: # @({{ SHELLTEST }} checks \ # && echo $@ PASSED) || echo $@ FAILED -# show the sorted, unique files matched by SOURCEFILES -@listsourcefiles: - for f in {{ SOURCEFILES }}; do echo $f; done | sort | uniq - -# show the sorted, unique subdirectories containing hs files -@listsourcedirs: - find . -name '*hs' | sed -e 's%[^/]*hs$%%' | sort | uniq +# sym-link some directories required by hledger-web dev builds +mkwebdirs: + echo "#ln -sf hledger-web/config # disabled, causes makeinfo warnings" + ln -sf hledger-web/messages + ln -sf hledger-web/static + ln -sf hledger-web/templates # Show last week's activity, for TWIH -@lastweek: +@_lastweek: echo "hledger time last 7 days including today (this should be run on a Friday):" tt bal hledger -DTS -b '6 days ago' --drop 2 echo @@ -514,6 +516,14 @@ _gitSwitchAutoCreate BRANCH: git -C finance log --format='%C(yellow)%cd %ad %Cred%h%Creset %s %Cgreen(%an)%Creset%C(bold blue)%d%Creset' --date=short --since="6 days ago" --reverse echo +# show the sorted, unique files matched by SOURCEFILES +@_listsourcefiles: + for f in {{ SOURCEFILES }}; do echo $f; done | sort | uniq + +# show the sorted, unique subdirectories containing hs files +@_listsourcedirs: + find . -name '*hs' | sed -e 's%[^/]*hs$%%' | sort | uniq + # Show a bunch of debug messages. @_dbgmsgs: rg --sort path -t hs 'dbg.*?(".*")' -r '$1' -o From 1d69d9b71fb6994342ed2112bf2f1832981747a6 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Tue, 12 Dec 2023 15:35:31 -1000 Subject: [PATCH 05/13] just: port/copy remaining make rules (TESTING, BENCHMARKS, DOCUMENTATION, MISC) --- justfile | 732 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 723 insertions(+), 9 deletions(-) diff --git a/justfile b/justfile index 54e031fc592..2e21310ff66 100644 --- a/justfile +++ b/justfile @@ -10,6 +10,8 @@ @help: just -lu +# This and all other just invocations assume you are in this justfile's directory, +# otherwise we must write --justfile {{ justfile() }} or {{ just }} everywhere. @_check: just --fmt --unstable --check @@ -66,15 +68,6 @@ STACKGHCI := STACK # --timeout := 'N is not much use here - can be defeated by multiple threads, unoptimised builds, ' # slow hackage index or compiler setup on first build, etc. -SHELLTESTOPTS := '--execdir --threads=64 --exclude=/_' - -# make sure shelltest is a released version of shelltestrunner -# run shell tests using the executable specified in tests -# SHELLTEST := 'COLUMNS=80 PATH=~/.local/bin:/usr/bin:/bin shelltest {{ SHELLTESTOPTS }}' -# run shell tests using the stack build of hledger -#SHELLTESTSTK := 'shelltest -w `stack exec which hledger` {{ SHELLTESTOPTS }}' - -SHELLTESTSTK := 'COLUMNS=80 ' + STACK + ' exec -- shelltest ' + SHELLTESTOPTS WATCHEXEC := 'watchexec' PACKAGES := '\ hledger-lib \ @@ -345,6 +338,449 @@ BUILDING: # # build "bin/hledgercov" for coverage reports (with ghc) # hledgercov: # {{ STACK }} ghc {{ MAIN }} -fhpc -o bin/hledgercov -outputdir .hledgercovobjs {{ BUILDFLAGS }} + +# ** testing + +TESTING: + +# run tests that are reasonably quick (files, unit, functional) and benchmarks +test: filestest functest #bench + +# For quieter tests add --silent. It may hide troubleshooting info. +# For very verbose tests add --verbosity=debug. It seems hard to get something in between. +STACKTEST := STACK + ' test --fast' + +# # When doing build testing, save a little time and output noise by not +# # running tests & benchmarks. Comment this out if you want to run them. +# SKIPTESTSBENCHS := '--no-run-tests --no-run-benchmarks' + +# check all files embedded with file-embed are declared in extra-source-files +@filestest: + tools/checkembeddedfiles + +# # stack build --dry-run all hledger packages ensuring an install plan with default snapshot) +# buildplantest: +# buildplantest-stack.yaml + +# # stack build --dry-run all hledger packages ensuring an install plan with each ghc version/stackage snapshot +# buildplantest-all: +# for F in stack*.yaml; do make --no-print-directory buildplantest-$F; done + +# # stack build --dry-run all hledger packages ensuring an install plan with the given stack yaml file; eg make buildplantest-stack8.2.yaml +# buildplantest-%: +# {{ STACK }} build --dry-run --test --bench --stack-yaml=$* + +# # force-rebuild all hledger packages/modules quickly ensuring no warnings with default snapshot) +# buildtest: +# buildtest-stack.yaml + +# # force-rebuild all hledger packages/modules quickly ensuring no warnings with each ghc version/stackage snapshot +# buildtest-all: +# for F in stack*.yaml; do make --no-print-directory buildtest-$F; done + +# # force-rebuild all hledger packages/modules quickly ensuring no warnings with the given stack yaml file; eg make buildtest-stack8.2.yaml +# buildtest-%: +# {{ STACK }} build --test --bench {{ SKIPTESTSBENCHS }} --fast --force-dirty --ghc-options=-fforce-recomp --ghc-options=-Werror --stack-yaml=$* + +# # build any outdated hledger packages/modules quickly ensuring no warnings with default snapshot. Wont detect warnings in up-to-date modules.) +# incr-buildtest: +# incr-buildtest-stack.yaml + +# # build any outdated hledger packages/modules quickly ensuring no warnings with each ghc version/stackage snapshot. Wont detect warnings in up-to-date modules. +# incr-buildtest-all: +# for F in stack*.yaml; do make --no-print-directory incr-buildtest-$F; done + +# # build any outdated hledger packages/modules quickly ensuring no warnings with the stack yaml file; eg make buildtest-stack8.2.yaml. Wont detect warnings in up-to-date modules. +# incr-buildtest-%: +# {{ STACK }} build --test --bench {{ SKIPTESTSBENCHS }} --fast --ghc-options=-Werror --stack-yaml=$* + +# # do a stack clean --full with all ghc versions for paranoia/troubleshooting +# stack-clean-all: +# for F in stack*.yaml; do {{ STACK }} clean --full --stack-yaml=$F; done + +# run all test suites in the hledger packages +@pkgtest: + ({{ STACKTEST }} && echo $@ PASSED) || (echo $@ FAILED; false) + +# doctest with ghc 8.4 on mac requires a workaround, see hledger-lib/package.yaml. +# Or, could run it with ghc 8.2: +# @({{ STACKTEST }} --stack-yaml stack8.2.yaml hledger-lib:test:doctest && echo $@ PASSED) || (echo $@ FAILED; false) +# run the doctests in hledger-lib module/function docs +@doctest: + ({{ STACKTEST }} hledger-lib:test:doctest && echo $@ PASSED) || (echo $@ FAILED; false) + +# # run the unit tests in hledger-lib +# unittest: +# @({{ STACKTEST }} hledger-lib:test:unittest && echo $@ PASSED) || (echo $@ FAILED; false) + +# run hledger & hledger-lib unit tests (do a stack build hledger first). +@unittest: + ({{ STACK }} exec hledger test && echo $@ PASSED) || (echo $@ FAILED; false) + +SHELLTEST := 'COLUMNS=80 ' + STACK + ' exec -- shelltest --execdir --threads=64 --exclude=/_' +# --hide-successes + +# build hledger quickly and run functional tests, or just the ones matching PAT. (Run mktestaddons first.) +@functest *PAT: + {{ STACK }} build --fast hledger + ({{ SHELLTEST }} {{ if PAT == '' { '' } else { '-i "'+PAT+'"' } }} \ + hledger/test/ bin/ \ + -x ledger-compat/ledger-baseline -x ledger-compat/ledger-regress -x ledger-compat/ledger-extra \ + && echo $@ PASSED) || (echo $@ FAILED; false) + +ADDONEXTS := 'pl py rb sh hs lhs rkt exe com bat' + +# generate dummy add-ons for testing the CLI +@mktestaddons: + rm -rf hledger/test/addons/hledger-* + printf '#!/bin/sh\necho add-on: $0\necho args: $*\n' >hledger/test/addons/hledger-addon + for E in '' {{ ADDONEXTS }}; do \ + cp hledger/test/addons/hledger-addon hledger/test/addons/hledger-addon.$E; done + for F in addon. addon2 addon2.hs addon3.exe addon3.lhs addon4.exe add reg; do \ + cp hledger/test/addons/hledger-addon hledger/test/addons/hledger-$F; done + mkdir hledger/test/addons/hledger-addondir + chmod +x hledger/test/addons/hledger-* + +# generate a hlint report +# hlinttest hlint: +# hlint --hint=hlint --report=hlint.html {{ SOURCEFILES }} + +# # run haddock to make sure it can generate docs without dying +# @haddocktest: +# (make --quiet haddock && echo $@ PASSED) || (echo $@ FAILED; false) + +# # run cabal check to test cabal file syntax +# cabalfiletest: +# @(make --no-print-directory cabalcheck && echo $@ PASSED) || (echo $@ FAILED; false) + +# test-stack%yaml: +# {{ STACK }} --stack-yaml stack$*yaml clean +# {{ STACK }} --stack-yaml stack$*yaml build --ghc-options="{{ WARNINGS }} -Werror" --test --bench --haddock --no-haddock-deps + +# committest: hlinttest unittest doctest functest haddocktest buildtest quickcabaltest \ +# + +# releasetest: Clean unittest functest fullcabaltest haddocktest #buildtest doctest \ +# {{ call def-help,releasetest,pre-release tests }} + +# run hledger-install.sh not from inside a haskell project +installtest: + cd; {{ justfile_directory() }}/hledger-install/hledger-install.sh + +# ** benchmarking + +BENCHMARKING: + +# generate standard sample journals in examples/ +mksamplejournals: + +# samplejournals: $(call def-help,samplejournals, regenerate standard sample journals in examples/) \ +# examples/sample.journal \ +# examples/10x10x10.journal \ +# examples/100x100x10.journal \ +# examples/1000x1000x10.journal \ +# examples/1000x10000x10.journal \ +# examples/2000x1000x10.journal \ +# examples/3000x1000x10.journal \ +# examples/4000x1000x10.journal \ +# examples/5000x1000x10.journal \ +# examples/6000x1000x10.journal \ +# examples/7000x1000x10.journal \ +# examples/8000x1000x10.journal \ +# examples/9000x1000x10.journal \ +# examples/10000x1000x10.journal \ +# examples/10000x10000x10.journal \ +# examples/100000x1000x10.journal \ +# examples/1000000x1000x10.journal \ +# # examples/ascii.journal \ +# # examples/chinese.journal \ +# # examples/mixed.journal \ + +# examples/sample.journal: +# true # XXX should probably regenerate this + +# examples/10x10x10.journal: tools/generatejournal +# tools/generatejournal 10 10 10 >$@ + +# examples/100x100x10.journal: tools/generatejournal +# tools/generatejournal 100 100 10 >$@ + +# examples/1000x1000x10.journal: tools/generatejournal +# tools/generatejournal 1000 1000 10 >$@ + +# examples/1000x10000x10.journal: tools/generatejournal +# tools/generatejournal 1000 10000 10 >$@ + +# examples/2000x1000x10.journal: tools/generatejournal +# tools/generatejournal 2000 1000 10 >$@ + +# examples/3000x1000x10.journal: tools/generatejournal +# tools/generatejournal 3000 1000 10 >$@ + +# examples/4000x1000x10.journal: tools/generatejournal +# tools/generatejournal 4000 1000 10 >$@ + +# examples/5000x1000x10.journal: tools/generatejournal +# tools/generatejournal 5000 1000 10 >$@ + +# examples/6000x1000x10.journal: tools/generatejournal +# tools/generatejournal 6000 1000 10 >$@ + +# examples/7000x1000x10.journal: tools/generatejournal +# tools/generatejournal 7000 1000 10 >$@ + +# examples/8000x1000x10.journal: tools/generatejournal +# tools/generatejournal 8000 1000 10 >$@ + +# examples/9000x1000x10.journal: tools/generatejournal +# tools/generatejournal 9000 1000 10 >$@ + +# examples/10000x1000x10.journal: tools/generatejournal +# tools/generatejournal 10000 1000 10 >$@ + +# examples/10000x10000x10.journal: tools/generatejournal +# tools/generatejournal 10000 10000 10 >$@ + +# examples/100000x1000x10.journal: tools/generatejournal +# tools/generatejournal 100000 1000 10 >$@ + +# examples/1000000x1000x10.journal: tools/generatejournal +# tools/generatejournal 1000000 1000 10 >$@ + +# examples/ascii.journal: tools/generatejournal +# tools/generatejournal 3 5 5 >$@ + +# examples/chinese.journal: tools/generatejournal +# tools/generatejournal 3 5 5 --chinese >$@ + +# examples/mixed.journal: tools/generatejournal +# tools/generatejournal 3 5 5 --mixed >$@ + +# # hledger executables to bench test, can be overridden by env var, +# # eg: BENCHEXES=ledger,hledger-1.18,hledger make bench +# BENCHEXES ?= hledger + +# bench: quickbench + +# quickbench: samplejournals bench.sh $(call def-help,quickbench, benchmark commands in bench.sh with quickbench and $(BENCHEXES)) +# @echo; echo "run quick performance benchmarks in bench.sh (approximate, can be skewed):" +# @which quickbench >/dev/null && quickbench -w $(BENCHEXES) || echo "quickbench not installed (see bench.sh), skipping" + +# # bench: samplejournals tests/bench.tests tools/simplebench \ +# # $(call def-help,bench,\ +# # run simple performance benchmarks and archive results\ +# # Requires some commands defined in tests/bench.tests and some BENCHEXES defined above.\ +# # ) +# # tools/simplebench -v -ftests/bench.tests $(BENCHEXES) | tee doc/profs/$(TIME).bench +# # @rm -f benchresults.* +# # @(cd doc/profs; rm -f latest.bench; ln -s $(TIME).bench latest.bench) + +# # criterionbench: samplejournals tools/criterionbench \ +# # $(call def-help,criterionbench,\ +# # run criterion benchmark tests and save graphical results\ +# # ) +# # tools/criterionbench -t png -k png + +# # progressionbench: samplejournals tools/progressionbench \ +# # $(call def-help,progressionbench,\ +# # run progression benchmark tests and save graphical results\ +# # ) +# # tools/progressionbench -- -t png -k png + +# throughput: throughput-hledger \ +# $(call def-help,throughput, show throughput at various data sizes with the default hledger executable ) + +# throughput-%: samplejournals \ +# $(call def-help,throughput-HLEDGEREXE, show throughput at various data sizes with the given hledger executable ) +# @echo date: `date` +# @echo system: `uname -a` +# @echo executable: $* +# @echo version: `$* --version` +# @for n in 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 100000 ; do \ +# printf "%6d txns: " $$n; $* stats -f examples/$${n}x1000x10.journal | tail -1; \ +# done +# @date + +# throughput-dev: samplejournals \ +# $(call def-help,throughput-dev, show throughput at various data sizes with the latest hledger dev build (optimised or not) ) +# @stack build hledger +# @stack exec -- make -s throughput + +# # prof: samplejournals \ +# # $(call def-help,prof,\ +# # generate and archive an execution profile\ +# # ) #bin/hledgerprof +# # @echo "Profiling: $(PROFCMD)" +# # -$(PROFCMD) +RTS $(PROFRTSFLAGS) -RTS +# # mv hledgerprof.prof doc/profs/$(TIME).prof +# # (cd doc/profs; rm -f latest*.prof; ln -s $(TIME).prof latest.prof) + +# # viewprof: prof \ +# # $(call def-help,viewprof,\ +# # generate, archive, simplify and display an execution profile\ +# # ) +# # tools/simplifyprof.hs doc/profs/latest.prof + +# quickprof-%: hledgerprof samplejournals \ +# $(call def-help,quickprof-"CMD", run some command against a standard sample journal and display the execution profile ) +# $(STACK) exec --profile -- hledger +RTS $(PROFRTSFLAGS) -RTS $* -f examples/1000x1000x10.journal >/dev/null +# profiterole hledger.prof +# @echo +# @head -20 hledger.prof +# @echo ... +# @echo +# @head -20 hledger.profiterole.txt +# @echo ... +# @echo +# @echo "See hledger.prof, hledger.profiterole.txt, hledger.profiterole.html for more." + +# # heap: samplejournals \ +# # $(call def-help,heap,\ +# # generate and archive a graphical heap profile\ +# # ) #bin/hledgerprof +# # @echo "Profiling heap with: $(PROFCMD)" +# # $(PROFCMD) +RTS -hc -RTS +# # mv hledgerprof.hp doc/profs/$(TIME).hp +# # (cd doc/profs; rm -f latest.hp; ln -s $(TIME).hp latest.hp; \ +# # hp2ps $(TIME).hp; rm -f latest.ps; ln -s $(TIME).ps latest.ps; rm -f *.aux) + +# # viewheap: heap \ +# # $(call def-help,viewheap,\ +# # \ +# # ) +# # $(VIEWPS) doc/profs/latest.ps + +# quickheap-%: hledgerprof samplejournals \ +# $(call def-help,quickheap-"CMD", run some command against a sample journal and display the heap profile ) +# $(STACK) exec -- hledgerprof +RTS -hc -RTS $* -f examples/10000x1000x10.journal >/dev/null +# hp2ps hledgerprof.hp +# @echo generated hledgerprof.ps +# $(VIEWPS) hledgerprof.ps + +# # quickcoverage: hledgercov \ +# # $(call def-help,quickcoverage,\ +# # display a code coverage text report from running hledger COVCMD\ +# # ) +# # @echo "Generating code coverage text report for hledger command: $(COVCMD)" +# # tools/runhledgercov "report" $(COVCMD) + +# # coverage: samplejournals hledgercov \ +# # $(call def-help,coverage,\ +# # generate a code coverage html report from running hledger COVCMD\ +# # ) +# # @echo "Generating code coverage html report for hledger command: $(COVCMD)" +# # tools/runhledgercov "markup --destdir=doc/profs/coverage" $(COVCMD) +# # cd doc/profs/coverage; rm -f index.html; ln -s hpc_index.html index.html + +# # viewcoverage: \ +# # $(call def-help,viewcoverage,\ +# # view the last html code coverage report\ +# # ) +# # $(VIEWHTML) doc/profs/coverage/index.html + +# ############################################################################### +# $(call def-help-subheading,DOCUMENTATION: (see also Shake.hs)) + +# # http://www.haskell.org/haddock/doc/html/invoking.html +# STACKHADDOCK=time $(STACK) --verbosity=error haddock --fast --no-keep-going \ +# --only-locals --no-haddock-deps --no-haddock-hyperlink-source \ +# --haddock-arguments="--no-warnings" +# # -ghc-options='-optP-P' # workaround for http://trac.haskell.org/haddock/ticket/284 + +# # uncomment to run haddock on fewer packages, saving time +# #HADDOCKPKGS=hledger-lib + +# releasediag: \ +# $(call def-help,releasediag, optimise and commit RELEASING value map diagram ) +# pngquant doc/HledgerReleaseValueMap.png -f -o doc/HledgerReleaseValueMap.png && git add doc/HledgerReleaseValueMap.png && git commit -m ';doc: RELEASING: update value map' -- doc/HledgerReleaseValueMap.png + +# # Renders all hledger packages. Run make haddock-open to open contents page. +# haddock: \ +# $(call def-help,haddock, regenerate haddock docs for the hledger packages and open them ) +# $(STACKHADDOCK) $(HADDOCKPKGS) && make -s haddock-open # --open shows all deps and packages + +# # Rerenders all hledger packages. Run make haddock-open to open contents page. +# haddock-watch1: \ +# $(call def-help,haddock-watch, regenerate haddock docs when files change ) +# $(STACKHADDOCK) $(HADDOCK_PKGS) --file-watch --exec='echo done' + +# # Rerenders hledger-lib modules, opens hledger-lib contents page. +# haddock-watch2: \ +# $(call def-help,haddock-watch2, regenerate hledger-lib haddock docs when files change ) +# watchexec -r -e yaml,cabal,hs --print-events -- \ +# $(STACKHADDOCK) --verbosity=info $(HADDOCK_PKGS) --exec="'echo done'" hledger-lib --open + +# # Rerenders/reopens the Hledger module, without submodules. (Fastest) +# haddock-watch: \ +# $(call def-help,haddock-watch3, quickly regenerate & reload Hledger.hs haddock when files change ) +# watchexec -r -e yaml,cabal,hs --print-events --shell=none -- bash -c 'mkdir -p tmp && rm -f tmp/Hledger.html && haddock -h -o tmp hledger-lib/Hledger.hs --no-warnings --no-print-missing-docs 2>&1 | grep -v "Could not find documentation" && open tmp/Hledger.html' + +# haddock-open: \ +# $(call def-help,haddock-open, open the haddock packages contents page in a browser ) +# $(BROWSE) `stack path --local-install-root`/doc/index.html + +# hoogle-setup: $(call def-help,hoogle-setup, install hoogle then build haddocks and a hoogle db for the project and all deps ) +# stack hoogle --rebuild + +# HOOGLEBROWSER="/Applications/Firefox Dev.app/Contents/MacOS/firefox" # safari not supported +# hoogle-serve: $(call def-help,hoogle-serve, run hoogle web app and open in browser after doing setup if needed ) +# $(HOOGLEBROWSER) http://localhost:8080 & +# stack --verbosity=warn hoogle --server + +# # sourcegraph: \ +# # $(call def-help,sourcegraph,\ +# # \ +# # ) +# # for p in $(PACKAGES); do (cd $$p; SourceGraph $$p.cabal); done + +# manuals-watch: Shake \ +# $(call def-help,manuals-watch, rerender manuals when their source files change ) +# ls $(DOCSOURCEFILES) | entr ./Shake -VV manuals + +# man-watch: man-watch-hledger \ +# $(call def-help,man-watch, run man on the hledger man page when its source file changes ) + +# man-watch-%: Shake \ +# $(call def-help,man-watch-PROG, run man on the given man page when its source file changes. Eg make man-watch-hledger-web ) +# $(WATCHEXEC) -r -w $*/$*.m4.md './Shake $*/$*.1 && man $*/$*.1' + +# shakehelp-watch: \ +# $(call def-help,shakehelp-watch, rerender Shake.hs's help when it changes) +# ls Shake.hs | entr -c ./Shake.hs + +# # The following rule, for updating the website, gets called on hledger.org by: +# # 1. github-post-receive (github webhook handler), when something is pushed +# # to the main or wiki repos on Github. Config: +# # /etc/supervisord.conf -> [program:github-post-receive] +# # /etc/github-post-receive.conf +# # 2. cron, nightly. Config: /etc/crontab +# # 3. manually: "make site" on hledger.org, or "make hledgerorg" elsewhere (cf Makefile.local). + + +# .PHONY: site + +# # Use the existing Shake executable without recompiling it, so as not to automatially run unreviewed code by hook ? I think this no longer applies. +# # site: $(call def-help,site-build, update the hledger.org website (run this on hledger.org, or run "make hledgerorg" elsewhere) ) +# # @[ ! -x Shake ] \ +# # && echo 'Please run "make Shake" first (manual compilation required for safety)' \ +# # || ( \ +# # echo; \ +# # ./Shake -V site; \ +# # ) 2>&1 | tee -a site.log + +# site: Shake \ +# $(call def-help,site, update the hledger.org website (run on hledger.org, or run "make hledgerorg" elsewhere) ) +# ./Shake -V site 2>&1 | tee -a site.log + + +# BROWSE=open +# BROWSEDELAY=5 +# LOCALSITEURL=http://localhost:3000/dev/hledger.html +# site-watch: $(call def-help,site-watch, open a browser on the website (in ./site) and rerender when docs or web pages change ) +# @make -s Shake +# @(printf "\nbrowser will open in $(BROWSEDELAY)s (adjust BROWSE in Makefile if needed)...\n\n"; sleep $(BROWSEDELAY); $(BROWSE) $(LOCALSITEURL)) & +# @$(WATCHEXEC) --print-events -e md,m4 -i hledger.md -i hledger-ui.md -i hledger-web.md -r './Shake webmanuals && ./Shake orgfiles && make -sC site serve' + # ** installing INSTALLING: @@ -363,6 +799,8 @@ INSTALLING: # # update shell completions in hledger package # shellcompletions: # make -C hledger/shell-completion/ clean-all all + + # ** releasing RELEASING: @@ -472,6 +910,211 @@ _gitSwitchAutoCreate BRANCH: git switch -c {{ BRANCH }} fi + +# ############################################################################### +# $(call def-help-subheading,RELEASING:) + +# # old/desired release process: +# # a normal release: echo 0.7 >.version; make release +# # a bugfix release: echo 0.7.1 >.version; make release +# #release: releasetest bumpversion tagrelease $(call def-help,release, prepare and test a release and tag the repo ) +# #publish: hackageupload pushtags $(call def-help,upload, publish latest hackage packages and push tags to github ) +# #releaseandpublish: release upload $(call def-help,releaseandpublish, release and upload and publish updated docs ) + +# ISCLEAN=git diff-index --quiet HEAD -- + +# # stop if the working directory has uncommitted changes +# iscleanwd: +# @$(ISCLEAN) || (echo "please clean the working directory first"; false) + +# # stop if the given file(s) have uncommitted changes +# isclean-%: +# @$(ISCLEAN) $* || (echo "please clean these files first: $*"; false) + +# # update all cabal files based on latest package.yaml files using stack's built-in hpack +# cabal: $(call def-help,cabal, regenerate cabal files from package.yaml files with stack ) +# $(STACK) build --dry-run --silent + +# # Update all cabal files based on latest package.yaml files using a specific hpack version. +# # To avoid warnings, this should be the same version as stack's built-in hpack. +# cabal-with-hpack-%: +# $(STACK) build --with-hpack hpack-$* --dry-run --silent + +# # updatecabal: gencabal $(call def-help,updatecabal, regenerate cabal files and commit ) +# # @read -p "please review changes then press enter to commit $(shell ls */*.cabal)" +# # git commit -m "update cabal files" $(shell ls */*.cabal) + +# # we use shake for this job; so dependencies aren't checked here +# manuals: Shake $(call def-help,manuals, regenerate and commit CLI help and manuals (might need -B) ) +# ./Shake manuals +# git commit -m ";doc: regen manuals" -m "[ci skip]" hledger*/hledger*.{1,5,info,txt} hledger/Hledger/Cli/Commands/*.txt + +# tag: $(call def-help,tag, make git release tags for the project and all packages ) +# @for p in $(PACKAGES); do make tag-$$p; done +# @make tag-project + +# tag-%: $(call def-help,tag-PKG, make a git release tag for PKG ) +# git tag -fs $*-`cat $*/.version` -m "Release $*-`cat $*/.version`" + +# tag-project: $(call def-help,tag-project, make a git release tag for the project as a whole ) +# git tag -fs `cat .version` -m "Release `cat .version`, https://hledger.org/release-notes.html#hledger-`cat .version | sed -e 's/\./-/g'`" +# @printf "if tagging a major release, please also review and run this command:\n" +# @printf " git tag -fs `cat .version`.99 master -m \"Start of next release cycle. This tag influences git describe and dev builds' version strings.\"\n" + +# # hackageupload-dry: \ +# # $(call def-help,hackageupload-dry,\ +# # upload all packages to hackage; dry run\ +# # ) +# # for p in $(PACKAGES); do cabal upload $$p/dist/$$p-$(VERSION).tar.gz -v2 --check; done + +# hackageupload: \ +# $(call def-help,hackageupload, upload all packages to hackage from a release branch) +# tools/hackageupload $(PACKAGES) + +# # showreleasestats stats: \ +# # showreleasedays \ +# # showunreleasedchangecount \ +# # showloc \ +# # showtestcount \ +# # showunittestcoverage \ +# # showreleaseauthors \ +# # showunreleasedcodechanges \ +# # showunpushedchanges \ +# # $(call def-help,showreleasestats stats,\ +# # show project stats useful for release notes\ +# # ) +# # # showerrors + +# # FROMTAG=. + +# # showreleasedays: \ +# # $(call def-help,showreleasedays,\ +# # \ +# # ) +# # @echo Days since last release: +# # @tools/dayssincetag.hs $(FROMTAG) | head -1 | cut -d' ' -f-1 +# # @echo + +# # # XXX +# # showunreleasedchangecount: \ +# # $(call def-help,showunreleasedchangecount,\ +# # \ +# # ) +# # @echo Commits since last release: +# # @darcs changes --from-tag $(FROMTAG) --count +# # @echo + +# describe: $(call def-help,describe, show a precise git-describe version string ) +# @git describe --tags --match 'hledger-[0-9]*' --dirty + +# # showreleaseauthors: $(call def-help,showreleaseauthors, show author names since last release) +# # @echo Commit authors since last release: +# # @git shortlog -sn $(CHANGELOGSTART).. # TODO undefined + +# showauthors: $(call def-help,showauthors, show all commit author names) +# @echo "Commit authors ($$(git shortlog -sn | wc -l | awk '{print $$1}'))": +# @git shortlog -sn + +# cloc: $(call def-help,cloc, count lines of source code ) +# @echo Lines of code including tests: +# @cloc --exclude-lang=HTML --exclude-dir=.stack-work,.idea,dist,old,bin,doc,site,.tutorial-data,static,angular . + +# SCC=scc -z --cocomo-project-type semi-detached -f wide -s code + +# scc: $(call def-help,scc, count lines of source code with scc) +# @echo Lines of code including tests: +# @$(SCC) -i hs,sh,m4,hamlet + +# sccv: $(call def-help,sccv, count lines of source code with scc showing all files) +# @echo Lines of code including tests: +# @$(SCC) -i hs,sh,m4,hamlet --by-file + +# # `ls $(SOURCEFILES)` + +# # sloc: \ +# # $(call def-help,sloc,\ +# # \ +# # ) +# # @sloccount hledger-lib hledger hledger-web + +# # cloc: \ +# # $(call def-help,cloc,\ +# # \ +# # ) +# # @echo +# # @echo "Lines of code as of `date`:" +# # @echo +# # @echo "hledger-lib, hledger" +# # @cloc -q hledger-lib hledger 2>&1 | grep -v 'defined(' +# # @echo +# # @echo "hledger-web" +# # @cloc -q hledger-web 2>&1 | grep -v 'defined(' +# # @echo +# # @echo "hledger-lib, hledger, hledger-web" +# # @cloc -q hledger-lib hledger hledger-web 2>&1 | grep -v 'defined(' + +# # showtestcount: \ +# # $(call def-help,showtestcount,\ +# # \ +# # ) +# # @echo "Unit tests:" +# # @hledger test 2>&1 | cut -d' ' -f2 +# # @echo "Functional tests:" +# # @make --no-print functest | egrep '^ Total' | awk '{print $$2}' +# # @echo + +# # showunittestcoverage: \ +# # $(call def-help,showunittestcoverage,\ +# # \ +# # ) +# # @echo Unit test coverage: +# # @make --no-print quickcoverage | grep 'expressions' +# # @echo + +# # # showerrors: +# # # @echo Known errors: +# # # @awk '/^** errors/, /^** / && !/^** errors/' NOTES.org | grep '^\*\*\* ' | tail +1 +# # # @echo + +# # # XXX +# # showunpushedchanges showunpushed: \ +# # $(call def-help,showunpushedchanges showunpushed,\ +# # \ +# # ) +# # @echo "Changes not yet pushed upstream (to `darcs show repo | grep 'Default Remote' | cut -c 17-`):" +# # @-darcs push simon@joyful.com:/repos/hledger --dry-run | grep '*' | tac +# # @echo + +# # # XXX +# # showunreleasedcodechanges showunreleased showchanges: \ +# # $(call def-help,showunreleasedcodechanges showunreleased showchanges,\ +# # \ +# # ) +# # @echo "hledger code changes since last release:" +# # @darcs changes --from-tag $(FROMTAG) --matches "not (name docs: or name doc: or name site: or name tools:)" | grep '*' +# # @echo + +# # # XXX +# # showcodechanges: \ +# # $(call def-help,showcodechanges,\ +# # \ +# # ) +# # @echo "hledger code changes:" +# # @darcs changes --matches "not (name docs: or name site: or name tools:)" | egrep '^ +(\*|tagged)' +# # @echo + +# nix-hledger-version: $(call def-help,nix-hledger-version, show which version of hledger has reached nixpkgs) +# @curl -s https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/development/haskell-modules/hackage-packages.nix | grep -A1 'pname = "hledger"' + +# nix-hledger-versions: $(call def-help,nix-hledger-versions, show versions of all hledger packages in nixpkgs) +# @curl -s https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/development/haskell-modules/hackage-packages.nix | grep -A1 'pname = "hledger' + +# nix-view-commits: $(call def-help,nix-view-commits, show recent haskell commits in nixpkgs) +# @open 'https://github.com/NixOS/nixpkgs/commits/master/pkgs/development/haskell-modules/hackage-packages.nix' + +# list-commits: $(call def-help,list-commits, list all commits chronologically and numbered) +# @git log --format='%ad %h %s (%an)' --date=short --reverse | cat -n + # ** misc MISC: @@ -524,6 +1167,10 @@ mkwebdirs: @_listsourcedirs: find . -name '*hs' | sed -e 's%[^/]*hs$%%' | sort | uniq +# show the ghc versions used by all stack files +@_listghcversions: + for F in stack*.yaml; do {{ STACK }} --stack-yaml=$F --no-install-ghc exec -- ghc --version; done 2>&1 | grep -v 'To install the correct GHC' + # Show a bunch of debug messages. @_dbgmsgs: rg --sort path -t hs 'dbg.*?(".*")' -r '$1' -o @@ -539,3 +1186,70 @@ mkwebdirs: printf "account ledger\naccount hledger\naccount beancount\n\n" >project-commits.j for p in ledger hledger beancount; do git -C ../$p log --format="%cd (%h) %s%n ($p) 1%n" --date=short --reverse >> project-commits.j; done echo "wrote project-commits.j" + + +# ############################################################################### +# $(call def-help-subheading,MISCELLANEOUS:) + +# installcommithook: $(call def-help,installcommithook, symlink tools/commitlint as .git/hooks/commit-msg) +# ln -s ../../tools/commitlint .git/hooks/commit-msg + +# watch-%: $(call def-help,watch-RULE, run make RULE repeatedly when any committed file changes) +# @git ls-files | entr -r make $* + +# Shake: Shake.hs $(call def-help,Shake, ensure the Shake script is compiled ) +# ./Shake.hs + +# usage: cabalusage stackusage \ +# $(call def-help,usage, show size of various dirs ) +# du -sh .git bin data doc extra +# du -sh . + +# stackusage: \ +# $(call def-help,stackusage, show size of stack working dirs if any ) +# -du -shc `find . -name '.stack*'` + +# cabalusage: \ +# $(call def-help,cabalusage, show size of cabal working dirs if any ) +# -du -shc */dist* 2>/dev/null + +# # Generate an emacs TAGS file. Tag: +# # 1. haskell source files with hasktags +# # 2. other source files recognised by (exuberant) ctags and not excluded by .ctags. Keep .ctags up to date. +# # 3. some extra files missed by the above, as just their file names (for tags-search, tags-query-replace etc.) +# etags:$(call def-help,etags, generate emacs TAGS file for haskell source and other project files ) +# hasktags -e $(SOURCEFILES) +# ctags -a -e -R +# for f in \ +# $(WEBTEMPLATEFILES) \ +# $(DOCSOURCEFILES) \ +# $(TESTFILES) \ +# $(HPACKFILES) \ +# $(CABALFILES) \ +# Shake.hs \ +# ; do printf " \n$$f,1\n" >> TAGS; done +# -etagsls >TAGS.files + +# etags-ls: # list files indexed in TAGS +# @rg -v '[  ]' TAGS | rg -r '$$1' '^(.*?)([0-9]+)?,[0-9,]+*' + +# cleantags: \ +# $(call def-help-hide,cleantags, remove tag files ) +# rm -f TAGS tags + +# stackclean: \ +# $(call def-help-hide,stackclean, remove .stack-work/ dirs ) +# $(STACK) purge + +# cleanghco: \ +# $(call def-help-hide,cleanghc, remove ghc build leftovers ) +# rm -rf `find . -name "*.o" -o -name "*.hi" -o -name "*.dyn_o" -o -name "*.dyn_hi" -o -name "*~" | grep -vE '\.(stack-work|cabal-sandbox|virthualenv)'` +# #rm -f `fd -I '\.(hi|o|dyn_hi|dyn_o)$'` + +# clean: cleanghco \ +# $(call def-help,clean, default cleanup (ghc build leftovers) ) + +# Clean: stackclean cleanghco cleantags \ +# $(call def-help,Clean, thorough cleanup (stack/ghc leftovers/tags) ) + +# # reverse = $(if $(wordlist 2,2,$(1)),$(call reverse,$(wordlist 2,$(words $(1)),$(1))) $(firstword $(1)),$(1)) From 78aea61b60ea7075dbbeed48ca22994678c80b92 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 15 Dec 2023 18:30:08 -1000 Subject: [PATCH 06/13] ;just: capitalise --- justfile => Justfile | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename justfile => Justfile (100%) diff --git a/justfile b/Justfile similarity index 100% rename from justfile rename to Justfile From da5c5073836977b117a0a47cc888dc020a5971b0 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 15 Dec 2023 18:35:03 -1000 Subject: [PATCH 07/13] ;just: fmt --- Justfile | 180 ++++++++----------------------------------------------- 1 file changed, 26 insertions(+), 154 deletions(-) diff --git a/Justfile b/Justfile index 2e21310ff66..355804d7671 100644 --- a/Justfile +++ b/Justfile @@ -10,6 +10,7 @@ @help: just -lu + # This and all other just invocations assume you are in this justfile's directory, # otherwise we must write --justfile {{ justfile() }} or {{ just }} everywhere. @@ -338,16 +339,17 @@ BUILDING: # # build "bin/hledgercov" for coverage reports (with ghc) # hledgercov: # {{ STACK }} ghc {{ MAIN }} -fhpc -o bin/hledgercov -outputdir .hledgercovobjs {{ BUILDFLAGS }} - # ** testing TESTING: # run tests that are reasonably quick (files, unit, functional) and benchmarks -test: filestest functest #bench +test: filestest functest +#bench # For quieter tests add --silent. It may hide troubleshooting info. # For very verbose tests add --verbosity=debug. It seems hard to get something in between. + STACKTEST := STACK + ' test --fast' # # When doing build testing, save a little time and output noise by not @@ -358,58 +360,50 @@ STACKTEST := STACK + ' test --fast' @filestest: tools/checkembeddedfiles -# # stack build --dry-run all hledger packages ensuring an install plan with default snapshot) +# # stack build --dry-run all hledger packages ensuring an install plan with default snapshot) # buildplantest: # buildplantest-stack.yaml - -# # stack build --dry-run all hledger packages ensuring an install plan with each ghc version/stackage snapshot +# # stack build --dry-run all hledger packages ensuring an install plan with each ghc version/stackage snapshot # buildplantest-all: # for F in stack*.yaml; do make --no-print-directory buildplantest-$F; done - -# # stack build --dry-run all hledger packages ensuring an install plan with the given stack yaml file; eg make buildplantest-stack8.2.yaml +# # stack build --dry-run all hledger packages ensuring an install plan with the given stack yaml file; eg make buildplantest-stack8.2.yaml # buildplantest-%: # {{ STACK }} build --dry-run --test --bench --stack-yaml=$* - -# # force-rebuild all hledger packages/modules quickly ensuring no warnings with default snapshot) +# # force-rebuild all hledger packages/modules quickly ensuring no warnings with default snapshot) # buildtest: # buildtest-stack.yaml - -# # force-rebuild all hledger packages/modules quickly ensuring no warnings with each ghc version/stackage snapshot +# # force-rebuild all hledger packages/modules quickly ensuring no warnings with each ghc version/stackage snapshot # buildtest-all: # for F in stack*.yaml; do make --no-print-directory buildtest-$F; done - -# # force-rebuild all hledger packages/modules quickly ensuring no warnings with the given stack yaml file; eg make buildtest-stack8.2.yaml +# # force-rebuild all hledger packages/modules quickly ensuring no warnings with the given stack yaml file; eg make buildtest-stack8.2.yaml # buildtest-%: # {{ STACK }} build --test --bench {{ SKIPTESTSBENCHS }} --fast --force-dirty --ghc-options=-fforce-recomp --ghc-options=-Werror --stack-yaml=$* - -# # build any outdated hledger packages/modules quickly ensuring no warnings with default snapshot. Wont detect warnings in up-to-date modules.) +# # build any outdated hledger packages/modules quickly ensuring no warnings with default snapshot. Wont detect warnings in up-to-date modules.) # incr-buildtest: # incr-buildtest-stack.yaml - -# # build any outdated hledger packages/modules quickly ensuring no warnings with each ghc version/stackage snapshot. Wont detect warnings in up-to-date modules. +# # build any outdated hledger packages/modules quickly ensuring no warnings with each ghc version/stackage snapshot. Wont detect warnings in up-to-date modules. # incr-buildtest-all: # for F in stack*.yaml; do make --no-print-directory incr-buildtest-$F; done - -# # build any outdated hledger packages/modules quickly ensuring no warnings with the stack yaml file; eg make buildtest-stack8.2.yaml. Wont detect warnings in up-to-date modules. +# # build any outdated hledger packages/modules quickly ensuring no warnings with the stack yaml file; eg make buildtest-stack8.2.yaml. Wont detect warnings in up-to-date modules. # incr-buildtest-%: # {{ STACK }} build --test --bench {{ SKIPTESTSBENCHS }} --fast --ghc-options=-Werror --stack-yaml=$* - -# # do a stack clean --full with all ghc versions for paranoia/troubleshooting +# # do a stack clean --full with all ghc versions for paranoia/troubleshooting # stack-clean-all: # for F in stack*.yaml; do {{ STACK }} clean --full --stack-yaml=$F; done -# run all test suites in the hledger packages +# run all test suites in the hledger packages @pkgtest: ({{ STACKTEST }} && echo $@ PASSED) || (echo $@ FAILED; false) # doctest with ghc 8.4 on mac requires a workaround, see hledger-lib/package.yaml. -# Or, could run it with ghc 8.2: +# Or, could run it with ghc 8.2: # @({{ STACKTEST }} --stack-yaml stack8.2.yaml hledger-lib:test:doctest && echo $@ PASSED) || (echo $@ FAILED; false) -# run the doctests in hledger-lib module/function docs + +# run the doctests in hledger-lib module/function docs @doctest: ({{ STACKTEST }} hledger-lib:test:doctest && echo $@ PASSED) || (echo $@ FAILED; false) -# # run the unit tests in hledger-lib +# # run the unit tests in hledger-lib # unittest: # @({{ STACKTEST }} hledger-lib:test:unittest && echo $@ PASSED) || (echo $@ FAILED; false) @@ -418,12 +412,13 @@ STACKTEST := STACK + ' test --fast' ({{ STACK }} exec hledger test && echo $@ PASSED) || (echo $@ FAILED; false) SHELLTEST := 'COLUMNS=80 ' + STACK + ' exec -- shelltest --execdir --threads=64 --exclude=/_' + # --hide-successes # build hledger quickly and run functional tests, or just the ones matching PAT. (Run mktestaddons first.) @functest *PAT: {{ STACK }} build --fast hledger - ({{ SHELLTEST }} {{ if PAT == '' { '' } else { '-i "'+PAT+'"' } }} \ + ({{ SHELLTEST }} {{ if PAT == '' { '' } else { '-i "' + PAT + '"' } }} \ hledger/test/ bin/ \ -x ledger-compat/ledger-baseline -x ledger-compat/ledger-regress -x ledger-compat/ledger-extra \ && echo $@ PASSED) || (echo $@ FAILED; false) @@ -444,22 +439,17 @@ ADDONEXTS := 'pl py rb sh hs lhs rkt exe com bat' # generate a hlint report # hlinttest hlint: # hlint --hint=hlint --report=hlint.html {{ SOURCEFILES }} - -# # run haddock to make sure it can generate docs without dying +# # run haddock to make sure it can generate docs without dying # @haddocktest: # (make --quiet haddock && echo $@ PASSED) || (echo $@ FAILED; false) - -# # run cabal check to test cabal file syntax +# # run cabal check to test cabal file syntax # cabalfiletest: # @(make --no-print-directory cabalcheck && echo $@ PASSED) || (echo $@ FAILED; false) - # test-stack%yaml: # {{ STACK }} --stack-yaml stack$*yaml clean # {{ STACK }} --stack-yaml stack$*yaml build --ghc-options="{{ WARNINGS }} -Werror" --test --bench --haddock --no-haddock-deps - # committest: hlinttest unittest doctest functest haddocktest buildtest quickcabaltest \ -# - +# # releasetest: Clean unittest functest fullcabaltest haddocktest #buildtest doctest \ # {{ call def-help,releasetest,pre-release tests }} @@ -495,77 +485,53 @@ mksamplejournals: # # examples/ascii.journal \ # # examples/chinese.journal \ # # examples/mixed.journal \ - # examples/sample.journal: # true # XXX should probably regenerate this - # examples/10x10x10.journal: tools/generatejournal # tools/generatejournal 10 10 10 >$@ - # examples/100x100x10.journal: tools/generatejournal # tools/generatejournal 100 100 10 >$@ - # examples/1000x1000x10.journal: tools/generatejournal # tools/generatejournal 1000 1000 10 >$@ - # examples/1000x10000x10.journal: tools/generatejournal # tools/generatejournal 1000 10000 10 >$@ - # examples/2000x1000x10.journal: tools/generatejournal # tools/generatejournal 2000 1000 10 >$@ - # examples/3000x1000x10.journal: tools/generatejournal # tools/generatejournal 3000 1000 10 >$@ - # examples/4000x1000x10.journal: tools/generatejournal # tools/generatejournal 4000 1000 10 >$@ - # examples/5000x1000x10.journal: tools/generatejournal # tools/generatejournal 5000 1000 10 >$@ - # examples/6000x1000x10.journal: tools/generatejournal # tools/generatejournal 6000 1000 10 >$@ - # examples/7000x1000x10.journal: tools/generatejournal # tools/generatejournal 7000 1000 10 >$@ - # examples/8000x1000x10.journal: tools/generatejournal # tools/generatejournal 8000 1000 10 >$@ - # examples/9000x1000x10.journal: tools/generatejournal # tools/generatejournal 9000 1000 10 >$@ - # examples/10000x1000x10.journal: tools/generatejournal # tools/generatejournal 10000 1000 10 >$@ - # examples/10000x10000x10.journal: tools/generatejournal # tools/generatejournal 10000 10000 10 >$@ - # examples/100000x1000x10.journal: tools/generatejournal # tools/generatejournal 100000 1000 10 >$@ - # examples/1000000x1000x10.journal: tools/generatejournal # tools/generatejournal 1000000 1000 10 >$@ - # examples/ascii.journal: tools/generatejournal # tools/generatejournal 3 5 5 >$@ - # examples/chinese.journal: tools/generatejournal # tools/generatejournal 3 5 5 --chinese >$@ - # examples/mixed.journal: tools/generatejournal # tools/generatejournal 3 5 5 --mixed >$@ - -# # hledger executables to bench test, can be overridden by env var, +# # hledger executables to bench test, can be overridden by env var, # # eg: BENCHEXES=ledger,hledger-1.18,hledger make bench # BENCHEXES ?= hledger - # bench: quickbench - # quickbench: samplejournals bench.sh $(call def-help,quickbench, benchmark commands in bench.sh with quickbench and $(BENCHEXES)) # @echo; echo "run quick performance benchmarks in bench.sh (approximate, can be skewed):" # @which quickbench >/dev/null && quickbench -w $(BENCHEXES) || echo "quickbench not installed (see bench.sh), skipping" - # # bench: samplejournals tests/bench.tests tools/simplebench \ # # $(call def-help,bench,\ # # run simple performance benchmarks and archive results\ @@ -574,22 +540,18 @@ mksamplejournals: # # tools/simplebench -v -ftests/bench.tests $(BENCHEXES) | tee doc/profs/$(TIME).bench # # @rm -f benchresults.* # # @(cd doc/profs; rm -f latest.bench; ln -s $(TIME).bench latest.bench) - # # criterionbench: samplejournals tools/criterionbench \ # # $(call def-help,criterionbench,\ # # run criterion benchmark tests and save graphical results\ # # ) # # tools/criterionbench -t png -k png - # # progressionbench: samplejournals tools/progressionbench \ # # $(call def-help,progressionbench,\ # # run progression benchmark tests and save graphical results\ # # ) # # tools/progressionbench -- -t png -k png - # throughput: throughput-hledger \ # $(call def-help,throughput, show throughput at various data sizes with the default hledger executable ) - # throughput-%: samplejournals \ # $(call def-help,throughput-HLEDGEREXE, show throughput at various data sizes with the given hledger executable ) # @echo date: `date` @@ -600,12 +562,10 @@ mksamplejournals: # printf "%6d txns: " $$n; $* stats -f examples/$${n}x1000x10.journal | tail -1; \ # done # @date - # throughput-dev: samplejournals \ # $(call def-help,throughput-dev, show throughput at various data sizes with the latest hledger dev build (optimised or not) ) # @stack build hledger # @stack exec -- make -s throughput - # # prof: samplejournals \ # # $(call def-help,prof,\ # # generate and archive an execution profile\ @@ -614,13 +574,11 @@ mksamplejournals: # # -$(PROFCMD) +RTS $(PROFRTSFLAGS) -RTS # # mv hledgerprof.prof doc/profs/$(TIME).prof # # (cd doc/profs; rm -f latest*.prof; ln -s $(TIME).prof latest.prof) - # # viewprof: prof \ # # $(call def-help,viewprof,\ # # generate, archive, simplify and display an execution profile\ # # ) # # tools/simplifyprof.hs doc/profs/latest.prof - # quickprof-%: hledgerprof samplejournals \ # $(call def-help,quickprof-"CMD", run some command against a standard sample journal and display the execution profile ) # $(STACK) exec --profile -- hledger +RTS $(PROFRTSFLAGS) -RTS $* -f examples/1000x1000x10.journal >/dev/null @@ -633,7 +591,6 @@ mksamplejournals: # @echo ... # @echo # @echo "See hledger.prof, hledger.profiterole.txt, hledger.profiterole.html for more." - # # heap: samplejournals \ # # $(call def-help,heap,\ # # generate and archive a graphical heap profile\ @@ -643,27 +600,23 @@ mksamplejournals: # # mv hledgerprof.hp doc/profs/$(TIME).hp # # (cd doc/profs; rm -f latest.hp; ln -s $(TIME).hp latest.hp; \ # # hp2ps $(TIME).hp; rm -f latest.ps; ln -s $(TIME).ps latest.ps; rm -f *.aux) - # # viewheap: heap \ # # $(call def-help,viewheap,\ # # \ # # ) # # $(VIEWPS) doc/profs/latest.ps - # quickheap-%: hledgerprof samplejournals \ # $(call def-help,quickheap-"CMD", run some command against a sample journal and display the heap profile ) # $(STACK) exec -- hledgerprof +RTS -hc -RTS $* -f examples/10000x1000x10.journal >/dev/null # hp2ps hledgerprof.hp # @echo generated hledgerprof.ps # $(VIEWPS) hledgerprof.ps - # # quickcoverage: hledgercov \ # # $(call def-help,quickcoverage,\ # # display a code coverage text report from running hledger COVCMD\ # # ) # # @echo "Generating code coverage text report for hledger command: $(COVCMD)" # # tools/runhledgercov "report" $(COVCMD) - # # coverage: samplejournals hledgercov \ # # $(call def-help,coverage,\ # # generate a code coverage html report from running hledger COVCMD\ @@ -671,83 +624,65 @@ mksamplejournals: # # @echo "Generating code coverage html report for hledger command: $(COVCMD)" # # tools/runhledgercov "markup --destdir=doc/profs/coverage" $(COVCMD) # # cd doc/profs/coverage; rm -f index.html; ln -s hpc_index.html index.html - # # viewcoverage: \ # # $(call def-help,viewcoverage,\ # # view the last html code coverage report\ # # ) # # $(VIEWHTML) doc/profs/coverage/index.html - # ############################################################################### # $(call def-help-subheading,DOCUMENTATION: (see also Shake.hs)) - # # http://www.haskell.org/haddock/doc/html/invoking.html # STACKHADDOCK=time $(STACK) --verbosity=error haddock --fast --no-keep-going \ # --only-locals --no-haddock-deps --no-haddock-hyperlink-source \ # --haddock-arguments="--no-warnings" # # -ghc-options='-optP-P' # workaround for http://trac.haskell.org/haddock/ticket/284 - # # uncomment to run haddock on fewer packages, saving time # #HADDOCKPKGS=hledger-lib - # releasediag: \ # $(call def-help,releasediag, optimise and commit RELEASING value map diagram ) # pngquant doc/HledgerReleaseValueMap.png -f -o doc/HledgerReleaseValueMap.png && git add doc/HledgerReleaseValueMap.png && git commit -m ';doc: RELEASING: update value map' -- doc/HledgerReleaseValueMap.png - # # Renders all hledger packages. Run make haddock-open to open contents page. # haddock: \ # $(call def-help,haddock, regenerate haddock docs for the hledger packages and open them ) # $(STACKHADDOCK) $(HADDOCKPKGS) && make -s haddock-open # --open shows all deps and packages - # # Rerenders all hledger packages. Run make haddock-open to open contents page. # haddock-watch1: \ # $(call def-help,haddock-watch, regenerate haddock docs when files change ) # $(STACKHADDOCK) $(HADDOCK_PKGS) --file-watch --exec='echo done' - # # Rerenders hledger-lib modules, opens hledger-lib contents page. # haddock-watch2: \ # $(call def-help,haddock-watch2, regenerate hledger-lib haddock docs when files change ) # watchexec -r -e yaml,cabal,hs --print-events -- \ # $(STACKHADDOCK) --verbosity=info $(HADDOCK_PKGS) --exec="'echo done'" hledger-lib --open - # # Rerenders/reopens the Hledger module, without submodules. (Fastest) # haddock-watch: \ # $(call def-help,haddock-watch3, quickly regenerate & reload Hledger.hs haddock when files change ) # watchexec -r -e yaml,cabal,hs --print-events --shell=none -- bash -c 'mkdir -p tmp && rm -f tmp/Hledger.html && haddock -h -o tmp hledger-lib/Hledger.hs --no-warnings --no-print-missing-docs 2>&1 | grep -v "Could not find documentation" && open tmp/Hledger.html' - # haddock-open: \ # $(call def-help,haddock-open, open the haddock packages contents page in a browser ) # $(BROWSE) `stack path --local-install-root`/doc/index.html - # hoogle-setup: $(call def-help,hoogle-setup, install hoogle then build haddocks and a hoogle db for the project and all deps ) # stack hoogle --rebuild - # HOOGLEBROWSER="/Applications/Firefox Dev.app/Contents/MacOS/firefox" # safari not supported # hoogle-serve: $(call def-help,hoogle-serve, run hoogle web app and open in browser after doing setup if needed ) # $(HOOGLEBROWSER) http://localhost:8080 & # stack --verbosity=warn hoogle --server - # # sourcegraph: \ # # $(call def-help,sourcegraph,\ # # \ # # ) # # for p in $(PACKAGES); do (cd $$p; SourceGraph $$p.cabal); done - # manuals-watch: Shake \ # $(call def-help,manuals-watch, rerender manuals when their source files change ) # ls $(DOCSOURCEFILES) | entr ./Shake -VV manuals - # man-watch: man-watch-hledger \ # $(call def-help,man-watch, run man on the hledger man page when its source file changes ) - # man-watch-%: Shake \ # $(call def-help,man-watch-PROG, run man on the given man page when its source file changes. Eg make man-watch-hledger-web ) # $(WATCHEXEC) -r -w $*/$*.m4.md './Shake $*/$*.1 && man $*/$*.1' - # shakehelp-watch: \ # $(call def-help,shakehelp-watch, rerender Shake.hs's help when it changes) # ls Shake.hs | entr -c ./Shake.hs - # # The following rule, for updating the website, gets called on hledger.org by: # # 1. github-post-receive (github webhook handler), when something is pushed # # to the main or wiki repos on Github. Config: @@ -755,10 +690,7 @@ mksamplejournals: # # /etc/github-post-receive.conf # # 2. cron, nightly. Config: /etc/crontab # # 3. manually: "make site" on hledger.org, or "make hledgerorg" elsewhere (cf Makefile.local). - - # .PHONY: site - # # Use the existing Shake executable without recompiling it, so as not to automatially run unreviewed code by hook ? I think this no longer applies. # # site: $(call def-help,site-build, update the hledger.org website (run this on hledger.org, or run "make hledgerorg" elsewhere) ) # # @[ ! -x Shake ] \ @@ -767,12 +699,9 @@ mksamplejournals: # # echo; \ # # ./Shake -V site; \ # # ) 2>&1 | tee -a site.log - # site: Shake \ # $(call def-help,site, update the hledger.org website (run on hledger.org, or run "make hledgerorg" elsewhere) ) # ./Shake -V site 2>&1 | tee -a site.log - - # BROWSE=open # BROWSEDELAY=5 # LOCALSITEURL=http://localhost:3000/dev/hledger.html @@ -780,7 +709,6 @@ mksamplejournals: # @make -s Shake # @(printf "\nbrowser will open in $(BROWSEDELAY)s (adjust BROWSE in Makefile if needed)...\n\n"; sleep $(BROWSEDELAY); $(BROWSE) $(LOCALSITEURL)) & # @$(WATCHEXEC) --print-events -e md,m4 -i hledger.md -i hledger-ui.md -i hledger-web.md -r './Shake webmanuals && ./Shake orgfiles && make -sC site serve' - # ** installing INSTALLING: @@ -799,8 +727,6 @@ INSTALLING: # # update shell completions in hledger package # shellcompletions: # make -C hledger/shell-completion/ clean-all all - - # ** releasing RELEASING: @@ -910,67 +836,52 @@ _gitSwitchAutoCreate BRANCH: git switch -c {{ BRANCH }} fi - # ############################################################################### # $(call def-help-subheading,RELEASING:) - # # old/desired release process: # # a normal release: echo 0.7 >.version; make release # # a bugfix release: echo 0.7.1 >.version; make release # #release: releasetest bumpversion tagrelease $(call def-help,release, prepare and test a release and tag the repo ) # #publish: hackageupload pushtags $(call def-help,upload, publish latest hackage packages and push tags to github ) # #releaseandpublish: release upload $(call def-help,releaseandpublish, release and upload and publish updated docs ) - # ISCLEAN=git diff-index --quiet HEAD -- - # # stop if the working directory has uncommitted changes # iscleanwd: # @$(ISCLEAN) || (echo "please clean the working directory first"; false) - # # stop if the given file(s) have uncommitted changes # isclean-%: # @$(ISCLEAN) $* || (echo "please clean these files first: $*"; false) - # # update all cabal files based on latest package.yaml files using stack's built-in hpack # cabal: $(call def-help,cabal, regenerate cabal files from package.yaml files with stack ) # $(STACK) build --dry-run --silent - # # Update all cabal files based on latest package.yaml files using a specific hpack version. # # To avoid warnings, this should be the same version as stack's built-in hpack. # cabal-with-hpack-%: # $(STACK) build --with-hpack hpack-$* --dry-run --silent - # # updatecabal: gencabal $(call def-help,updatecabal, regenerate cabal files and commit ) # # @read -p "please review changes then press enter to commit $(shell ls */*.cabal)" # # git commit -m "update cabal files" $(shell ls */*.cabal) - # # we use shake for this job; so dependencies aren't checked here # manuals: Shake $(call def-help,manuals, regenerate and commit CLI help and manuals (might need -B) ) # ./Shake manuals # git commit -m ";doc: regen manuals" -m "[ci skip]" hledger*/hledger*.{1,5,info,txt} hledger/Hledger/Cli/Commands/*.txt - # tag: $(call def-help,tag, make git release tags for the project and all packages ) # @for p in $(PACKAGES); do make tag-$$p; done # @make tag-project - # tag-%: $(call def-help,tag-PKG, make a git release tag for PKG ) # git tag -fs $*-`cat $*/.version` -m "Release $*-`cat $*/.version`" - # tag-project: $(call def-help,tag-project, make a git release tag for the project as a whole ) # git tag -fs `cat .version` -m "Release `cat .version`, https://hledger.org/release-notes.html#hledger-`cat .version | sed -e 's/\./-/g'`" # @printf "if tagging a major release, please also review and run this command:\n" # @printf " git tag -fs `cat .version`.99 master -m \"Start of next release cycle. This tag influences git describe and dev builds' version strings.\"\n" - # # hackageupload-dry: \ # # $(call def-help,hackageupload-dry,\ # # upload all packages to hackage; dry run\ # # ) # # for p in $(PACKAGES); do cabal upload $$p/dist/$$p-$(VERSION).tar.gz -v2 --check; done - # hackageupload: \ # $(call def-help,hackageupload, upload all packages to hackage from a release branch) # tools/hackageupload $(PACKAGES) - # # showreleasestats stats: \ # # showreleasedays \ # # showunreleasedchangecount \ @@ -984,9 +895,7 @@ _gitSwitchAutoCreate BRANCH: # # show project stats useful for release notes\ # # ) # # # showerrors - # # FROMTAG=. - # # showreleasedays: \ # # $(call def-help,showreleasedays,\ # # \ @@ -994,7 +903,6 @@ _gitSwitchAutoCreate BRANCH: # # @echo Days since last release: # # @tools/dayssincetag.hs $(FROMTAG) | head -1 | cut -d' ' -f-1 # # @echo - # # # XXX # # showunreleasedchangecount: \ # # $(call def-help,showunreleasedchangecount,\ @@ -1003,40 +911,30 @@ _gitSwitchAutoCreate BRANCH: # # @echo Commits since last release: # # @darcs changes --from-tag $(FROMTAG) --count # # @echo - # describe: $(call def-help,describe, show a precise git-describe version string ) # @git describe --tags --match 'hledger-[0-9]*' --dirty - # # showreleaseauthors: $(call def-help,showreleaseauthors, show author names since last release) # # @echo Commit authors since last release: # # @git shortlog -sn $(CHANGELOGSTART).. # TODO undefined - # showauthors: $(call def-help,showauthors, show all commit author names) # @echo "Commit authors ($$(git shortlog -sn | wc -l | awk '{print $$1}'))": # @git shortlog -sn - # cloc: $(call def-help,cloc, count lines of source code ) # @echo Lines of code including tests: # @cloc --exclude-lang=HTML --exclude-dir=.stack-work,.idea,dist,old,bin,doc,site,.tutorial-data,static,angular . - # SCC=scc -z --cocomo-project-type semi-detached -f wide -s code - # scc: $(call def-help,scc, count lines of source code with scc) # @echo Lines of code including tests: # @$(SCC) -i hs,sh,m4,hamlet - # sccv: $(call def-help,sccv, count lines of source code with scc showing all files) # @echo Lines of code including tests: # @$(SCC) -i hs,sh,m4,hamlet --by-file - # # `ls $(SOURCEFILES)` - # # sloc: \ # # $(call def-help,sloc,\ # # \ # # ) # # @sloccount hledger-lib hledger hledger-web - # # cloc: \ # # $(call def-help,cloc,\ # # \ @@ -1052,7 +950,6 @@ _gitSwitchAutoCreate BRANCH: # # @echo # # @echo "hledger-lib, hledger, hledger-web" # # @cloc -q hledger-lib hledger hledger-web 2>&1 | grep -v 'defined(' - # # showtestcount: \ # # $(call def-help,showtestcount,\ # # \ @@ -1062,7 +959,6 @@ _gitSwitchAutoCreate BRANCH: # # @echo "Functional tests:" # # @make --no-print functest | egrep '^ Total' | awk '{print $$2}' # # @echo - # # showunittestcoverage: \ # # $(call def-help,showunittestcoverage,\ # # \ @@ -1070,12 +966,10 @@ _gitSwitchAutoCreate BRANCH: # # @echo Unit test coverage: # # @make --no-print quickcoverage | grep 'expressions' # # @echo - # # # showerrors: # # # @echo Known errors: # # # @awk '/^** errors/, /^** / && !/^** errors/' NOTES.org | grep '^\*\*\* ' | tail +1 # # # @echo - # # # XXX # # showunpushedchanges showunpushed: \ # # $(call def-help,showunpushedchanges showunpushed,\ @@ -1084,7 +978,6 @@ _gitSwitchAutoCreate BRANCH: # # @echo "Changes not yet pushed upstream (to `darcs show repo | grep 'Default Remote' | cut -c 17-`):" # # @-darcs push simon@joyful.com:/repos/hledger --dry-run | grep '*' | tac # # @echo - # # # XXX # # showunreleasedcodechanges showunreleased showchanges: \ # # $(call def-help,showunreleasedcodechanges showunreleased showchanges,\ @@ -1093,7 +986,6 @@ _gitSwitchAutoCreate BRANCH: # # @echo "hledger code changes since last release:" # # @darcs changes --from-tag $(FROMTAG) --matches "not (name docs: or name doc: or name site: or name tools:)" | grep '*' # # @echo - # # # XXX # # showcodechanges: \ # # $(call def-help,showcodechanges,\ @@ -1102,19 +994,14 @@ _gitSwitchAutoCreate BRANCH: # # @echo "hledger code changes:" # # @darcs changes --matches "not (name docs: or name site: or name tools:)" | egrep '^ +(\*|tagged)' # # @echo - # nix-hledger-version: $(call def-help,nix-hledger-version, show which version of hledger has reached nixpkgs) # @curl -s https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/development/haskell-modules/hackage-packages.nix | grep -A1 'pname = "hledger"' - # nix-hledger-versions: $(call def-help,nix-hledger-versions, show versions of all hledger packages in nixpkgs) # @curl -s https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/development/haskell-modules/hackage-packages.nix | grep -A1 'pname = "hledger' - # nix-view-commits: $(call def-help,nix-view-commits, show recent haskell commits in nixpkgs) # @open 'https://github.com/NixOS/nixpkgs/commits/master/pkgs/development/haskell-modules/hackage-packages.nix' - # list-commits: $(call def-help,list-commits, list all commits chronologically and numbered) # @git log --format='%ad %h %s (%an)' --date=short --reverse | cat -n - # ** misc MISC: @@ -1167,7 +1054,7 @@ mkwebdirs: @_listsourcedirs: find . -name '*hs' | sed -e 's%[^/]*hs$%%' | sort | uniq -# show the ghc versions used by all stack files +# show the ghc versions used by all stack files @_listghcversions: for F in stack*.yaml; do {{ STACK }} --stack-yaml=$F --no-install-ghc exec -- ghc --version; done 2>&1 | grep -v 'To install the correct GHC' @@ -1187,32 +1074,24 @@ mkwebdirs: for p in ledger hledger beancount; do git -C ../$p log --format="%cd (%h) %s%n ($p) 1%n" --date=short --reverse >> project-commits.j; done echo "wrote project-commits.j" - # ############################################################################### # $(call def-help-subheading,MISCELLANEOUS:) - # installcommithook: $(call def-help,installcommithook, symlink tools/commitlint as .git/hooks/commit-msg) # ln -s ../../tools/commitlint .git/hooks/commit-msg - # watch-%: $(call def-help,watch-RULE, run make RULE repeatedly when any committed file changes) # @git ls-files | entr -r make $* - # Shake: Shake.hs $(call def-help,Shake, ensure the Shake script is compiled ) # ./Shake.hs - # usage: cabalusage stackusage \ # $(call def-help,usage, show size of various dirs ) # du -sh .git bin data doc extra # du -sh . - # stackusage: \ # $(call def-help,stackusage, show size of stack working dirs if any ) # -du -shc `find . -name '.stack*'` - # cabalusage: \ # $(call def-help,cabalusage, show size of cabal working dirs if any ) # -du -shc */dist* 2>/dev/null - # # Generate an emacs TAGS file. Tag: # # 1. haskell source files with hasktags # # 2. other source files recognised by (exuberant) ctags and not excluded by .ctags. Keep .ctags up to date. @@ -1229,27 +1108,20 @@ mkwebdirs: # Shake.hs \ # ; do printf " \n$$f,1\n" >> TAGS; done # -etagsls >TAGS.files - # etags-ls: # list files indexed in TAGS # @rg -v '[  ]' TAGS | rg -r '$$1' '^(.*?)([0-9]+)?,[0-9,]+*' - # cleantags: \ # $(call def-help-hide,cleantags, remove tag files ) # rm -f TAGS tags - # stackclean: \ # $(call def-help-hide,stackclean, remove .stack-work/ dirs ) # $(STACK) purge - # cleanghco: \ # $(call def-help-hide,cleanghc, remove ghc build leftovers ) # rm -rf `find . -name "*.o" -o -name "*.hi" -o -name "*.dyn_o" -o -name "*.dyn_hi" -o -name "*~" | grep -vE '\.(stack-work|cabal-sandbox|virthualenv)'` # #rm -f `fd -I '\.(hi|o|dyn_hi|dyn_o)$'` - # clean: cleanghco \ # $(call def-help,clean, default cleanup (ghc build leftovers) ) - # Clean: stackclean cleanghco cleantags \ # $(call def-help,Clean, thorough cleanup (stack/ghc leftovers/tags) ) - # # reverse = $(if $(wordlist 2,2,$(1)),$(call reverse,$(wordlist 2,$(words $(1)),$(1))) $(firstword $(1)),$(1)) From 07967b4c04ac6ff45502803d8f0f674a25f3901d Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 15 Dec 2023 18:41:31 -1000 Subject: [PATCH 08/13] ;just: _watch --- Justfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Justfile b/Justfile index 355804d7671..2190f13ca0b 100644 --- a/Justfile +++ b/Justfile @@ -20,6 +20,9 @@ @_fmt: just -q _check || just --fmt --unstable +@_watch: + watchexec -w {{ justfile() }} -- 'just; just -q _check && echo format ok || echo format non-standard' + # ** vars # GHC-compiled executables require a locale (and not just C) or they # will die on encountering non-ascii data. Set LANG to something if not already set. From 1f5a6fc7589602368ed1728d27d478bff70fc559 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 15 Dec 2023 19:27:41 -1000 Subject: [PATCH 09/13] ;tools: generatejournal: make runnable without compiling, with arguments --- tools/generatejournal.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/generatejournal.hs b/tools/generatejournal.hs index 93aa9299390..7fd6e59a72e 100755 --- a/tools/generatejournal.hs +++ b/tools/generatejournal.hs @@ -1,4 +1,5 @@ -#!/usr/bin/env runhaskell +#!/usr/bin/env stack +-- stack runghc {- generatejournal.hs NUMTXNS NUMACCTS ACCTDEPTH [--chinese|--mixed] From f7763cbc9c3d28b0b4bfc336b2536b8bca3ac822 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 15 Dec 2023 19:27:58 -1000 Subject: [PATCH 10/13] ;examples: update some example journals --- examples/ascii.journal | 12 ++++++------ examples/chinese.journal | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/ascii.journal b/examples/ascii.journal index 8d8c848446d..2b3907902a9 100644 --- a/examples/ascii.journal +++ b/examples/ascii.journal @@ -1,14 +1,14 @@ 2000-01-01 transaction 1 - 1 1 A - 1:2 -1 A + 1 1 A @ 0.71 B + 1:2 -0.71 B 2000-01-02 transaction 2 - 1:2:3 1 A - 1:2:3:4 -1 A + 1:2:3 2 B @@ 2 C + 1:2:3:4 -2 C 2000-01-03 transaction 3 - 1:2:3:4:5 1 A - 1 -1 A + 1:2:3:4:5 3 C + 1 -3 C P 2000-01-01 A 0.70 B P 2000-01-02 A 0.71 B diff --git a/examples/chinese.journal b/examples/chinese.journal index 74042ba6ff3..1d55dbd7024 100644 --- a/examples/chinese.journal +++ b/examples/chinese.journal @@ -1,14 +1,14 @@ 2000-01-01 transaction 1 - 㐀 1 A - 㐀:㐁 -1 A + 㐀 1 A @ 0.71 B + 㐀:㐁 -0.71 B 2000-01-02 transaction 2 - 㐀:㐁:㐂 1 A - 㐀:㐁:㐂:㐃 -1 A + 㐀:㐁:㐂 2 B @@ 2 C + 㐀:㐁:㐂:㐃 -2 C 2000-01-03 transaction 3 - 㐀:㐁:㐂:㐃:㐄 1 A - 㐀 -1 A + 㐀:㐁:㐂:㐃:㐄 3 C + 㐀 -3 C P 2000-01-01 A 0.70 B P 2000-01-02 A 0.71 B From f4156475cfd93b87bbc5dc42a6488540740c1073 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 15 Dec 2023 19:28:20 -1000 Subject: [PATCH 11/13] ;just: port more make rules --- Justfile | 581 ++++++++++++++++++++++++++----------------------------- 1 file changed, 278 insertions(+), 303 deletions(-) diff --git a/Justfile b/Justfile index 2190f13ca0b..58d9bc56a3c 100644 --- a/Justfile +++ b/Justfile @@ -5,7 +5,8 @@ # https://just.systems/man/en/chapter_31.html Functions # https://cheatography.com/linux-china/cheat-sheets/justfile Cheatsheet # https://github.com/casey/just/discussions -# See also Makefile, Shake.hs. +# This has absorbed all of Makefile; uncomment and update remaining bits when needed. +# See also Shake.hs. # ** prelude @help: @@ -21,7 +22,7 @@ just -q _check || just --fmt --unstable @_watch: - watchexec -w {{ justfile() }} -- 'just; just -q _check && echo format ok || echo format non-standard' + watchexec -w {{ justfile() }} -- 'just; just -q _check && echo format ok || echo non-standard format' # ** vars # GHC-compiled executables require a locale (and not just C) or they @@ -349,7 +350,6 @@ TESTING: # run tests that are reasonably quick (files, unit, functional) and benchmarks test: filestest functest -#bench # For quieter tests add --silent. It may hide troubleshooting info. # For very verbose tests add --verbosity=debug. It seems hard to get something in between. @@ -465,110 +465,74 @@ installtest: BENCHMARKING: # generate standard sample journals in examples/ -mksamplejournals: - -# samplejournals: $(call def-help,samplejournals, regenerate standard sample journals in examples/) \ -# examples/sample.journal \ -# examples/10x10x10.journal \ -# examples/100x100x10.journal \ -# examples/1000x1000x10.journal \ -# examples/1000x10000x10.journal \ -# examples/2000x1000x10.journal \ -# examples/3000x1000x10.journal \ -# examples/4000x1000x10.journal \ -# examples/5000x1000x10.journal \ -# examples/6000x1000x10.journal \ -# examples/7000x1000x10.journal \ -# examples/8000x1000x10.journal \ -# examples/9000x1000x10.journal \ -# examples/10000x1000x10.journal \ -# examples/10000x10000x10.journal \ -# examples/100000x1000x10.journal \ -# examples/1000000x1000x10.journal \ -# # examples/ascii.journal \ -# # examples/chinese.journal \ -# # examples/mixed.journal \ -# examples/sample.journal: -# true # XXX should probably regenerate this -# examples/10x10x10.journal: tools/generatejournal -# tools/generatejournal 10 10 10 >$@ -# examples/100x100x10.journal: tools/generatejournal -# tools/generatejournal 100 100 10 >$@ -# examples/1000x1000x10.journal: tools/generatejournal -# tools/generatejournal 1000 1000 10 >$@ -# examples/1000x10000x10.journal: tools/generatejournal -# tools/generatejournal 1000 10000 10 >$@ -# examples/2000x1000x10.journal: tools/generatejournal -# tools/generatejournal 2000 1000 10 >$@ -# examples/3000x1000x10.journal: tools/generatejournal -# tools/generatejournal 3000 1000 10 >$@ -# examples/4000x1000x10.journal: tools/generatejournal -# tools/generatejournal 4000 1000 10 >$@ -# examples/5000x1000x10.journal: tools/generatejournal -# tools/generatejournal 5000 1000 10 >$@ -# examples/6000x1000x10.journal: tools/generatejournal -# tools/generatejournal 6000 1000 10 >$@ -# examples/7000x1000x10.journal: tools/generatejournal -# tools/generatejournal 7000 1000 10 >$@ -# examples/8000x1000x10.journal: tools/generatejournal -# tools/generatejournal 8000 1000 10 >$@ -# examples/9000x1000x10.journal: tools/generatejournal -# tools/generatejournal 9000 1000 10 >$@ -# examples/10000x1000x10.journal: tools/generatejournal -# tools/generatejournal 10000 1000 10 >$@ -# examples/10000x10000x10.journal: tools/generatejournal -# tools/generatejournal 10000 10000 10 >$@ -# examples/100000x1000x10.journal: tools/generatejournal -# tools/generatejournal 100000 1000 10 >$@ -# examples/1000000x1000x10.journal: tools/generatejournal -# tools/generatejournal 1000000 1000 10 >$@ -# examples/ascii.journal: tools/generatejournal -# tools/generatejournal 3 5 5 >$@ -# examples/chinese.journal: tools/generatejournal -# tools/generatejournal 3 5 5 --chinese >$@ -# examples/mixed.journal: tools/generatejournal -# tools/generatejournal 3 5 5 --mixed >$@ -# # hledger executables to bench test, can be overridden by env var, -# # eg: BENCHEXES=ledger,hledger-1.18,hledger make bench -# BENCHEXES ?= hledger -# bench: quickbench -# quickbench: samplejournals bench.sh $(call def-help,quickbench, benchmark commands in bench.sh with quickbench and $(BENCHEXES)) -# @echo; echo "run quick performance benchmarks in bench.sh (approximate, can be skewed):" -# @which quickbench >/dev/null && quickbench -w $(BENCHEXES) || echo "quickbench not installed (see bench.sh), skipping" -# # bench: samplejournals tests/bench.tests tools/simplebench \ -# # $(call def-help,bench,\ -# # run simple performance benchmarks and archive results\ -# # Requires some commands defined in tests/bench.tests and some BENCHEXES defined above.\ -# # ) -# # tools/simplebench -v -ftests/bench.tests $(BENCHEXES) | tee doc/profs/$(TIME).bench -# # @rm -f benchresults.* -# # @(cd doc/profs; rm -f latest.bench; ln -s $(TIME).bench latest.bench) -# # criterionbench: samplejournals tools/criterionbench \ -# # $(call def-help,criterionbench,\ -# # run criterion benchmark tests and save graphical results\ -# # ) -# # tools/criterionbench -t png -k png -# # progressionbench: samplejournals tools/progressionbench \ -# # $(call def-help,progressionbench,\ -# # run progression benchmark tests and save graphical results\ -# # ) -# # tools/progressionbench -- -t png -k png -# throughput: throughput-hledger \ -# $(call def-help,throughput, show throughput at various data sizes with the default hledger executable ) -# throughput-%: samplejournals \ -# $(call def-help,throughput-HLEDGEREXE, show throughput at various data sizes with the given hledger executable ) -# @echo date: `date` -# @echo system: `uname -a` -# @echo executable: $* -# @echo version: `$* --version` -# @for n in 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 100000 ; do \ -# printf "%6d txns: " $$n; $* stats -f examples/$${n}x1000x10.journal | tail -1; \ -# done -# @date -# throughput-dev: samplejournals \ -# $(call def-help,throughput-dev, show throughput at various data sizes with the latest hledger dev build (optimised or not) ) -# @stack build hledger -# @stack exec -- make -s throughput +samplejournals: + tools/generatejournal.hs 3 5 5 > examples/ascii.journal + tools/generatejournal.hs 3 5 5 --chinese > examples/chinese.journal + tools/generatejournal.hs 3 5 5 --mixed > examples/mixed.journal + tools/generatejournal.hs 10 10 10 > examples/10x10x10.journal + tools/generatejournal.hs 100 100 10 > examples/100x100x10.journal + tools/generatejournal.hs 1000 1000 10 > examples/1000x1000x10.journal + tools/generatejournal.hs 1000 10000 10 > examples/1000x10000x10.journal + tools/generatejournal.hs 2000 1000 10 > examples/2000x1000x10.journal + tools/generatejournal.hs 3000 1000 10 > examples/3000x1000x10.journal + tools/generatejournal.hs 4000 1000 10 > examples/4000x1000x10.journal + tools/generatejournal.hs 5000 1000 10 > examples/5000x1000x10.journal + tools/generatejournal.hs 6000 1000 10 > examples/6000x1000x10.journal + tools/generatejournal.hs 7000 1000 10 > examples/7000x1000x10.journal + tools/generatejournal.hs 8000 1000 10 > examples/8000x1000x10.journal + tools/generatejournal.hs 9000 1000 10 > examples/9000x1000x10.journal + tools/generatejournal.hs 10000 1000 10 > examples/10000x1000x10.journal + tools/generatejournal.hs 10000 10000 10 > examples/10000x10000x10.journal + tools/generatejournal.hs 100000 1000 10 > examples/100000x1000x10.journal + tools/generatejournal.hs 1000000 1000 10 > examples/1000000x1000x10.journal + +# $ just --set BENCHEXES ledger,hledger bench + +BENCHEXES := 'hledger' + +bench: quickbench + +# run benchmark commands in bench.sh for each of BENCHEXES, with quickbench +@quickbench: + printf "Running benchmarks with {{ BENCHEXES }} (times are approximate, can be skewed):\n" + which quickbench >/dev/null && quickbench -w {{ BENCHEXES }} || echo "quickbench not installed (see bench.sh), skipping" + +# samplejournals bench.sh +# bench: samplejournals tests/bench.tests tools/simplebench \ +# $(call def-help,bench,\ +# run simple performance benchmarks and archive results\ +# Requires some commands defined in tests/bench.tests and some BENCHEXES defined above.\ +# ) +# tools/simplebench -v -ftests/bench.tests $(BENCHEXES) | tee doc/profs/$(TIME).bench +# @rm -f benchresults.* +# @(cd doc/profs; rm -f latest.bench; ln -s $(TIME).bench latest.bench) +# criterionbench: samplejournals tools/criterionbench \ +# $(call def-help,criterionbench,\ +# run criterion benchmark tests and save graphical results\ +# ) +# tools/criterionbench -t png -k png +# progressionbench: samplejournals tools/progressionbench \ +# $(call def-help,progressionbench,\ +# run progression benchmark tests and save graphical results\ +# ) +# tools/progressionbench -- -t png -k png + +# show throughput at various data sizes with the given hledger executable (requires samplejournals) +@throughput HLEDGEREXE: + echo date: `date` + echo system: `uname -a` + echo executable: {{ HLEDGEREXE }} + echo version: `{{ HLEDGEREXE }} --version` + for n in 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000 100000 ; do \ + printf "%6d txns: " $n; {{ HLEDGEREXE }} stats -f examples/${n}x1000x10.journal | tail -1; \ + done + date + +# show throughput at various data sizes with the latest hledger dev build, optimised or not (requires samplejournals) +@throughput-dev: + stack build hledger + stack exec -- just throughput hledger + # # prof: samplejournals \ # # $(call def-help,prof,\ # # generate and archive an execution profile\ @@ -632,60 +596,73 @@ mksamplejournals: # # view the last html code coverage report\ # # ) # # $(VIEWHTML) doc/profs/coverage/index.html -# ############################################################################### -# $(call def-help-subheading,DOCUMENTATION: (see also Shake.hs)) -# # http://www.haskell.org/haddock/doc/html/invoking.html -# STACKHADDOCK=time $(STACK) --verbosity=error haddock --fast --no-keep-going \ -# --only-locals --no-haddock-deps --no-haddock-hyperlink-source \ -# --haddock-arguments="--no-warnings" -# # -ghc-options='-optP-P' # workaround for http://trac.haskell.org/haddock/ticket/284 -# # uncomment to run haddock on fewer packages, saving time -# #HADDOCKPKGS=hledger-lib -# releasediag: \ -# $(call def-help,releasediag, optimise and commit RELEASING value map diagram ) -# pngquant doc/HledgerReleaseValueMap.png -f -o doc/HledgerReleaseValueMap.png && git add doc/HledgerReleaseValueMap.png && git commit -m ';doc: RELEASING: update value map' -- doc/HledgerReleaseValueMap.png -# # Renders all hledger packages. Run make haddock-open to open contents page. -# haddock: \ -# $(call def-help,haddock, regenerate haddock docs for the hledger packages and open them ) -# $(STACKHADDOCK) $(HADDOCKPKGS) && make -s haddock-open # --open shows all deps and packages +# ** documentation + +DOCUMENTATION: + +# see also Shake.hs +# http://www.haskell.org/haddock/doc/html/invoking.html + +# optimise and commit RELEASING value map diagram +@releasediag: + pngquant doc/HledgerReleaseValueMap.png -f -o doc/HledgerReleaseValueMap.png + git add doc/HledgerReleaseValueMap.png + git commit -m ';doc: RELEASING: update value map' -- doc/HledgerReleaseValueMap.png + +STACKHADDOCK := 'time ' + STACK + ' --verbosity=error haddock --fast --no-keep-going \ + --only-locals --no-haddock-deps --no-haddock-hyperlink-source \ + --haddock-arguments="--no-warnings" \ + ' + +# -ghc-options='-optP-P' # workaround for http://trac.haskell.org/haddock/ticket/284 + +HADDOCKPKGS := 'hledger-lib' + +# regenerate haddock docs for the hledger packages and open them +haddock: + {{ STACKHADDOCK }} {{ HADDOCKPKGS }} + just haddock-open # --open shows all deps and packages + # # Rerenders all hledger packages. Run make haddock-open to open contents page. # haddock-watch1: \ -# $(call def-help,haddock-watch, regenerate haddock docs when files change ) -# $(STACKHADDOCK) $(HADDOCK_PKGS) --file-watch --exec='echo done' +# $(call def-help,haddock-watch, regenerate haddock docs when files change ) +# $(STACKHADDOCK) $(HADDOCK_PKGS) --file-watch --exec='echo done' # # Rerenders hledger-lib modules, opens hledger-lib contents page. # haddock-watch2: \ -# $(call def-help,haddock-watch2, regenerate hledger-lib haddock docs when files change ) -# watchexec -r -e yaml,cabal,hs --print-events -- \ -# $(STACKHADDOCK) --verbosity=info $(HADDOCK_PKGS) --exec="'echo done'" hledger-lib --open +# $(call def-help,haddock-watch2, regenerate hledger-lib haddock docs when files change ) +# watchexec -r -e yaml,cabal,hs --print-events -- \ +# $(STACKHADDOCK) --verbosity=info $(HADDOCK_PKGS) --exec="'echo done'" hledger-lib --open # # Rerenders/reopens the Hledger module, without submodules. (Fastest) # haddock-watch: \ -# $(call def-help,haddock-watch3, quickly regenerate & reload Hledger.hs haddock when files change ) -# watchexec -r -e yaml,cabal,hs --print-events --shell=none -- bash -c 'mkdir -p tmp && rm -f tmp/Hledger.html && haddock -h -o tmp hledger-lib/Hledger.hs --no-warnings --no-print-missing-docs 2>&1 | grep -v "Could not find documentation" && open tmp/Hledger.html' -# haddock-open: \ -# $(call def-help,haddock-open, open the haddock packages contents page in a browser ) -# $(BROWSE) `stack path --local-install-root`/doc/index.html +# $(call def-help,haddock-watch3, quickly regenerate & reload Hledger.hs haddock when files change ) +# watchexec -r -e yaml,cabal,hs --print-events --shell=none -- bash -c 'mkdir -p tmp && rm -f tmp/Hledger.html && haddock -h -o tmp hledger-lib/Hledger.hs --no-warnings --no-print-missing-docs 2>&1 | grep -v "Could not find documentation" && open tmp/Hledger.html' + +# open the haddock packages contents page in a browser +haddock-open: + {{ BROWSE }} `{{ STACK }} path --local-install-root`/doc/index.html + # hoogle-setup: $(call def-help,hoogle-setup, install hoogle then build haddocks and a hoogle db for the project and all deps ) -# stack hoogle --rebuild +# stack hoogle --rebuild # HOOGLEBROWSER="/Applications/Firefox Dev.app/Contents/MacOS/firefox" # safari not supported # hoogle-serve: $(call def-help,hoogle-serve, run hoogle web app and open in browser after doing setup if needed ) -# $(HOOGLEBROWSER) http://localhost:8080 & -# stack --verbosity=warn hoogle --server +# $(HOOGLEBROWSER) http://localhost:8080 & +# stack --verbosity=warn hoogle --server # # sourcegraph: \ -# # $(call def-help,sourcegraph,\ -# # \ -# # ) -# # for p in $(PACKAGES); do (cd $$p; SourceGraph $$p.cabal); done +# # $(call def-help,sourcegraph,\ +# # \ +# # ) +# # for p in $(PACKAGES); do (cd $$p; SourceGraph $$p.cabal); done # manuals-watch: Shake \ -# $(call def-help,manuals-watch, rerender manuals when their source files change ) -# ls $(DOCSOURCEFILES) | entr ./Shake -VV manuals +# $(call def-help,manuals-watch, rerender manuals when their source files change ) +# ls $(DOCSOURCEFILES) | entr ./Shake -VV manuals # man-watch: man-watch-hledger \ -# $(call def-help,man-watch, run man on the hledger man page when its source file changes ) +# $(call def-help,man-watch, run man on the hledger man page when its source file changes ) # man-watch-%: Shake \ -# $(call def-help,man-watch-PROG, run man on the given man page when its source file changes. Eg make man-watch-hledger-web ) -# $(WATCHEXEC) -r -w $*/$*.m4.md './Shake $*/$*.1 && man $*/$*.1' +# $(call def-help,man-watch-PROG, run man on the given man page when its source file changes. Eg make man-watch-hledger-web ) +# $(WATCHEXEC) -r -w $*/$*.m4.md './Shake $*/$*.1 && man $*/$*.1' # shakehelp-watch: \ -# $(call def-help,shakehelp-watch, rerender Shake.hs's help when it changes) -# ls Shake.hs | entr -c ./Shake.hs +# $(call def-help,shakehelp-watch, rerender Shake.hs's help when it changes) +# ls Shake.hs | entr -c ./Shake.hs # # The following rule, for updating the website, gets called on hledger.org by: # # 1. github-post-receive (github webhook handler), when something is pushed # # to the main or wiki repos on Github. Config: @@ -696,29 +673,29 @@ mksamplejournals: # .PHONY: site # # Use the existing Shake executable without recompiling it, so as not to automatially run unreviewed code by hook ? I think this no longer applies. # # site: $(call def-help,site-build, update the hledger.org website (run this on hledger.org, or run "make hledgerorg" elsewhere) ) -# # @[ ! -x Shake ] \ -# # && echo 'Please run "make Shake" first (manual compilation required for safety)' \ -# # || ( \ -# # echo; \ -# # ./Shake -V site; \ -# # ) 2>&1 | tee -a site.log +# # @[ ! -x Shake ] \ +# # && echo 'Please run "make Shake" first (manual compilation required for safety)' \ +# # || ( \ +# # echo; \ +# # ./Shake -V site; \ +# # ) 2>&1 | tee -a site.log # site: Shake \ -# $(call def-help,site, update the hledger.org website (run on hledger.org, or run "make hledgerorg" elsewhere) ) -# ./Shake -V site 2>&1 | tee -a site.log +# $(call def-help,site, update the hledger.org website (run on hledger.org, or run "make hledgerorg" elsewhere) ) +# ./Shake -V site 2>&1 | tee -a site.log # BROWSE=open # BROWSEDELAY=5 # LOCALSITEURL=http://localhost:3000/dev/hledger.html # site-watch: $(call def-help,site-watch, open a browser on the website (in ./site) and rerender when docs or web pages change ) -# @make -s Shake -# @(printf "\nbrowser will open in $(BROWSEDELAY)s (adjust BROWSE in Makefile if needed)...\n\n"; sleep $(BROWSEDELAY); $(BROWSE) $(LOCALSITEURL)) & -# @$(WATCHEXEC) --print-events -e md,m4 -i hledger.md -i hledger-ui.md -i hledger-web.md -r './Shake webmanuals && ./Shake orgfiles && make -sC site serve' +# @make -s Shake +# @(printf "\nbrowser will open in $(BROWSEDELAY)s (adjust BROWSE in Makefile if needed)...\n\n"; sleep $(BROWSEDELAY); $(BROWSE) $(LOCALSITEURL)) & +# @$(WATCHEXEC) --print-events -e md,m4 -i hledger.md -i hledger-ui.md -i hledger-web.md -r './Shake webmanuals && ./Shake orgfiles && make -sC site serve' # ** installing INSTALLING: # # copy the current ~/.local/bin/hledger to bin/old/hledger-VER # @copy-as VER: -# cp ~/.local/bin/hledger bin/old/hledger-{{ VER }}; echo "bin/hledger-{{ VER }}" +# cp ~/.local/bin/hledger bin/old/hledger-{{ VER }}; echo "bin/hledger-{{ VER }}" # stack install, then copy the hledger executables to bin/old/hledger*-VER @installas VER: @@ -839,8 +816,6 @@ _gitSwitchAutoCreate BRANCH: git switch -c {{ BRANCH }} fi -# ############################################################################### -# $(call def-help-subheading,RELEASING:) # # old/desired release process: # # a normal release: echo 0.7 >.version; make release # # a bugfix release: echo 0.7.1 >.version; make release @@ -850,161 +825,161 @@ _gitSwitchAutoCreate BRANCH: # ISCLEAN=git diff-index --quiet HEAD -- # # stop if the working directory has uncommitted changes # iscleanwd: -# @$(ISCLEAN) || (echo "please clean the working directory first"; false) +# @$(ISCLEAN) || (echo "please clean the working directory first"; false) # # stop if the given file(s) have uncommitted changes # isclean-%: -# @$(ISCLEAN) $* || (echo "please clean these files first: $*"; false) +# @$(ISCLEAN) $* || (echo "please clean these files first: $*"; false) # # update all cabal files based on latest package.yaml files using stack's built-in hpack # cabal: $(call def-help,cabal, regenerate cabal files from package.yaml files with stack ) -# $(STACK) build --dry-run --silent +# $(STACK) build --dry-run --silent # # Update all cabal files based on latest package.yaml files using a specific hpack version. # # To avoid warnings, this should be the same version as stack's built-in hpack. # cabal-with-hpack-%: -# $(STACK) build --with-hpack hpack-$* --dry-run --silent +# $(STACK) build --with-hpack hpack-$* --dry-run --silent # # updatecabal: gencabal $(call def-help,updatecabal, regenerate cabal files and commit ) -# # @read -p "please review changes then press enter to commit $(shell ls */*.cabal)" -# # git commit -m "update cabal files" $(shell ls */*.cabal) +# # @read -p "please review changes then press enter to commit $(shell ls */*.cabal)" +# # git commit -m "update cabal files" $(shell ls */*.cabal) # # we use shake for this job; so dependencies aren't checked here # manuals: Shake $(call def-help,manuals, regenerate and commit CLI help and manuals (might need -B) ) -# ./Shake manuals -# git commit -m ";doc: regen manuals" -m "[ci skip]" hledger*/hledger*.{1,5,info,txt} hledger/Hledger/Cli/Commands/*.txt +# ./Shake manuals +# git commit -m ";doc: regen manuals" -m "[ci skip]" hledger*/hledger*.{1,5,info,txt} hledger/Hledger/Cli/Commands/*.txt # tag: $(call def-help,tag, make git release tags for the project and all packages ) -# @for p in $(PACKAGES); do make tag-$$p; done -# @make tag-project +# @for p in $(PACKAGES); do make tag-$$p; done +# @make tag-project # tag-%: $(call def-help,tag-PKG, make a git release tag for PKG ) -# git tag -fs $*-`cat $*/.version` -m "Release $*-`cat $*/.version`" +# git tag -fs $*-`cat $*/.version` -m "Release $*-`cat $*/.version`" # tag-project: $(call def-help,tag-project, make a git release tag for the project as a whole ) -# git tag -fs `cat .version` -m "Release `cat .version`, https://hledger.org/release-notes.html#hledger-`cat .version | sed -e 's/\./-/g'`" -# @printf "if tagging a major release, please also review and run this command:\n" -# @printf " git tag -fs `cat .version`.99 master -m \"Start of next release cycle. This tag influences git describe and dev builds' version strings.\"\n" +# git tag -fs `cat .version` -m "Release `cat .version`, https://hledger.org/release-notes.html#hledger-`cat .version | sed -e 's/\./-/g'`" +# @printf "if tagging a major release, please also review and run this command:\n" +# @printf " git tag -fs `cat .version`.99 master -m \"Start of next release cycle. This tag influences git describe and dev builds' version strings.\"\n" # # hackageupload-dry: \ -# # $(call def-help,hackageupload-dry,\ -# # upload all packages to hackage; dry run\ -# # ) -# # for p in $(PACKAGES); do cabal upload $$p/dist/$$p-$(VERSION).tar.gz -v2 --check; done +# # $(call def-help,hackageupload-dry,\ +# # upload all packages to hackage; dry run\ +# # ) +# # for p in $(PACKAGES); do cabal upload $$p/dist/$$p-$(VERSION).tar.gz -v2 --check; done # hackageupload: \ -# $(call def-help,hackageupload, upload all packages to hackage from a release branch) -# tools/hackageupload $(PACKAGES) +# $(call def-help,hackageupload, upload all packages to hackage from a release branch) +# tools/hackageupload $(PACKAGES) # # showreleasestats stats: \ -# # showreleasedays \ -# # showunreleasedchangecount \ -# # showloc \ -# # showtestcount \ -# # showunittestcoverage \ -# # showreleaseauthors \ -# # showunreleasedcodechanges \ -# # showunpushedchanges \ -# # $(call def-help,showreleasestats stats,\ -# # show project stats useful for release notes\ -# # ) -# # # showerrors +# # showreleasedays \ +# # showunreleasedchangecount \ +# # showloc \ +# # showtestcount \ +# # showunittestcoverage \ +# # showreleaseauthors \ +# # showunreleasedcodechanges \ +# # showunpushedchanges \ +# # $(call def-help,showreleasestats stats,\ +# # show project stats useful for release notes\ +# # ) +# # # showerrors # # FROMTAG=. # # showreleasedays: \ -# # $(call def-help,showreleasedays,\ -# # \ -# # ) -# # @echo Days since last release: -# # @tools/dayssincetag.hs $(FROMTAG) | head -1 | cut -d' ' -f-1 -# # @echo +# # $(call def-help,showreleasedays,\ +# # \ +# # ) +# # @echo Days since last release: +# # @tools/dayssincetag.hs $(FROMTAG) | head -1 | cut -d' ' -f-1 +# # @echo # # # XXX # # showunreleasedchangecount: \ -# # $(call def-help,showunreleasedchangecount,\ -# # \ -# # ) -# # @echo Commits since last release: -# # @darcs changes --from-tag $(FROMTAG) --count -# # @echo +# # $(call def-help,showunreleasedchangecount,\ +# # \ +# # ) +# # @echo Commits since last release: +# # @darcs changes --from-tag $(FROMTAG) --count +# # @echo # describe: $(call def-help,describe, show a precise git-describe version string ) -# @git describe --tags --match 'hledger-[0-9]*' --dirty +# @git describe --tags --match 'hledger-[0-9]*' --dirty # # showreleaseauthors: $(call def-help,showreleaseauthors, show author names since last release) -# # @echo Commit authors since last release: -# # @git shortlog -sn $(CHANGELOGSTART).. # TODO undefined +# # @echo Commit authors since last release: +# # @git shortlog -sn $(CHANGELOGSTART).. # TODO undefined # showauthors: $(call def-help,showauthors, show all commit author names) -# @echo "Commit authors ($$(git shortlog -sn | wc -l | awk '{print $$1}'))": -# @git shortlog -sn +# @echo "Commit authors ($$(git shortlog -sn | wc -l | awk '{print $$1}'))": +# @git shortlog -sn # cloc: $(call def-help,cloc, count lines of source code ) -# @echo Lines of code including tests: -# @cloc --exclude-lang=HTML --exclude-dir=.stack-work,.idea,dist,old,bin,doc,site,.tutorial-data,static,angular . +# @echo Lines of code including tests: +# @cloc --exclude-lang=HTML --exclude-dir=.stack-work,.idea,dist,old,bin,doc,site,.tutorial-data,static,angular . # SCC=scc -z --cocomo-project-type semi-detached -f wide -s code # scc: $(call def-help,scc, count lines of source code with scc) -# @echo Lines of code including tests: -# @$(SCC) -i hs,sh,m4,hamlet +# @echo Lines of code including tests: +# @$(SCC) -i hs,sh,m4,hamlet # sccv: $(call def-help,sccv, count lines of source code with scc showing all files) -# @echo Lines of code including tests: -# @$(SCC) -i hs,sh,m4,hamlet --by-file +# @echo Lines of code including tests: +# @$(SCC) -i hs,sh,m4,hamlet --by-file # # `ls $(SOURCEFILES)` # # sloc: \ -# # $(call def-help,sloc,\ -# # \ -# # ) -# # @sloccount hledger-lib hledger hledger-web +# # $(call def-help,sloc,\ +# # \ +# # ) +# # @sloccount hledger-lib hledger hledger-web # # cloc: \ -# # $(call def-help,cloc,\ -# # \ -# # ) -# # @echo -# # @echo "Lines of code as of `date`:" -# # @echo -# # @echo "hledger-lib, hledger" -# # @cloc -q hledger-lib hledger 2>&1 | grep -v 'defined(' -# # @echo -# # @echo "hledger-web" -# # @cloc -q hledger-web 2>&1 | grep -v 'defined(' -# # @echo -# # @echo "hledger-lib, hledger, hledger-web" -# # @cloc -q hledger-lib hledger hledger-web 2>&1 | grep -v 'defined(' +# # $(call def-help,cloc,\ +# # \ +# # ) +# # @echo +# # @echo "Lines of code as of `date`:" +# # @echo +# # @echo "hledger-lib, hledger" +# # @cloc -q hledger-lib hledger 2>&1 | grep -v 'defined(' +# # @echo +# # @echo "hledger-web" +# # @cloc -q hledger-web 2>&1 | grep -v 'defined(' +# # @echo +# # @echo "hledger-lib, hledger, hledger-web" +# # @cloc -q hledger-lib hledger hledger-web 2>&1 | grep -v 'defined(' # # showtestcount: \ -# # $(call def-help,showtestcount,\ -# # \ -# # ) -# # @echo "Unit tests:" -# # @hledger test 2>&1 | cut -d' ' -f2 -# # @echo "Functional tests:" -# # @make --no-print functest | egrep '^ Total' | awk '{print $$2}' -# # @echo +# # $(call def-help,showtestcount,\ +# # \ +# # ) +# # @echo "Unit tests:" +# # @hledger test 2>&1 | cut -d' ' -f2 +# # @echo "Functional tests:" +# # @make --no-print functest | egrep '^ Total' | awk '{print $$2}' +# # @echo # # showunittestcoverage: \ -# # $(call def-help,showunittestcoverage,\ -# # \ -# # ) -# # @echo Unit test coverage: -# # @make --no-print quickcoverage | grep 'expressions' -# # @echo +# # $(call def-help,showunittestcoverage,\ +# # \ +# # ) +# # @echo Unit test coverage: +# # @make --no-print quickcoverage | grep 'expressions' +# # @echo # # # showerrors: -# # # @echo Known errors: -# # # @awk '/^** errors/, /^** / && !/^** errors/' NOTES.org | grep '^\*\*\* ' | tail +1 -# # # @echo +# # # @echo Known errors: +# # # @awk '/^** errors/, /^** / && !/^** errors/' NOTES.org | grep '^\*\*\* ' | tail +1 +# # # @echo # # # XXX # # showunpushedchanges showunpushed: \ -# # $(call def-help,showunpushedchanges showunpushed,\ -# # \ -# # ) -# # @echo "Changes not yet pushed upstream (to `darcs show repo | grep 'Default Remote' | cut -c 17-`):" -# # @-darcs push simon@joyful.com:/repos/hledger --dry-run | grep '*' | tac -# # @echo +# # $(call def-help,showunpushedchanges showunpushed,\ +# # \ +# # ) +# # @echo "Changes not yet pushed upstream (to `darcs show repo | grep 'Default Remote' | cut -c 17-`):" +# # @-darcs push simon@joyful.com:/repos/hledger --dry-run | grep '*' | tac +# # @echo # # # XXX # # showunreleasedcodechanges showunreleased showchanges: \ -# # $(call def-help,showunreleasedcodechanges showunreleased showchanges,\ -# # \ -# # ) -# # @echo "hledger code changes since last release:" -# # @darcs changes --from-tag $(FROMTAG) --matches "not (name docs: or name doc: or name site: or name tools:)" | grep '*' -# # @echo +# # $(call def-help,showunreleasedcodechanges showunreleased showchanges,\ +# # \ +# # ) +# # @echo "hledger code changes since last release:" +# # @darcs changes --from-tag $(FROMTAG) --matches "not (name docs: or name doc: or name site: or name tools:)" | grep '*' +# # @echo # # # XXX # # showcodechanges: \ -# # $(call def-help,showcodechanges,\ -# # \ -# # ) -# # @echo "hledger code changes:" -# # @darcs changes --matches "not (name docs: or name site: or name tools:)" | egrep '^ +(\*|tagged)' -# # @echo +# # $(call def-help,showcodechanges,\ +# # \ +# # ) +# # @echo "hledger code changes:" +# # @darcs changes --matches "not (name docs: or name site: or name tools:)" | egrep '^ +(\*|tagged)' +# # @echo # nix-hledger-version: $(call def-help,nix-hledger-version, show which version of hledger has reached nixpkgs) -# @curl -s https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/development/haskell-modules/hackage-packages.nix | grep -A1 'pname = "hledger"' +# @curl -s https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/development/haskell-modules/hackage-packages.nix | grep -A1 'pname = "hledger"' # nix-hledger-versions: $(call def-help,nix-hledger-versions, show versions of all hledger packages in nixpkgs) -# @curl -s https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/development/haskell-modules/hackage-packages.nix | grep -A1 'pname = "hledger' +# @curl -s https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/development/haskell-modules/hackage-packages.nix | grep -A1 'pname = "hledger' # nix-view-commits: $(call def-help,nix-view-commits, show recent haskell commits in nixpkgs) -# @open 'https://github.com/NixOS/nixpkgs/commits/master/pkgs/development/haskell-modules/hackage-packages.nix' +# @open 'https://github.com/NixOS/nixpkgs/commits/master/pkgs/development/haskell-modules/hackage-packages.nix' # list-commits: $(call def-help,list-commits, list all commits chronologically and numbered) -# @git log --format='%ad %h %s (%an)' --date=short --reverse | cat -n +# @git log --format='%ad %h %s (%an)' --date=short --reverse | cat -n # ** misc MISC: @@ -1080,51 +1055,51 @@ mkwebdirs: # ############################################################################### # $(call def-help-subheading,MISCELLANEOUS:) # installcommithook: $(call def-help,installcommithook, symlink tools/commitlint as .git/hooks/commit-msg) -# ln -s ../../tools/commitlint .git/hooks/commit-msg +# ln -s ../../tools/commitlint .git/hooks/commit-msg # watch-%: $(call def-help,watch-RULE, run make RULE repeatedly when any committed file changes) -# @git ls-files | entr -r make $* +# @git ls-files | entr -r make $* # Shake: Shake.hs $(call def-help,Shake, ensure the Shake script is compiled ) -# ./Shake.hs +# ./Shake.hs # usage: cabalusage stackusage \ -# $(call def-help,usage, show size of various dirs ) -# du -sh .git bin data doc extra -# du -sh . +# $(call def-help,usage, show size of various dirs ) +# du -sh .git bin data doc extra +# du -sh . # stackusage: \ -# $(call def-help,stackusage, show size of stack working dirs if any ) -# -du -shc `find . -name '.stack*'` +# $(call def-help,stackusage, show size of stack working dirs if any ) +# -du -shc `find . -name '.stack*'` # cabalusage: \ -# $(call def-help,cabalusage, show size of cabal working dirs if any ) -# -du -shc */dist* 2>/dev/null +# $(call def-help,cabalusage, show size of cabal working dirs if any ) +# -du -shc */dist* 2>/dev/null # # Generate an emacs TAGS file. Tag: # # 1. haskell source files with hasktags # # 2. other source files recognised by (exuberant) ctags and not excluded by .ctags. Keep .ctags up to date. # # 3. some extra files missed by the above, as just their file names (for tags-search, tags-query-replace etc.) # etags:$(call def-help,etags, generate emacs TAGS file for haskell source and other project files ) -# hasktags -e $(SOURCEFILES) -# ctags -a -e -R -# for f in \ -# $(WEBTEMPLATEFILES) \ -# $(DOCSOURCEFILES) \ -# $(TESTFILES) \ -# $(HPACKFILES) \ -# $(CABALFILES) \ -# Shake.hs \ -# ; do printf " \n$$f,1\n" >> TAGS; done -# -etagsls >TAGS.files +# hasktags -e $(SOURCEFILES) +# ctags -a -e -R +# for f in \ +# $(WEBTEMPLATEFILES) \ +# $(DOCSOURCEFILES) \ +# $(TESTFILES) \ +# $(HPACKFILES) \ +# $(CABALFILES) \ +# Shake.hs \ +# ; do printf " \n$$f,1\n" >> TAGS; done +# -etagsls >TAGS.files # etags-ls: # list files indexed in TAGS -# @rg -v '[  ]' TAGS | rg -r '$$1' '^(.*?)([0-9]+)?,[0-9,]+*' +# @rg -v '[  ]' TAGS | rg -r '$$1' '^(.*?)([0-9]+)?,[0-9,]+*' # cleantags: \ -# $(call def-help-hide,cleantags, remove tag files ) -# rm -f TAGS tags +# $(call def-help-hide,cleantags, remove tag files ) +# rm -f TAGS tags # stackclean: \ -# $(call def-help-hide,stackclean, remove .stack-work/ dirs ) -# $(STACK) purge +# $(call def-help-hide,stackclean, remove .stack-work/ dirs ) +# $(STACK) purge # cleanghco: \ -# $(call def-help-hide,cleanghc, remove ghc build leftovers ) -# rm -rf `find . -name "*.o" -o -name "*.hi" -o -name "*.dyn_o" -o -name "*.dyn_hi" -o -name "*~" | grep -vE '\.(stack-work|cabal-sandbox|virthualenv)'` +# $(call def-help-hide,cleanghc, remove ghc build leftovers ) +# rm -rf `find . -name "*.o" -o -name "*.hi" -o -name "*.dyn_o" -o -name "*.dyn_hi" -o -name "*~" | grep -vE '\.(stack-work|cabal-sandbox|virthualenv)'` # #rm -f `fd -I '\.(hi|o|dyn_hi|dyn_o)$'` # clean: cleanghco \ -# $(call def-help,clean, default cleanup (ghc build leftovers) ) +# $(call def-help,clean, default cleanup (ghc build leftovers) ) # Clean: stackclean cleanghco cleantags \ -# $(call def-help,Clean, thorough cleanup (stack/ghc leftovers/tags) ) +# $(call def-help,Clean, thorough cleanup (stack/ghc leftovers/tags) ) # # reverse = $(if $(wordlist 2,2,$(1)),$(call reverse,$(wordlist 2,$(words $(1)),$(1))) $(firstword $(1)),$(1)) From 7c82c54f0b9c9afeeae030fb6c1d2059ac9d6758 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 16 Dec 2023 10:46:20 -1000 Subject: [PATCH 12/13] ;just: more porting, cleanups --- Justfile | 256 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 168 insertions(+), 88 deletions(-) diff --git a/Justfile b/Justfile index 58d9bc56a3c..80e442d6140 100644 --- a/Justfile +++ b/Justfile @@ -1,19 +1,44 @@ #!/usr/bin/env just -# * Light project scripts, without file dependendencies -# using https://github.com/casey/just 0.16. +# * Project scripts, using https://github.com/casey/just (last tested with 1.16.0) +# Usage: alias j=just, run j to list available scripts. +# +# After many years with make and plain shell and haskell for +# scripting, just is better enough, and the goal of clean consolidated +# efficient project automation is so valuable, that I am relying on it +# even though it's not installed by default. +# +# All of Makefile has been absorbed below; uncomment/update/drop +# remaining bits when needed. Makefile will be removed some time soon. +# +# just currently lacks make-style file dependency tracking. When that +# is needed for efficiency, or when more powerful code is needed, use +# Shake.hs instead of just. +# +# Lines beginning with "# * ", "# ** ", etc are section headings, +# foldable in Emacs outshine-mode. Some extra Emacs highlighting: +# (add-hook 'just-mode-hook (lambda () +# (display-line-numbers-mode 1) +# (highlight-lines-matching-regexp "^# \\*\\*? " 'hi-yellow) ; level 1-2 outshine headings +# (highlight-lines-matching-regexp "^@?\\w.*\\w:$" 'hi-pink) ; recipe headings (misses recipes with dependencies) +# )) +# +# This file is formatted by `just _fmt`, which currently eats blank lines a bit. + +# ** Prelude + +# Reference: # https://docs.rs/regex/1.5.4/regex/#syntax Regexps # https://just.systems/man/en/chapter_31.html Functions # https://cheatography.com/linux-china/cheat-sheets/justfile Cheatsheet # https://github.com/casey/just/discussions -# This has absorbed all of Makefile; uncomment and update remaining bits when needed. -# See also Shake.hs. -# ** prelude -@help: - just -lu +# Invocations of just in this file assume you are in this justfile's directory, +# since otherwise we must write --justfile {{ justfile() }} or {{ just }} everywhere. -# This and all other just invocations assume you are in this justfile's directory, -# otherwise we must write --justfile {{ justfile() }} or {{ just }} everywhere. +# list this justfile's recipes, optionally filtered by REGEX +@help *REGEX: + if [[ '{{ REGEX }}' =~ '' ]]; then just -lu; else just -lu | rg -i '{{ REGEX }}'; fi +# if [[ "$REGEX" =~ "" ]]; then just -lu; else just -lu | rg -i "$REGEX"; true; fi @_check: just --fmt --unstable --check @@ -24,7 +49,29 @@ @_watch: watchexec -w {{ justfile() }} -- 'just; just -q _check && echo format ok || echo non-standard format' -# ** vars +# rerun RECIPE when any git-committed file changes +watchgit RECIPE *OPTS: + #!/usr/bin/env bash + watchexec -r --filter-file <(git ls-files) -- just $RECIPE + +# show watchexec env vars when any git-committed file changes +watchgitdbg *OPTS: + #!/usr/bin/env bash + watchexec -r --filter-file <(git ls-files) {{ OPTS }} -- 'env | rg "WATCHEXEC\w*"; true' + +# show watchexec env vars when any file changes, ignoring nothing and printing events +watchdbg *OPTS: + watchexec --ignore-nothing --print-events {{ OPTS }} -- 'env | rg "WATCHEXEC\w*"; true' + +# Constants and recipe arguments will also be available as environment variables +# in recipes, making just code easier to convert to and from shell, so you can +# write $VAR instead of {{ VAR }}. Notes: +# They handle multi-word values differently, {{ }} is better ? +# In command lines in output, {{ }} is fully evaluated, $ is not. +set export + +# ** Constants + # GHC-compiled executables require a locale (and not just C) or they # will die on encountering non-ascii data. Set LANG to something if not already set. # export LANG? := 'en_US.UTF-8' @@ -115,6 +162,24 @@ SOURCEFILES := '\ hledger-lib/Text/*/*hs \ ' +SOURCEFILES2 := ''' + dev.hs + hledger/*hs + hledger/app/*hs + hledger/bench/*hs + hledger/test/*hs + hledger/Hledger/*hs + hledger/Hledger/*/*hs + hledger/Hledger/*/*/*hs + hledger-*/*hs + hledger-*/app/*hs + hledger-*/test/*hs + hledger-*/Hledger/*hs + hledger-*/Hledger/*/*hs + hledger-*/Hledger/*/*/*hs + hledger-lib/Text/*/*hs + ''' + # hledger-*/src/*hs \ HPACKFILES := '\ @@ -191,51 +256,51 @@ BUILDFLAGS := '-rtsopts ' + WARNINGS + GHCLOWMEMFLAGS + CABALMACROSFLAGS + ' -DD TIME := "{{ shell date +'%Y%m%d%H%M' }}" MONTHYEAR := "{{ shell date +'%B %Y' }}" -# ** GHCI +# ** ghci GHCI: -# run GHCI on hledger-lib + hledger +# run ghci on hledger-lib + hledger @ghci: {{ STACKGHCI }} exec -- {{ GHCI }} {{ BUILDFLAGS }} hledger/Hledger/Cli.hs -# run GHCI on hledger-lib + hledger with profiling/call stack information +# run ghci on hledger-lib + hledger with profiling/call stack information @ghci-prof: stack build --profile hledger --only-dependencies {{ STACKGHCI }} exec -- {{ GHCI }} {{ BUILDFLAGS }} -fexternal-interpreter -prof -fprof-auto hledger/Hledger/Cli.hs -# # run GHCI on hledger-lib + hledger + dev.hs script +# # run ghci on hledger-lib + hledger + dev.hs script # @ghci-dev: # {{ STACKGHCI }} exec -- {{ GHCI }} {{ BUILDFLAGS }} -fno-warn-unused-imports -fno-warn-unused-binds dev.hs -# run GHCI on hledger-lib + hledger + hledger-ui +# run ghci on hledger-lib + hledger + hledger-ui @ghci-ui: {{ STACKGHCI }} exec -- {{ GHCI }} {{ BUILDFLAGS }} hledger-ui/Hledger/UI/Main.hs -# run GHCI on hledger-lib + hledger + hledger-web +# run ghci on hledger-lib + hledger + hledger-web @ghci-web: {{ STACKGHCI }} exec -- {{ GHCI }} {{ BUILDFLAGS }} hledger-web/app/main.hs -# run GHCI on hledger-lib + hledger + hledger-web + hledger-web test suite +# run ghci on hledger-lib + hledger + hledger-web + hledger-web test suite @ghci-web-test: {{ STACKGHCI }} exec -- {{ GHCI }} {{ BUILDFLAGS }} hledger-web/test/test.hs # # better than stack exec ? # # XXX does not see changes to files -# # run GHCI on hledger-lib + test runner +# # run ghci on hledger-lib + test runner # ghci-lib-test: # {{ STACKGHCI }} ghci --ghc-options="\'-rtsopts {{ WARNINGS }} -ihledger-lib -DDEVELOPMENT -DVERSION=\"1.26.99\"\'" hledger-lib/test/unittest.hs -# run GHCI on all the hledger +# run ghci on all the hledger # ghci-all: # {{ STACK }} exec -- {{ GHCI }} {{ BUILDFLAGS }} \ # hledger-ui/Hledger/UI/Main.hs \ # hledger-web/app/main.hs \ -# run GHCI on hledger-lib doctests +# run ghci on hledger-lib doctests @ghci-doctest: cd hledger-lib; {{ STACKGHCI }} ghci hledger-lib:test:doctest -# run GHCI on Shake.hs +# run ghci on Shake.hs @ghci-shake: {{ STACK }} exec {{ SHAKEDEPS }} -- ghci Shake.hs @@ -318,11 +383,11 @@ ghcid-shake: # dev-heap-upload: # curl -F "file=@devprof-hc.hp" -F "title='hledger parser'" http://heap.ezyang.com/upload # curl -F "file=@devprof-hr.hp" -F "title='hledger parser'" http://heap.ezyang.com/upload -# ** building +# ** Building BUILDING: -# build the hledger package showing GHC codegen times/allocations +# build the hledger package showing ghc codegen times/allocations @buildtimes: time ({{ STACK }} build hledger --force-dirty --ghc-options='-fforce-recomp -ddump-timings' 2>&1 | grep -E '\bCodeGen \[.*time=') @@ -343,7 +408,7 @@ BUILDING: # # build "bin/hledgercov" for coverage reports (with ghc) # hledgercov: # {{ STACK }} ghc {{ MAIN }} -fhpc -o bin/hledgercov -outputdir .hledgercovobjs {{ BUILDFLAGS }} -# ** testing +# ** Testing TESTING: @@ -460,7 +525,7 @@ ADDONEXTS := 'pl py rb sh hs lhs rkt exe com bat' installtest: cd; {{ justfile_directory() }}/hledger-install/hledger-install.sh -# ** benchmarking +# ** Benchmarking BENCHMARKING: @@ -490,10 +555,8 @@ samplejournals: BENCHEXES := 'hledger' -bench: quickbench - # run benchmark commands in bench.sh for each of BENCHEXES, with quickbench -@quickbench: +@bench: printf "Running benchmarks with {{ BENCHEXES }} (times are approximate, can be skewed):\n" which quickbench >/dev/null && quickbench -w {{ BENCHEXES }} || echo "quickbench not installed (see bench.sh), skipping" @@ -596,9 +659,9 @@ bench: quickbench # # view the last html code coverage report\ # # ) # # $(VIEWHTML) doc/profs/coverage/index.html -# ** documentation +# ** Documenting -DOCUMENTATION: +DOCUMENTING: # see also Shake.hs # http://www.haskell.org/haddock/doc/html/invoking.html @@ -689,7 +752,7 @@ haddock-open: # @make -s Shake # @(printf "\nbrowser will open in $(BROWSEDELAY)s (adjust BROWSE in Makefile if needed)...\n\n"; sleep $(BROWSEDELAY); $(BROWSE) $(LOCALSITEURL)) & # @$(WATCHEXEC) --print-events -e md,m4 -i hledger.md -i hledger-ui.md -i hledger-web.md -r './Shake webmanuals && ./Shake orgfiles && make -sC site serve' -# ** installing +# ** Installing INSTALLING: @@ -707,7 +770,7 @@ INSTALLING: # # update shell completions in hledger package # shellcompletions: # make -C hledger/shell-completion/ clean-all all -# ** releasing +# ** Releasing RELEASING: @@ -889,24 +952,43 @@ _gitSwitchAutoCreate BRANCH: # # @echo Commits since last release: # # @darcs changes --from-tag $(FROMTAG) --count # # @echo -# describe: $(call def-help,describe, show a precise git-describe version string ) -# @git describe --tags --match 'hledger-[0-9]*' --dirty -# # showreleaseauthors: $(call def-help,showreleaseauthors, show author names since last release) -# # @echo Commit authors since last release: -# # @git shortlog -sn $(CHANGELOGSTART).. # TODO undefined -# showauthors: $(call def-help,showauthors, show all commit author names) -# @echo "Commit authors ($$(git shortlog -sn | wc -l | awk '{print $$1}'))": -# @git shortlog -sn -# cloc: $(call def-help,cloc, count lines of source code ) -# @echo Lines of code including tests: -# @cloc --exclude-lang=HTML --exclude-dir=.stack-work,.idea,dist,old,bin,doc,site,.tutorial-data,static,angular . -# SCC=scc -z --cocomo-project-type semi-detached -f wide -s code -# scc: $(call def-help,scc, count lines of source code with scc) -# @echo Lines of code including tests: -# @$(SCC) -i hs,sh,m4,hamlet -# sccv: $(call def-help,sccv, count lines of source code with scc showing all files) -# @echo Lines of code including tests: -# @$(SCC) -i hs,sh,m4,hamlet --by-file + +# show a precise git-describe version string +@describe: + git describe --tags --match 'hledger-[0-9]*' --dirty + +# show commit author names since last release +@authors-release: + echo "Commit authors since last release:" + git shortlog -sn `git tag --sort=-creatordate -l '[0-9]*' | head -1`.. + +# show all commit author names +@authors: + echo "Commit authors ($(git shortlog -sn | wc -l | awk '{print $1}'))": + git shortlog -sn + +# show all commit author names and emails +@authorsv: + echo "Commit authors ($(git shortlog -sn | wc -l | awk '{print $1}'))": + git shortlog -sne + +# count lines of code with cloc +@cloc: + echo "Lines of code including tests:" + cloc --exclude-lang=HTML --exclude-dir=.stack-work,.idea,dist,old,bin,doc,site,.tutorial-data,static,angular . + +SCC := 'scc -z --cocomo-project-type semi-detached -f wide -s code' + +# count lines of code with scc +@scc: + echo Lines of code including tests: + $SCC -i hs,sh,m4,hamlet + +# count lines of code with scc showing all files +@sccv: + echo Lines of code including tests: + $SCC -i hs,sh,m4,hamlet --by-file + # # `ls $(SOURCEFILES)` # # sloc: \ # # $(call def-help,sloc,\ @@ -980,7 +1062,7 @@ _gitSwitchAutoCreate BRANCH: # @open 'https://github.com/NixOS/nixpkgs/commits/master/pkgs/development/haskell-modules/hackage-packages.nix' # list-commits: $(call def-help,list-commits, list all commits chronologically and numbered) # @git log --format='%ad %h %s (%an)' --date=short --reverse | cat -n -# ** misc +# ** Misc MISC: @@ -1052,45 +1134,43 @@ mkwebdirs: for p in ledger hledger beancount; do git -C ../$p log --format="%cd (%h) %s%n ($p) 1%n" --date=short --reverse >> project-commits.j; done echo "wrote project-commits.j" -# ############################################################################### -# $(call def-help-subheading,MISCELLANEOUS:) -# installcommithook: $(call def-help,installcommithook, symlink tools/commitlint as .git/hooks/commit-msg) -# ln -s ../../tools/commitlint .git/hooks/commit-msg -# watch-%: $(call def-help,watch-RULE, run make RULE repeatedly when any committed file changes) -# @git ls-files | entr -r make $* +# symlink tools/commitlint as .git/hooks/commit-msg +installcommithook: + ln -s ../../tools/commitlint .git/hooks/commit-msg + # Shake: Shake.hs $(call def-help,Shake, ensure the Shake script is compiled ) # ./Shake.hs -# usage: cabalusage stackusage \ -# $(call def-help,usage, show size of various dirs ) -# du -sh .git bin data doc extra -# du -sh . -# stackusage: \ -# $(call def-help,stackusage, show size of stack working dirs if any ) -# -du -shc `find . -name '.stack*'` -# cabalusage: \ -# $(call def-help,cabalusage, show size of cabal working dirs if any ) -# -du -shc */dist* 2>/dev/null -# # Generate an emacs TAGS file. Tag: -# # 1. haskell source files with hasktags -# # 2. other source files recognised by (exuberant) ctags and not excluded by .ctags. Keep .ctags up to date. -# # 3. some extra files missed by the above, as just their file names (for tags-search, tags-query-replace etc.) -# etags:$(call def-help,etags, generate emacs TAGS file for haskell source and other project files ) -# hasktags -e $(SOURCEFILES) -# ctags -a -e -R -# for f in \ -# $(WEBTEMPLATEFILES) \ -# $(DOCSOURCEFILES) \ -# $(TESTFILES) \ -# $(HPACKFILES) \ -# $(CABALFILES) \ -# Shake.hs \ -# ; do printf " \n$$f,1\n" >> TAGS; done -# -etagsls >TAGS.files -# etags-ls: # list files indexed in TAGS -# @rg -v '[  ]' TAGS | rg -r '$$1' '^(.*?)([0-9]+)?,[0-9,]+*' -# cleantags: \ -# $(call def-help-hide,cleantags, remove tag files ) -# rm -f TAGS tags + +# show some big directory sizes +@usage: + -du -sh .git bin data doc extra `find . -name '.stack*' -prune -o -name 'dist' -prune -o -name 'dist-newstyle' -prune` 2>/dev/null | sort -hr + +# Tags: +# 1. haskell source files with hasktags +# 2. other source files recognised by (exuberant) ctags and not excluded by .ctags. Keep .ctags up to date. +# 3. some extra files missed by the above, as just their file names (for tags-search, tags-query-replace etc.) +# generate emacs TAGS file for haskell source and other project files, and list the tagged files in TAGS.files +@etags: + hasktags -e {{ SOURCEFILES }} +# ctags -a -e -R +# for f in \ +# $WEBTEMPLATEFILES \ +# $DOCSOURCEFILES \ +# $TESTFILES \ +# $HPACKFILES \ +# $CABALFILES \ +# Shake.hs \ +# ; do printf " \n$f,1\n" >> TAGS; done +# -just etags-ls >TAGS.files + +# list the files tagged in TAGS +@etags-ls: + rg -v '[  ]' TAGS | rg -r '$1' '^(.*?)([0-9]+)?,[0-9,]+*' + +# remove TAGS files +@etags-clean: + rm -f TAGS TAGS.files + # stackclean: \ # $(call def-help-hide,stackclean, remove .stack-work/ dirs ) # $(STACK) purge From 57a92a2caa81668beaf7924ca4b515b5b64bf61d Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 16 Dec 2023 10:46:41 -1000 Subject: [PATCH 13/13] ;git: mailmap: update to clean up git shortlog -se Dump everyone in there, it's easier. --- .mailmap | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 165 insertions(+), 9 deletions(-) diff --git a/.mailmap b/.mailmap index 09383665c46..0e653c5b08b 100644 --- a/.mailmap +++ b/.mailmap @@ -1,14 +1,170 @@ -Clint Adams -Marko Kocić -Marko Kocić +# sort -f +Aerex +afarrow +agander +Aiken Cairncross +Alan Young +Alejandro García Montoro +Aleksandar Dimitrov +Alex Chen +Alex Hirzel +Alvaro Fernando García +Amarandus +Amitai Burstein +Andreas Pauley +Andrew Jones +Andrew Lelechenko +Andriy Mykhaylyk +aragaer +Arjen Langebaerd +Arnout Engelen +Arsen Arsenović +awjchen +Ben Boeckel +Ben Creasy +bobobo1618 +Boyd Kelly +Brian Scott +Brian Wignall +Bryan Richter +Caleb Maclennan +Carel Fellinger +Carl Richard Theodor Schneider +Carlos Lopez-Camey +Charlie Ambrose +Charlotte Van Petegem +charukiewicz +Chris Lemaire +Christian G. Warden +Christoph Nicolai +Clint Adams +Colin Woodbury +crocket <748856+crocket@users.noreply.github.com> +Damien Cassou +Daniel Gröber +David D Lowe +David Reaver +David Zhang +Dmitry Astapov +Dominik Süß +Doug Goldstein +Eli Flanagan +Elijah Caine +Eric Kow +Eric Mertens +Everett Hildenbrandt +Evilham +Felix Van der Jeugt +Felix Yan +flip111 +Fun Ilrys (Nissar Chababy) +Gabriel Ebner +Gaith Hallak +Garret McGraw +Gergely Risko +gwern +Hans-Peter Deifel +Henning Thielemann +Ilja Kocken +Imuli +J. B. Rainsberger +Jacek Generowicz +Jacob Weisz +Jakob Schöttl +Jakub Zárybnický +Jan Zerebecki +Jay Neubrand +Jeff Richards +Jesse Rosenthal +Joachim Breitner +Joaquin "Florius" Azcarate +Joe Horsnell +Johann Klähn +Johannes Gerer +John Wiegley +Jonathan Dowland +Joseph Weston +Joshua Chia +Joshua Kehn +Judah Jacobson +Julien Moutinho +jungle-boogie +Justin Le +Kyle Marek-Spartz +Lawrence Wu +legrostdg +Luca Molteni +Léo Gaspard +M Parker +Malte Brandy +Mark Hansen +Marko Kocić +Marko Kocić marko.kocic +Martin Michlmayr +Mateus Furquim +Matthias Kauer +Max Bolingbroke +Max Thomas +Michael Grünewald +Michael Kainer +Michael Sanders Michael Snoyman -Nick Ingolia +Michael Walker +Mick Dekkers +Mitchell Rosen +Moritz Kiefer Mykola Orliuk -Oliver Braun -Ryan Desfosses -Sergei Trofimovich -Thomas R. Koll +Nadrieril +Nicholas Niro +Nick Ingolia +Nicolas Wavrant +Nikhil Jha +Nissar Chababy +Nolan Darilek +ob +Omari Norman +Patrick Fiaux +Patrik Keller +Pavan Rikhi +Pavlo Kerestey +Peter Sagerson +Peter Simons +Philipp Klocke +Pia Mancini +Pranesh Prakash +Rick Lupton +Robert Nielsen <32415800+RobertNielsen1@users.noreply.github.com> +Roman Cheplyaka +Rui Chen +Ryan Desfosses +Ryan Desfosses +S. Zeid +Sam Doshi +Sam Jeeves +Sam Jeeves +Samuel May +Sergei Trofimovich +Sergey Astanin +ShrykeWindgrace +Shubham Lagwankar +Simon Hengel +Simon Michael +Simon Michael +SpicyCat +Stefano Rodighiero +Stephen Morgan +Steven R. Baker +TANIGUCHI Kohei +Thomas R. Koll Tim Docker +Timofey ZAKREVSKIY +toonn +Trevor Riles Trygve Laugstøl +Vladimir Sorokin +Vladimir Zhelezov +Wad Xinruo Sun -gwern +Yann Büchau +Yehoshua Pesach Wallach +zieone <42358507+zieone@users.noreply.github.com>