makefiel cleanups, new targets: ghci, haddocktest, doctest, unittest, view-api-docs
This commit is contained in:
		
							parent
							
								
									a8ce8a55ce
								
							
						
					
					
						commit
						abf86f31fa
					
				
							
								
								
									
										88
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										88
									
								
								Makefile
									
									
									
									
									
								
							@ -29,10 +29,25 @@ continuous ci: setversion
 | 
				
			|||||||
# force a full rebuild with normal optimisation
 | 
					# force a full rebuild with normal optimisation
 | 
				
			||||||
rebuild: clean build
 | 
					rebuild: clean build
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# run tests without compiling, might be handy now and then
 | 
					# debug prompt
 | 
				
			||||||
test:
 | 
					ghci:
 | 
				
			||||||
 | 
						ghci hledger.hs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# run all tests
 | 
				
			||||||
 | 
					test: doctest unittest haddocktest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# make sure we have no haddock errors
 | 
				
			||||||
 | 
					haddocktest:
 | 
				
			||||||
 | 
						@make --quiet haddock
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# run unit tests, without waiting for compilation
 | 
				
			||||||
 | 
					unittest:
 | 
				
			||||||
	./hledger.hs test
 | 
						./hledger.hs test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# run doc tests
 | 
				
			||||||
 | 
					doctest:
 | 
				
			||||||
 | 
						tools/doctest.hs Tests.hs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# build profiling-enabled hledgerp and archive and show a cleaned-up profile
 | 
					# build profiling-enabled hledgerp and archive and show a cleaned-up profile
 | 
				
			||||||
# you may need to rebuild some libs: sudo cabal install --reinstall -p ...
 | 
					# you may need to rebuild some libs: sudo cabal install --reinstall -p ...
 | 
				
			||||||
PROFBIN=hledgerp
 | 
					PROFBIN=hledgerp
 | 
				
			||||||
@ -40,7 +55,7 @@ BUILDPROF=ghc $(BUILDFLAGS) --make hledger.hs -prof -auto-all -o $(PROFBIN)
 | 
				
			|||||||
RUNPROF=./$(PROFBIN) +RTS -p -RTS
 | 
					RUNPROF=./$(PROFBIN) +RTS -p -RTS
 | 
				
			||||||
PROFCMD=-f sample1000.ledger -s balance
 | 
					PROFCMD=-f sample1000.ledger -s balance
 | 
				
			||||||
TIME=`date +"%Y%m%d%H%M"`
 | 
					TIME=`date +"%Y%m%d%H%M"`
 | 
				
			||||||
profile: sampleledgers
 | 
					buildprof prof: sampleledgers
 | 
				
			||||||
	@echo "Profiling $(PROFCMD)"
 | 
						@echo "Profiling $(PROFCMD)"
 | 
				
			||||||
	$(BUILDPROF)
 | 
						$(BUILDPROF)
 | 
				
			||||||
	$(RUNPROF) $(PROFCMD) #>/dev/null
 | 
						$(RUNPROF) $(PROFCMD) #>/dev/null
 | 
				
			||||||
@ -180,7 +195,7 @@ Clean: clean clean-docs
 | 
				
			|||||||
DOCS=README NEWS
 | 
					DOCS=README NEWS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# rebuild all docs
 | 
					# rebuild all docs
 | 
				
			||||||
docs: html pdf api-doc-frames
 | 
					docs: html pdf api-docs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# rebuild html docs
 | 
					# rebuild html docs
 | 
				
			||||||
html:
 | 
					html:
 | 
				
			||||||
@ -191,14 +206,34 @@ html:
 | 
				
			|||||||
pdf:
 | 
					pdf:
 | 
				
			||||||
	for d in $(DOCS); do rst2pdf $$d -o doc/$$d.pdf; done
 | 
						for d in $(DOCS); do rst2pdf $$d -o doc/$$d.pdf; done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# rebuild api docs (haddock & hoogle) 
 | 
					# rebuild api docs
 | 
				
			||||||
api-docs: api-doc-frames
 | 
					# We munge haddock and hoogle into a rough but useful framed layout.
 | 
				
			||||||
 | 
					# For this to work the hoogle cgi must be built with base target "main".
 | 
				
			||||||
 | 
					api-docs: haddock hoogleweb
 | 
				
			||||||
 | 
						echo "Converting api docs to frames" ; \
 | 
				
			||||||
 | 
						sed -i -e 's%^></HEAD%><base target="main"></HEAD%' api-doc/modules-index.html ; \
 | 
				
			||||||
 | 
						cp doc/misc/api-doc-frames.html api-doc/index.html ; \
 | 
				
			||||||
 | 
						cp doc/misc/hoogle-small.html hoogle
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# build and preview the api docs
 | 
				
			||||||
 | 
					BROWSER=open
 | 
				
			||||||
 | 
					view-api-docs: api-docs
 | 
				
			||||||
 | 
						$(BROWSER) api-doc/index.html
 | 
				
			||||||
 | 
					
 | 
				
			||||||
api-doc-dir:
 | 
					api-doc-dir:
 | 
				
			||||||
	mkdir -p api-doc
 | 
						mkdir -p api-doc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					MAIN=hledger.hs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# --ignore-all-exports here means these are actually implementation docs
 | 
				
			||||||
 | 
					HADDOCK=haddock -B `ghc --print-libdir` --no-warnings --ignore-all-exports $(subst -D,--optghc=-D,$(BUILDFLAGS))
 | 
				
			||||||
 | 
					haddock: api-doc-dir hscolour $(MAIN)
 | 
				
			||||||
 | 
						echo "Generating haddock api docs with source" ; \
 | 
				
			||||||
 | 
						$(HADDOCK) -o api-doc -h --source-module=src-%{MODULE/./-}.html --source-entity=src-%{MODULE/./-}.html#%N $(filter-out %api-doc-dir hscolour,$^) && \
 | 
				
			||||||
 | 
							cp api-doc/index.html api-doc/modules-index.html
 | 
				
			||||||
 | 
					
 | 
				
			||||||
