;just: format

This commit is contained in:
Simon Michael 2023-12-09 10:49:11 -10:00
parent e1711f613f
commit 5798a73a96

114
justfile
View File

@ -6,8 +6,6 @@
# https://cheatography.com/linux-china/cheat-sheets/justfile Cheatsheet # https://cheatography.com/linux-china/cheat-sheets/justfile Cheatsheet
# https://github.com/casey/just/discussions # https://github.com/casey/just/discussions
# See also Makefile, Shake.hs. # See also Makefile, Shake.hs.
# ** prelude # ** prelude
@help: @help:
@ -19,53 +17,55 @@
@_fmt: @_fmt:
just -q _check || just --fmt --unstable just -q _check || just --fmt --unstable
# ** vars # ** vars
# GHC-compiled executables require a locale (and not just C) or they # 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. # will die on encountering non-ascii data. Set LANG to something if not already set.
# export LANG? := 'en_US.UTF-8' # export LANG? := 'en_US.UTF-8'
# command to run during profiling (time and heap) # command to run during profiling (time and heap)
PROFCMD := 'stack exec --profile -- hledger balance -f examples/10000x1000x10.journal >/dev/null' PROFCMD := 'stack exec --profile -- hledger balance -f examples/10000x1000x10.journal >/dev/null'
#PROFRTSFLAGS := '-p' #PROFRTSFLAGS := '-p'
PROFRTSFLAGS := '-P' PROFRTSFLAGS := '-P'
# # command to run during "make coverage" # # command to run during "make coverage"
# COVCMD := 'test' # COVCMD := 'test'
# COVCMD := '-f test-wf.csv print' # COVCMD := '-f test-wf.csv print'
# misc. system tools # misc. system tools
BROWSE := 'open' BROWSE := 'open'
# VIEWHTML := '{{ BROWSE }}' # VIEWHTML := '{{ BROWSE }}'
# VIEWPDF := '{{ BROWSE }}' # VIEWPDF := '{{ BROWSE }}'
# PRINT := 'lpr' # PRINT := 'lpr'
#GHC := 'ghc' #GHC := 'ghc'
GHCI := 'ghci' #-package ghc-datasize #-package ghc-heap-view
GHCI := 'ghci'
# GHCPKG := 'ghc-pkg' # GHCPKG := 'ghc-pkg'
# HADDOCK := 'haddock' # HADDOCK := 'haddock'
# CABAL := 'cabal' # CABAL := 'cabal'
# CABALINSTALL := 'cabal install -w {{ GHC }}' # CABALINSTALL := 'cabal install -w {{ GHC }}'
# Which stack command (and in particular, stack yaml/GHC version) to use for building etc. ? # Which stack command (and in particular, stack yaml/GHC version) to use for building etc. ?
STACK := 'stack' STACK := 'stack'
#STACK := 'stack --stack-yaml=stack8.10.yaml' #STACK := 'stack --stack-yaml=stack8.10.yaml'
# Or override temporarily with an env var: # Or override temporarily with an env var:
# STACK := '"stack --stack-yaml=stack8.10.yaml" make functest' # STACK := '"stack --stack-yaml=stack8.10.yaml" make functest'
# Which stack command (stack yaml, GHC version) to use for ghci[d] operations ? # Which stack command (stack yaml, GHC version) to use for ghci[d] operations ?
STACKGHCI := STACK
#STACKGHCI := 'stack --stack-yaml=stack9.2.yaml'
STACKGHCI := STACK
#STACKGHCI := 'stack --stack-yaml=stack9.2.yaml'
# if using an unreleased stack with a newer hpack than the one mentioned in */*.cabal, # 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: # it will give warnings. To silence these, put the old hpack-X.Y in $PATH and uncomment:
#STACK := 'stack --with-hpack=hpack-0.20' #STACK := 'stack --with-hpack=hpack-0.20'
# --threads := '16 sometimes gives "commitAndReleaseBuffer: resource vanished (Broken pipe)" but seems harmless' # --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, ' # --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. # slow hackage index or compiler setup on first build, etc.
SHELLTESTOPTS := '--execdir --threads=64 --exclude=/_' SHELLTESTOPTS := '--execdir --threads=64 --exclude=/_'
# make sure shelltest is a released version of shelltestrunner # 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 }}' # SHELLTEST := 'COLUMNS=80 PATH=~/.local/bin:/usr/bin:/bin shelltest {{ SHELLTESTOPTS }}'
# run shell tests using the stack build of hledger # run shell tests using the stack build of hledger
#SHELLTESTSTK := 'shelltest -w `stack exec which hledger` {{ SHELLTESTOPTS }}' #SHELLTESTSTK := 'shelltest -w `stack exec which hledger` {{ SHELLTESTOPTS }}'
SHELLTESTSTK := 'COLUMNS=80 ' + STACK + ' exec -- shelltest ' + SHELLTESTOPTS SHELLTESTSTK := 'COLUMNS=80 ' + STACK + ' exec -- shelltest ' + SHELLTESTOPTS
WATCHEXEC := 'watchexec' WATCHEXEC := 'watchexec'
PACKAGES := '\ PACKAGES := '\
hledger-lib \ hledger-lib \
hledger \ hledger \
hledger-ui \ hledger-ui \
hledger-web \ hledger-web \
' '
BINARIES := '\ BINARIES := '\
hledger \ hledger \
hledger-ui \ hledger-ui \
hledger-web hledger-web
' '
INCLUDEPATHS := '\ INCLUDEPATHS := '\
-ihledger-lib \ -ihledger-lib \
-ihledger \ -ihledger \
@ -97,11 +94,11 @@ INCLUDEPATHS := '\
-ihledger-web \ -ihledger-web \
-ihledger-web/app \ -ihledger-web/app \
' '
MAIN := 'hledger/app/hledger-cli.hs' MAIN := 'hledger/app/hledger-cli.hs'
# All source files in the project (plus a few strays like Setup.hs & hlint.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. # Used eg for building tags. Doesn't reliably catch all source files.
SOURCEFILES := '\ SOURCEFILES := '\
dev.hs \ dev.hs \
hledger/*hs \ hledger/*hs \
@ -119,46 +116,37 @@ SOURCEFILES := '\
hledger-*/Hledger/*/*/*hs \ hledger-*/Hledger/*/*/*hs \
hledger-lib/Text/*/*hs \ hledger-lib/Text/*/*hs \
' '
# hledger-*/src/*hs \ # hledger-*/src/*hs \
HPACKFILES := '\ HPACKFILES := '\
hledger/*package.yaml \ hledger/*package.yaml \
hledger-*/*package.yaml \ hledger-*/*package.yaml \
' '
CABALFILES := '\ CABALFILES := '\
hledger/hledger.cabal \ hledger/hledger.cabal \
hledger-*/*.cabal \ hledger-*/*.cabal \
' '
MANUALSOURCEFILES := '\ MANUALSOURCEFILES := '\
doc/common.m4 \ doc/common.m4 \
*/*.m4.md \ */*.m4.md \
' '
MANUALGENFILES := '\ MANUALGENFILES := '\
hledger*/hledger*.{1,5,info,txt} \ hledger*/hledger*.{1,5,info,txt} \
' '
COMMANDHELPFILES := '\ COMMANDHELPFILES := '\
hledger/Hledger/Cli/Commands/*.md \ hledger/Hledger/Cli/Commands/*.md \
' '
WEBTEMPLATEFILES := '\ WEBTEMPLATEFILES := '\
hledger-web/templates/* \ hledger-web/templates/* \
' '
WEBCODEFILES := '\ WEBCODEFILES := '\
hledger-web/static/*.js \ hledger-web/static/*.js \
hledger-web/static/*.css \ hledger-web/static/*.css \
' '
DOCSOURCEFILES := '\ DOCSOURCEFILES := '\
README.md \ README.md \
CONTRIBUTING.md' \ CONTRIBUTING.md' + MANUALSOURCEFILES + COMMANDHELPFILES
+ MANUALSOURCEFILES \
+ COMMANDHELPFILES
TESTFILES := '\ TESTFILES := '\
hledger/test/*.test \ hledger/test/*.test \
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 # # file(s) which require recompilation for a build to have an up-to-date version string
# VERSIONSOURCEFILE := 'hledger/Hledger/Cli/Version.hs' # VERSIONSOURCEFILE := 'hledger/Hledger/Cli/Version.hs'
# Two or three-part version string, set as program version in builds made by this makefile. # 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). # We use hledger CLI's current version (XXX for all packages, which isn't quite right).
export VERSION := `cat hledger/.version` export VERSION := `cat hledger/.version`
# Flags for ghc builds. # Flags for ghc builds.
# Warnings to see during dev tasks like make ghci*. See also the warnings in package.yamls. # Warnings to see during dev tasks like make ghci*. See also the warnings in package.yamls.
# XXX redundant with package.yamls ? # XXX redundant with package.yamls ?
WARNINGS := '\ WARNINGS := '\
-Wall \ -Wall \
-Wno-incomplete-uni-patterns \ -Wno-incomplete-uni-patterns \
@ -186,33 +174,25 @@ WARNINGS := '\
' '
# if you have need to try building in less memory # 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 # ghc-only builds need the macro definitions generated by cabal
# from cabal's dist or dist-sandbox dir, hopefully there's just one: # from cabal's dist or dist-sandbox dir, hopefully there's just one:
#CABALMACROSFLAGS := '-optP-include -optP hledger/dist*/build/autogen/cabal_macros.h' #CABALMACROSFLAGS := '-optP-include -optP hledger/dist*/build/autogen/cabal_macros.h'
# or from stack's dist dir: # or from stack's dist dir:
#CABALMACROSFLAGS := '-optP-include -optP hledger/.stack-work/dist/*/*/build/autogen/cabal_macros.h' #CABALMACROSFLAGS := '-optP-include -optP hledger/.stack-work/dist/*/*/build/autogen/cabal_macros.h'
CABALMACROSFLAGS := ''
BUILDFLAGS := \ CABALMACROSFLAGS := ''
'-rtsopts ' \ BUILDFLAGS := '-rtsopts ' + WARNINGS + GHCLOWMEMFLAGS + CABALMACROSFLAGS + ' -DDEVELOPMENT' + ' -DVERSION=\"' + VERSION + '\"' + INCLUDEPATHS
+ WARNINGS \
+ GHCLOWMEMFLAGS \
+ CABALMACROSFLAGS \
+ ' -DDEVELOPMENT' \
+ ' -DVERSION=\"'+VERSION+'\"' \
+ INCLUDEPATHS \
# -fplugin Debug.Breakpoint \ # -fplugin Debug.Breakpoint \
# -fhide-source-paths \ # -fhide-source-paths \
# PROFBUILDFLAGS := '-prof -fprof-auto -osuf hs_p' # PROFBUILDFLAGS := '-prof -fprof-auto -osuf hs_p'
TIME := "{{ shell date +'%Y%m%d%H%M' }}" TIME := "{{ shell date +'%Y%m%d%H%M' }}"
MONTHYEAR := "{{ shell date +'%B %Y' }}" MONTHYEAR := "{{ shell date +'%B %Y' }}"
# ** misc # ** misc
# sym-link some directories required by hledger-web dev builds # sym-link some directories required by hledger-web dev builds
@ -222,7 +202,6 @@ mkwebdirs:
ln -sf hledger-web/static ln -sf hledger-web/static
ln -sf hledger-web/templates ln -sf hledger-web/templates
# ** GHCI # ** GHCI
# run GHCI on hledger-lib + hledger # run GHCI on hledger-lib + hledger
@ -255,7 +234,6 @@ mkwebdirs:
# # run GHCI on hledger-lib + test runner # # run GHCI on hledger-lib + test runner
# ghci-lib-test: # ghci-lib-test:
# {{ STACKGHCI }} ghci --ghc-options="\'-rtsopts {{ WARNINGS }} -ihledger-lib -DDEVELOPMENT -DVERSION=\"1.26.99\"\'" hledger-lib/test/unittest.hs # {{ 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: # ghci-all:
# {{ STACK }} exec -- {{ GHCI }} {{ BUILDFLAGS }} \ # {{ STACK }} exec -- {{ GHCI }} {{ BUILDFLAGS }} \
@ -270,7 +248,6 @@ mkwebdirs:
@ghci-shake: @ghci-shake:
{{ STACK }} exec {{ SHAKEDEPS }} -- ghci Shake.hs {{ STACK }} exec {{ SHAKEDEPS }} -- ghci Shake.hs
# ** ghcid # ** ghcid
# run ghcid on hledger-lib + hledger # run ghcid on hledger-lib + hledger
@ -285,14 +262,13 @@ mkwebdirs:
@ghcid-web: @ghcid-web:
ghcid -c 'just ghci-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-web-run:
ghcid -c 'just ghci-web' --test ':main -f examples/sample.journal --port 5001 --serve' ghcid -c 'just ghci-web' --test ':main -f examples/sample.journal --port 5001 --serve'
# # run ghcid autobuilding and running the test command # # run ghcid autobuilding and running the test command
# ghcid-test: # ghcid-test:
# ghcid -c 'just ghci' --test ':main test -- --color=always' # ghcid -c 'just ghci' --test ':main test -- --color=always'
# # run ghcid autobuilding and running the test command with this TESTPATTERN # # run ghcid autobuilding and running the test command with this TESTPATTERN
# ghcid-test-%: # ghcid-test-%:
# ghcid -c 'just ghci' --test ':main test -- --color=always -p$*' # 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 ghcid -c 'cd hledger-lib; {{ STACK }} ghci hledger-lib:test:doctest' --test ':main' --reload hledger-lib
GHCIDRESTART := '--restart Makefile --restart Makefile.local' GHCIDRESTART := '--restart Makefile --restart Makefile.local'
GHCIDRELOAD := '--reload t.j --reload t.timedot' GHCIDRELOAD := '--reload t.j --reload t.timedot'
GHCIDCMD := ':main -f t.j bal date:today -S' 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 # # run ghcid autobuilding and running a custom GHCI command with reload/restart on certain files - customise this
# ghcid-watch watch: # ghcid-watch watch:
# ghcid -c 'just ghci' --test '{{ GHCIDCMD }}' {{ GHCIDRELOAD }} {{ GHCIDRESTART }} # ghcid -c 'just ghci' --test '{{ GHCIDCMD }}' {{ GHCIDRELOAD }} {{ GHCIDRESTART }}
# keep synced with Shake.hs header # keep synced with Shake.hs header
SHAKEDEPS := '\ SHAKEDEPS := '\
--package base-prelude \ --package base-prelude \
--package directory \ --package directory \
@ -320,42 +296,35 @@ SHAKEDEPS := '\
--package shake \ --package shake \
--package time \ --package time \
' '
# --package hledger-lib \ # for Hledger.Utils.Debug # --package hledger-lib \ # for Hledger.Utils.Debug
# run ghcid autobuilder on Shake.hs # run ghcid autobuilder on Shake.hs
ghcid-shake: ghcid-shake:
stack exec {{ SHAKEDEPS }} -- ghcid Shake.hs stack exec {{ SHAKEDEPS }} -- ghcid Shake.hs
# ** dev.hs script # ** dev.hs script
# # hledger-lib/Hledger/Read/TimeclockReaderPP.hs # # 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: # dev:
# {{ STACK }} ghc -- {{ CABALMACROSFLAGS }} -ihledger-lib dev.hs \ # {{ STACK }} ghc -- {{ CABALMACROSFLAGS }} -ihledger-lib dev.hs \
# # to get profiling deps installed, first do something like: # # to get profiling deps installed, first do something like:
# # stack build --library-profiling hledger-lib timeit criterion # # 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: # devprof:
# {{ STACK }} ghc -- {{ CABALMACROSFLAGS }} -ihledger-lib dev.hs -rtsopts -prof -fprof-auto -osuf p_o -o 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: # dev-profile:
# time ./devprof +RTS -P \ # time ./devprof +RTS -P \
# && cp devprof.prof devprof.prof.{{ TIME }} \ # && cp devprof.prof devprof.prof.{{ TIME }} \
# && profiterole devprof.prof # && profiterole devprof.prof
# # get heap profiles of the dev.hs script
# # get heap profiles of the dev.hs script
# dev-heap: # dev-heap:
# time ./devprof +RTS -hc -L1000 && cp devprof.hp devprof-hc.hp && hp2ps devprof-hc.hp # 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 # time ./devprof +RTS -hr -L1000 && cp devprof.hp devprof-hr.hp && hp2ps devprof-hr.hp
# dev-heap-upload: # dev-heap-upload:
# curl -F "file=@devprof-hc.hp" -F "title='hledger parser'" http://heap.ezyang.com/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 # curl -F "file=@devprof-hr.hp" -F "title='hledger parser'" http://heap.ezyang.com/upload
# ** special builds # ** special builds
# build the hledger package showing GHC codegen times/allocations # 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 # {{ STACK }} --verbosity=error install --ghc-options=-O0 hledger --local-bin-path=bin
# mv bin/hledger "$exe" # mv bin/hledger "$exe"
# echo "$exe" # echo "$exe"
# # build hledger with profiling enabled at bin/hledgerprof # # build hledger with profiling enabled at bin/hledgerprof
# hledgerprof: # hledgerprof:
# # {{ STACK }} --verbosity=error install --local-bin-path=bin hledger # # {{ STACK }} --verbosity=error install --local-bin-path=bin hledger
# {{ STACK }} build --profile hledger # {{ STACK }} build --profile hledger
# # hledger-lib --ghc-options=-fprof-auto # # hledger-lib --ghc-options=-fprof-auto
# # @echo "to profile, use {{ STACK }} exec --profile -- hledger ..." # # @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: # hledgercov:
# {{ STACK }} ghc {{ MAIN }} -fhpc -o bin/hledgercov -outputdir .hledgercovobjs {{ BUILDFLAGS }} # {{ STACK }} ghc {{ MAIN }} -fhpc -o bin/hledgercov -outputdir .hledgercovobjs {{ BUILDFLAGS }}
# ** installing # ** installing
# # copy the current ~/.local/bin/hledger to bin/old/hledger-VER # # copy the current ~/.local/bin/hledger to bin/old/hledger-VER
# @copy-as 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 # stack install, then copy the hledger executables to bin/old/hledger*-VER
@installas VER: @installas VER:
{{ STACK }} install --local-bin-path bin/old {{ 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 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+ # # make must be GNU Make 4.3+
# .PHONY: shellcompletions # .PHONY: shellcompletions
# # update shell completions in hledger package # # update shell completions in hledger package
# shellcompletions: # shellcompletions:
# make -C hledger/shell-completion/ clean-all all # make -C hledger/shell-completion/ clean-all all
# ** pushing # ** pushing
# push to github CI, wait for tests to pass, then push to master # push to github CI, wait for tests to pass, then push to master
@push: @push:
tools/push tools/push
# ** releasing # ** releasing
# Symlink/copy important files temporarily in .relfiles/. # Symlink/copy important files temporarily in .relfiles/.
@ -458,7 +418,6 @@ relprep VER:
# assumes the github remote is named "github" # assumes the github remote is named "github"
git push -f github HEAD:binaries git push -f github HEAD:binaries
# *** hledger version number helpers # *** hledger version number helpers
# (as hidden recipes, since just doesn't support global custom functions) # (as hidden recipes, since just doesn't support global custom functions)
# See doc/RELEASING.md > Glossary. # See doc/RELEASING.md > Glossary.
@ -502,7 +461,6 @@ _versionReleaseBranch VER:
echo "$MAJOR-branch" echo "$MAJOR-branch"
fi fi
# *** git helpers # *** git helpers
# Does the named branch exist in this git repo ? # Does the named branch exist in this git repo ?
@ -518,9 +476,7 @@ _gitSwitchAutoCreate BRANCH:
git switch -c {{ BRANCH }} git switch -c {{ BRANCH }}
fi fi
# ** misc # ** misc
# run some tests to validate the development environment # run some tests to validate the development environment
# check-setup: # check-setup:
# run some tests to validate the development environment\ # run some tests to validate the development environment\