From 4ec9bc4c538218a169a3d79d9adc1bb886a3cd18 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 18 Oct 2014 10:19:00 -0700 Subject: [PATCH] tools: make uninstall, reduces noise when testing Tries to unregister all three hledger packages from the user's package db (not cabal sandbox aware). --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index 76c5e1ff3..134cbd4a0 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,7 @@ PRINT=lpr GHC=ghc GHCI=ghci +GHCPKG=ghc-pkg HADDOCK=haddock CABAL=cabal CABALINSTALL=cabal install -w $(GHC) @@ -198,6 +199,14 @@ installdeps: installdeps-force: $(CABALINSTALL) $(patsubst %,./%,$(PACKAGES)) $(EXTRAINSTALLARGS) --enable-tests --only-dependencies --allow-newer --force-reinstalls +# unregister all packages, assuming they are defined lowest-dependency first +# avoids some reinstall noise when repeatedly doing make install +uninstall: + -for p in $(call reverse,$(PACKAGES)); do $(GHCPKG) unregister $$p; done + +# utility function +reverse = $(if $(wordlist 2,2,$(1)),$(call reverse,$(wordlist 2,$(words $(1)),$(1))) $(firstword $(1)),$(1)) + # run a cabal command in all hledger package dirs allcabal%: for p in $(PACKAGES); do (echo doing cabal $* in $$p; cd $$p; cabal $*; echo); done