This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
60 lines (46 loc) · 2.05 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# This really ought to be `/usr/bin/env bash`, but nix flakes don't like that.
SHELL := /bin/sh
.PHONY: hoogle format haddock usage tag format_nix format_haskell format_check lint ps_bridge bench bench_check scripts
TARGETS := src
usage:
@echo "usage: make <command> [OPTIONS]"
@echo
@echo "Available commands:"
@echo " hoogle -- Start local hoogle"
@echo " format -- Format the project"
@echo " haddock -- Generate Haddock docs for project"
@echo " tag -- Generate CTAGS and ETAGS files for project"
@echo " format_haskell -- Format haskell stuff, including source code and cabal files"
@echo " format_nix -- Format *.nix files only"
@echo " format_check -- Check if all haskell stuff have been formatted correctly"
@echo " lint -- Get hlint suggestions for project"
@echo " ci -- Run all the CI checks"
hoogle:
pkill hoogle || true
hoogle generate --local=haddock --database=hoo/local.hoo
hoogle server --local -p 8081 >> /dev/null &
hoogle server --local --database=hoo/local.hoo -p 8082 >> /dev/null &
format: format_haskell format_cabal format_nix
format_nix:
git ls-tree -r HEAD --full-tree --name-only | grep -E '.*\.nix' | xargs nixpkgs-fmt
format_cabal:
cabal-fmt -i $(CABAL_SOURCES)
CABAL_SOURCES := $(shell fd -ecabal)
FORMAT_EXTENSIONS := -o -XQuasiQuotes -o -XTemplateHaskell -o -XTypeApplications -o -XImportQualifiedPost -o -XPatternSynonyms -o -XOverloadedRecordDot
format_haskell:
find -name '*.hs' -not -path './dist-*/*' | xargs fourmolu $(FORMAT_EXTENSIONS) -m inplace
git ls-tree -r HEAD --full-tree --name-only | grep -E '.*\.cabal' | xargs cabal-fmt -i
format_check:
find -name '*.hs' \
-not -path './dist*/*' \
-not -path './haddock/*' \
| xargs fourmolu $(FORMAT_EXTENSIONS) -m check
haddock:
cabal haddock --haddock-html --haddock-hoogle --builddir=haddock
tag:
hasktags -x $(TARGETS)
lint:
hlint $(TARGETS)
ci:
@ [[ "$$(uname -sm)" == "Linux x86_64" ]] || (echo "NOTE: CI only builds on Linux x86_64. Your system is $$(uname -sm), continuing...")
nix build .#check.$(shell nix eval -f '<nixpkgs>' system)