HSCOLOUR=HsColour -css 
 | 
					HSCOLOUR=HsColour -css 
 | 
				
			||||||
colourised-source hscolour: api-doc-dir
 | 
					hscolour: api-doc-dir
 | 
				
			||||||
	echo "Generating colourised source" ; \
 | 
						echo "Generating colourised source" ; \
 | 
				
			||||||
	for f in *hs Ledger/*hs; do \
 | 
						for f in *hs Ledger/*hs; do \
 | 
				
			||||||
		$(HSCOLOUR) -anchor $$f -oapi-doc/`echo "src/"$$f | sed -e's%/%-%g' | sed -e's%\.hs$$%.html%'` ; \
 | 
							$(HSCOLOUR) -anchor $$f -oapi-doc/`echo "src/"$$f | sed -e's%/%-%g' | sed -e's%\.hs$$%.html%'` ; \
 | 
				
			||||||
@ -206,25 +241,6 @@ colourised-source hscolour: api-doc-dir
 | 
				
			|||||||
	cp api-doc/src-hledger.html api-doc/src-Main.html ; \
 | 
						cp api-doc/src-hledger.html api-doc/src-Main.html ; \
 | 
				
			||||||
	HsColour -print-css >api-doc/hscolour.css
 | 
						HsColour -print-css >api-doc/hscolour.css
 | 
				
			||||||
 | 
					
 | 
				
			||||||
MAIN=hledger.hs
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# nb --ignore-all-exports means these are actually implementation docs
 | 
					 | 
				
			||||||
HADDOCK=haddock -B `ghc --print-libdir` --no-warnings --ignore-all-exports $(subst -D,--optghc=-D,$(BUILDFLAGS))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
api-doc-with-source: api-doc-dir colourised-source $(MAIN)
 | 
					 | 
				
			||||||
	echo "Generating haddock api docs" ; \
 | 
					 | 
				
			||||||
	$(HADDOCK) -o api-doc -h --source-module=src-%{MODULE/./-}.html $(filter-out %api-doc-dir colourised-source,$^) ; \
 | 
					 | 
				
			||||||
	cp api-doc/index.html api-doc/modules-index.html
 | 
					 | 
				
			||||||
#--source-entity=src-%{MODULE/./-}.html#%N 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#generate a hoogle index
 | 
					 | 
				
			||||||
hoogleindex: $(MAIN)
 | 
					 | 
				
			||||||
	echo "Generating hoogle index" ; \
 | 
					 | 
				
			||||||
	mkdir -p hoogle && \
 | 
					 | 
				
			||||||
	$(HADDOCK) -o hoogle --hoogle $^ && \
 | 
					 | 
				
			||||||
	cd hoogle && \
 | 
					 | 
				
			||||||
	hoogle --convert=main.txt --output=default.hoo
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#set up the hoogle web interface
 | 
					#set up the hoogle web interface
 | 
				
			||||||
#uses a hoogle source tree configured with --datadir=., patched to fix haddock urls/target frame
 | 
					#uses a hoogle source tree configured with --datadir=., patched to fix haddock urls/target frame
 | 
				
			||||||
HOOGLESRC=/usr/local/src/hoogle
 | 
					HOOGLESRC=/usr/local/src/hoogle
 | 
				
			||||||
@ -244,19 +260,13 @@ hoogleweb: hoogleindex
 | 
				
			|||||||
		echo "Could not find $(HOOGLE) in the hoogle source tree" ; \
 | 
							echo "Could not find $(HOOGLE) in the hoogle source tree" ; \
 | 
				
			||||||
	fi
 | 
						fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# munge haddock and hoogle into a rough but useful framed layout
 | 
					#generate a hoogle index
 | 
				
			||||||
# ensure that the hoogle cgi is built with base target "main"
 | 
					hoogleindex: $(MAIN)
 | 
				
			||||||
api-doc-frames: api-doc-with-source hoogleweb
 | 
						echo "Generating hoogle index" ; \
 | 
				
			||||||
	echo "Converting api docs to frames" ; \
 | 
						mkdir -p hoogle && \
 | 
				
			||||||
	sed -i -e 's%^></HEAD%><base target="main"></HEAD%' api-doc/modules-index.html ; \
 | 
						$(HADDOCK) -o hoogle --hoogle $^ && \
 | 
				
			||||||
	cp doc/misc/api-doc-frames.html api-doc/index.html ; \
 | 
						cd hoogle && \
 | 
				
			||||||
	cp doc/misc/hoogle-small.html hoogle
 | 
						hoogle --convert=main.txt --output=default.hoo
 | 
				
			||||||
 | 
					 | 
				
			||||||
# build api docs and open them in a web browser, adjust to taste
 | 
					 | 
				
			||||||
BROWSER=open
 | 
					 | 
				
			||||||
test-docs: api-docs
 | 
					 | 
				
			||||||
	$(BROWSER) api-doc/index.html
 | 
					 | 
				
			||||||
#	$(BROWSER) doc/README.html
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
clean-docs:
 | 
					clean-docs:
 | 
				
			||||||
	rm -rf api-doc hoogle
 | 
						rm -rf api-doc hoogle
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user