Merge pull request #10530 from 9999years/no-hide-successes
[cabal.git] / Makefile
blob5cf1cae4d6fdf2517663cb6d663fa9027af07ac8
1 .PHONY: phony
2 # Adding dependency "phony" is like declaring a target as ".PHONY":
3 # See https://www.gnu.org/software/make/manual/html_node/Force-Targets.html
5 CABALBUILD := cabal build
6 CABALRUN := cabal run
8 # We have to avoid allow-newer.
9 # SEE: https://github.com/haskell/cabal/issues/6859
10 DOCTEST := cabal doctest --allow-newer=False
12 # default rules
14 .PHONY: all
15 all : exe lib
17 .PHONY: lib
18 lib :
19 $(CABALBUILD) Cabal:libs
21 .PHONY: exe
22 exe :
23 $(CABALBUILD) cabal-install:exes
25 .PHONY: init
26 init: ## Set up git hooks and ignored revisions
27 @git config core.hooksPath .githooks
28 ## TODO
30 .PHONY: style
31 style: ## Run the code styler
32 @fourmolu -q -i Cabal Cabal-syntax cabal-install cabal-validate
34 .PHONY: style-modified
35 style-modified: ## Run the code styler on modified files
36 @git ls-files --modified Cabal Cabal-syntax cabal-install cabal-validate \
37 | grep '.hs$$' | xargs -P $(PROCS) -I {} fourmolu -q -i {}
39 .PHONY: style-commit
40 style-commit: ## Run the code styler on the previous commit
41 @git diff --name-only HEAD $(COMMIT) Cabal Cabal-syntax cabal-install cabal-validate \
42 | grep '.hs$$' | xargs -P $(PROCS) -I {} fourmolu -q -i {}
44 .PHONY: whitespace
45 whitespace: ## Run fix-whitespace in check mode
46 fix-whitespace --check --verbose
48 .PHONY: fix-whitespace
49 fix-whitespace: ## Run fix-whitespace in fix mode
50 fix-whitespace --verbose
52 # local checks
54 .PHONY: checks
55 checks: whitespace style
56 # this should probably be a rule
57 hlint -j --json -- .
59 # source generation: SPDX
61 SPDX_LICENSE_HS:=Cabal-syntax/src/Distribution/SPDX/LicenseId.hs
62 SPDX_EXCEPTION_HS:=Cabal-syntax/src/Distribution/SPDX/LicenseExceptionId.hs
64 # Note: the 'spdx' goal is used in .github/workflows/quick-jobs.yml.
65 # Any changes to this goal need to be reconciled with this workflow.
67 .PHONY: spdx
68 spdx : $(SPDX_LICENSE_HS) $(SPDX_EXCEPTION_HS)
70 SPDX_LICENSE_VERSIONS:=3.0 3.2 3.6 3.9 3.10 3.16 3.23 3.25
72 $(SPDX_LICENSE_HS) : templates/SPDX.LicenseId.template.hs cabal-dev-scripts/src/GenUtils.hs cabal-dev-scripts/src/GenSPDX.hs license-list-data/licenses-3.0.json license-list-data/licenses-3.2.json
73 cabal run --builddir=dist-newstyle-meta --project-file=cabal.meta.project gen-spdx -- templates/SPDX.LicenseId.template.hs $(SPDX_LICENSE_VERSIONS:%=license-list-data/licenses-%.json) $(SPDX_LICENSE_HS)
75 $(SPDX_EXCEPTION_HS) : templates/SPDX.LicenseExceptionId.template.hs cabal-dev-scripts/src/GenUtils.hs cabal-dev-scripts/src/GenSPDXExc.hs license-list-data/exceptions-3.0.json license-list-data/exceptions-3.2.json
76 cabal run --builddir=dist-newstyle-meta --project-file=cabal.meta.project gen-spdx-exc -- templates/SPDX.LicenseExceptionId.template.hs $(SPDX_LICENSE_VERSIONS:%=license-list-data/exceptions-%.json) $(SPDX_EXCEPTION_HS)
78 # source generation: templates
80 TEMPLATE_MACROS:=Cabal/src/Distribution/Simple/Build/Macros/Z.hs
81 TEMPLATE_PATHS:=Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs
83 # Note: the 'templates' goal is used in .github/workflows/quick-jobs.yml.
84 # Any changes to this goal need to be reconciled with this workflow.
86 .PHONY: templates
87 templates : $(TEMPLATE_MACROS) $(TEMPLATE_PATHS)
89 $(TEMPLATE_MACROS) : templates/cabal_macros.template.h cabal-dev-scripts/src/GenCabalMacros.hs
90 cabal run --builddir=dist-newstyle-meta --project-file=cabal.meta.project gen-cabal-macros -- $< $@
92 $(TEMPLATE_PATHS) : templates/Paths_pkg.template.hs cabal-dev-scripts/src/GenPathsModule.hs
93 cabal run --builddir=dist-newstyle-meta --project-file=cabal.meta.project gen-paths-module -- $< $@
95 # generated docs
96 # Use cabal build before cabal run to avoid output of the build on stdout when running
97 doc/buildinfo-fields-reference.rst : \
98 $(wildcard Cabal-syntax/src/*/*.hs Cabal-syntax/src/*/*/*.hs Cabal-syntax/src/*/*/*/*.hs) \
99 $(wildcard Cabal-described/src/Distribution/Described.hs Cabal-described/src/Distribution/Utils/*.hs) \
100 buildinfo-reference-generator/src/Main.hs \
101 buildinfo-reference-generator/template.zinza
102 cabal build buildinfo-reference-generator
103 cabal run buildinfo-reference-generator buildinfo-reference-generator/template.zinza | tee $@
104 git diff --exit-code $@
106 .PHONY: analyse-imports
107 analyse-imports :
108 find Cabal-syntax/src Cabal/src cabal-install/src -type f -name '*.hs' | xargs cabal run --builddir=dist-newstyle-meta --project-file=cabal.meta.project analyse-imports --
110 # ghcid
112 .PHONY: ghcid-lib
113 ghcid-lib :
114 ghcid -c 'cabal repl Cabal'
116 .PHONY: ghcid-cli
117 ghcid-cli :
118 ghcid -c 'cabal repl cabal-install'
120 .PHONY: doctest
121 doctest :
122 cd Cabal-syntax && $(DOCTEST)
123 cd Cabal-described && $(DOCTEST)
124 cd Cabal && $(DOCTEST)
125 cd cabal-install-solver && $(DOCTEST)
126 cd cabal-install && $(DOCTEST)
128 # This is not run as part of validate.sh (we need hackage-security, which is tricky to get).
129 .PHONY: doctest-cli
130 doctest-cli :
131 doctest -D__DOCTEST__ --fast cabal-install/src cabal-install-solver/src cabal-install-solver/src-assertion
133 .PHONY: doctest-install
134 doctest-install:
135 cabal install doctest --overwrite-policy=always --ignore-project --flag cabal-doctest
137 # tests
139 .PHONY: check-tests
140 check-tests :
141 $(CABALRUN) check-tests -- --cwd Cabal-tests ${TEST}
143 .PHONY: parser-tests
144 parser-tests :
145 $(CABALRUN) parser-tests -- --cwd Cabal-tests ${TEST}
147 .PHONY: parser-tests-accept
148 parser-tests-accept :
149 $(CABALRUN) parser-tests -- --cwd Cabal-tests --accept ${TEST}
151 .PHONY: custom-setup-tests
152 custom-setup-tests :
153 $(CABALRUN) custom-setup-tests --
155 .PHONY: hackage-parsec-tests
156 hackage-parsec-tests :
157 $(CABALRUN) hackage-tests -- parsec +RTS -s -qg -I0 -A64M -N${THREADS} -RTS ${TEST}
159 .PHONY: hackage-rountrip-tests
160 hackage-roundtrip-tests :
161 $(CABALRUN) hackage-tests -- roundtrip +RTS -s -qg -I0 -A64M -N${THREADS} -RTS ${TEST}
163 .PHONY: cabal-install-test
164 cabal-install-test:
165 $(CABALBUILD) -j3 cabal-tests cabal
166 rm -rf .ghc.environment.*
167 cd cabal-testsuite && `cabal list-bin cabal-tests` --with-cabal=`cabal list-bin cabal` --hide-successes -j3 ${TEST}
169 # hackage-benchmarks (solver)
171 .PHONY: hackage-benchmarks-run
172 hackage-benchmarks-run:
173 $(CABALBUILD) -j3 hackage-benchmark cabal
174 rm -rf .ghc.environment.*
175 $$(cabal list-bin hackage-benchmark) --cabal1=cabal --cabal2=$$(cabal list-bin cabal) --packages="hakyll servant-auth-server" --print-trials --concurrently
178 # This doesn't run build, as you first need to test with cabal-install-test :)
179 .PHONY: cabal-install-test-accept
180 cabal-install-test-accept:
181 rm -rf .ghc.environment.*
182 cd cabal-testsuite && `cabal list-bin cabal-tests` --with-cabal=`cabal list-bin cabal` --hide-successes -j3 --accept ${TEST}
184 # Docker validation
186 # Use this carefully, on big machine you can say
188 # make validate-via-docker-all -j4 -O
190 .PHONY: validate-via-docker-all
191 validate-via-docker-all : validate-via-docker-8.2.2
192 validate-via-docker-all : validate-via-docker-8.4.4
193 validate-via-docker-all : validate-via-docker-8.8.4
194 validate-via-docker-all : validate-via-docker-8.10.4
196 .PHONY: validate-dockerfiles
197 validate-dockerfiles : .docker/validate-8.10.4.dockerfile
198 validate-dockerfiles : .docker/validate-8.8.4.dockerfile
199 validate-dockerfiles : .docker/validate-8.4.4.dockerfile
200 validate-dockerfiles : .docker/validate-8.2.2.dockerfile
202 .docker/validate-%.dockerfile : .docker/validate.dockerfile.zinza cabal-dev-scripts/src/GenValidateDockerfile.hs
203 cabal run --builddir=dist-newstyle-meta --project-file=cabal.meta.project gen-validate-dockerfile -- $* $< $@
205 # This is good idea anyway
206 # and we have a test relying on this limit being sufficiently small
207 DOCKERARGS:=--ulimit nofile=1024:1024
209 .PHONY: validate-via-docker-8.2.2
210 validate-via-docker-8.2.2:
211 docker build $(DOCKERARGS) -t cabal-validate:8.2.2 -f .docker/validate-8.2.2.dockerfile .
213 .PHONY: validate-via-docker-8.4.4
214 validate-via-docker-8.4.4:
215 docker build $(DOCKERARGS) -t cabal-validate:8.4.4 -f .docker/validate-8.4.4.dockerfile .
217 .PHONY: validate-via-docker-8.8.4
218 validate-via-docker-8.8.4:
219 docker build $(DOCKERARGS) -t cabal-validate:8.8.4 -f .docker/validate-8.8.4.dockerfile .
221 .PHONY: validate-via-docker-8.10.4
222 validate-via-docker-8.10.4:
223 docker build $(DOCKERARGS) -t cabal-validate:8.10.4 -f .docker/validate-8.10.4.dockerfile .
225 .PHONY: validate-via-docker-old
226 validate-via-docker-old:
227 docker build $(DOCKERARGS) -t cabal-validate:older -f .docker/validate-old.dockerfile .
229 # tags
230 .PHONY : tags
231 tags :
232 hasktags -b Cabal-syntax/src Cabal/src Cabal-described/src cabal-install/src cabal-testsuite/src
234 # bootstrapping
235 ##############################################################################
237 bootstrap-json-%: phony
238 cabal build --project-file=cabal.bootstrap.project --with-compiler=ghc-$* --dry-run cabal-install:exe:cabal
239 cp dist-newstyle/cache/plan.json bootstrap/linux-$*.plan.json
240 @# -v0 to avoid build output on stdout
241 cd bootstrap && cabal run -v0 cabal-bootstrap-gen -- linux-$*.plan.json \
242 | python3 -m json.tool > linux-$*.json
244 BOOTSTRAP_GHC_VERSIONS := 9.0.2 9.2.8 9.4.8 9.6.6 9.8.2
246 .PHONY: bootstrap-jsons
247 bootstrap-jsons: $(BOOTSTRAP_GHC_VERSIONS:%=bootstrap-json-%)
249 # documentation
250 ##############################################################################
252 .PHONY: users-guide
253 users-guide:
254 $(MAKE) -C doc users-guide
256 .PHONY: users-guide-requirements
257 users-guide-requirements:
258 $(MAKE) -C doc users-guide-requirements
260 ifeq ($(shell uname), Darwin)
261 PROCS := $(shell sysctl -n hw.logicalcpu)
262 else
263 PROCS := $(shell nproc)
264 endif