1 .PHONY
: all lexer sdpx lib exe doctest
4 CABALBUILD
:= cabal build
12 $(CABALBUILD
) Cabal
:libs
15 $(CABALBUILD
) cabal-install
:exes
17 init
: ## Set up git hooks and ignored revisions
18 @git config core.hooksPath .githooks
21 style
: ## Run the code styler
22 @fourmolu
-q
-i Cabal Cabal-syntax cabal-install
24 style-modified
: ## Run the code styler on modified files
25 @git ls-files
--modified Cabal Cabal-syntax cabal-install \
26 | grep
'.hs$$' | xargs
-P
$(PROCS
) -I
{} fourmolu
-q
-i
{}
28 # source generation: Lexer
30 LEXER_HS
:=Cabal-syntax
/src
/Distribution
/Fields
/Lexer.hs
34 $(LEXER_HS
) : templates
/Lexer.x
35 alex
--latin1
--ghc
-o
$@
$^
37 echo
'{- FOURMOLU_DISABLE -}' >> Lexer.tmp
38 cat
-s
$@
>> Lexer.tmp
41 # source generation: SPDX
43 SPDX_LICENSE_HS
:=Cabal-syntax
/src
/Distribution
/SPDX
/LicenseId.hs
44 SPDX_EXCEPTION_HS
:=Cabal-syntax
/src
/Distribution
/SPDX
/LicenseExceptionId.hs
46 spdx
: $(SPDX_LICENSE_HS
) $(SPDX_EXCEPTION_HS
)
48 SPDX_LICENSE_VERSIONS
:=3.0 3.2 3.6 3.9 3.10 3.16
50 $(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
51 cabal run
--builddir
=dist-newstyle-meta
--project-file
=cabal.project.meta gen-spdx
-- templates
/SPDX.LicenseId.template.hs
$(SPDX_LICENSE_VERSIONS
:%=license-list-data
/licenses-
%.json
) $(SPDX_LICENSE_HS
)
53 $(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
54 cabal run
--builddir
=dist-newstyle-meta
--project-file
=cabal.project.meta gen-spdx-exc
-- templates
/SPDX.LicenseExceptionId.template.hs
$(SPDX_LICENSE_VERSIONS
:%=license-list-data
/exceptions-
%.json
) $(SPDX_EXCEPTION_HS
)
56 # source generation: templates
58 TEMPLATE_MACROS
:=Cabal
/src
/Distribution
/Simple
/Build
/Macros
/Z.hs
59 TEMPLATE_PATHS
:=Cabal
/src
/Distribution
/Simple
/Build
/PathsModule
/Z.hs
61 templates
: phony
$(TEMPLATE_MACROS
) $(TEMPLATE_PATHS
)
63 $(TEMPLATE_MACROS
) : templates
/cabal_macros.template.h cabal-dev-scripts
/src
/GenCabalMacros.hs
64 cabal run
--builddir
=dist-newstyle-meta
--project-file
=cabal.project.meta gen-cabal-macros
-- $< $@
66 $(TEMPLATE_PATHS
) : templates
/Paths_pkg.template.hs cabal-dev-scripts
/src
/GenPathsModule.hs
67 cabal run
--builddir
=dist-newstyle-meta
--project-file
=cabal.project.meta gen-paths-module
-- $< $@
71 buildinfo-fields-reference
: phony
72 cabal build
--builddir
=dist-newstyle-bi
--project-file
=cabal.project.buildinfo buildinfo-reference-generator
73 $$(cabal list-bin
--builddir
=dist-newstyle-bi buildinfo-reference-generator
) buildinfo-reference-generator
/template.zinza | tee
$@
76 analyse-imports
: phony
77 find Cabal-syntax
/src Cabal
/src cabal-install
/src
-type f
-name
'*.hs' | xargs cabal run
--builddir
=dist-newstyle-meta
--project-file
=cabal.project.meta analyse-imports
--
82 ghcid
-c
'cabal repl Cabal'
85 ghcid
-c
'cabal repl cabal-install'
87 # Artem, 2023-02-03, https://github.com/haskell/cabal/issues/8504
88 # The new and prefered way to call the doctest tool (as of now) is based on cabal repl --with-ghc=doctest.
89 # The call below reflects the current documentation of the doctest tool except one caveat,
90 # which is https://github.com/haskell/cabal/issues/6859, i.e. we have to hide allow-newer in our project
91 # file from cabal/doctest. This is easy: we just select a project file with no allow-newer (e.g. cabal.project.libonly).
93 # TODO: Cabal-described should be added here but its doctests currently broken, see:
94 # https://github.com/haskell/cabal/issues/8734
95 # Just as well, cabal-install(-solver) doctests (the target below) bitrotted and need some care.
97 cabal repl
--with-ghc
=doctest
--build-depends
=QuickCheck
--build-depends
=template-haskell
--repl-options
="-w" --project-file
="cabal.project.validate" Cabal-syntax
98 cabal repl
--with-ghc
=doctest
--build-depends
=QuickCheck
--build-depends
=template-haskell
--repl-options
="-w" --project-file
="cabal.project.validate" Cabal
101 # This is not run as part of validate.sh (we need hackage-security, which is tricky to get).
103 doctest
-D__DOCTEST__
--fast cabal-install
/src cabal-install-solver
/src cabal-install-solver
/src-assertion
106 cabal
install doctest
--overwrite-policy
=always
--ignore-project
111 $(CABALRUN
) check-tests
-- --cwd Cabal-tests
${TEST}
114 $(CABALRUN
) parser-tests
-- --cwd Cabal-tests
${TEST}
116 parser-tests-accept
:
117 $(CABALRUN
) parser-tests
-- --cwd Cabal-tests
--accept
${TEST}
120 $(CABALRUN
) custom-setup-tests
--
122 hackage-parsec-tests
:
123 $(CABALRUN
) hackage-tests
-- parsec
+RTS
-s
-qg
-I0
-A64M
-N
${THREADS} -RTS
${TEST}
125 hackage-roundtrip-tests
:
126 $(CABALRUN
) hackage-tests
-- roundtrip
+RTS
-s
-qg
-I0
-A64M
-N
${THREADS} -RTS
${TEST}
129 $(CABALBUILD
) -j3 cabal-tests cabal
130 rm -rf .ghc.environment.
*
131 cd cabal-testsuite
&& `cabal list-bin cabal-tests` --with-cabal
=`cabal list-bin cabal` --hide-successes
-j3
${TEST}
133 # hackage-benchmarks (solver)
135 hackage-benchmarks-run
:
136 $(CABALBUILD
) -j3 hackage-benchmark cabal
137 rm -rf .ghc.environment.
*
138 $$(cabal list-bin hackage-benchmark
) --cabal1
=cabal
--cabal2
=$$(cabal list-bin cabal
) --packages
="hakyll servant-auth-server" --print-trials
--concurrently
141 # This doesn't run build, as you first need to test with cabal-install-test :)
142 cabal-install-test-accept
:
143 rm -rf .ghc.environment.
*
144 cd cabal-testsuite
&& `cabal list-bin cabal-tests` --with-cabal
=`cabal list-bin cabal` --hide-successes
-j3
--accept
${TEST}
148 # Use this carefully, on big machine you can say
150 # make validate-via-docker-all -j4 -O
152 validate-via-docker-all
: validate-via-docker-8.2
.2
153 validate-via-docker-all
: validate-via-docker-8.4
.4
154 validate-via-docker-all
: validate-via-docker-8.6
.5
155 validate-via-docker-all
: validate-via-docker-8.8
.4
156 validate-via-docker-all
: validate-via-docker-8.10
.4
158 validate-dockerfiles
: .docker
/validate-8.10
.4.dockerfile
159 validate-dockerfiles
: .docker
/validate-8.8
.4.dockerfile
160 validate-dockerfiles
: .docker
/validate-8.6
.5.dockerfile
161 validate-dockerfiles
: .docker
/validate-8.4
.4.dockerfile
162 validate-dockerfiles
: .docker
/validate-8.2
.2.dockerfile
164 .docker
/validate-
%.dockerfile
: .docker
/validate.dockerfile.zinza cabal-dev-scripts
/src
/GenValidateDockerfile.hs
165 cabal run
--builddir
=dist-newstyle-meta
--project-file
=cabal.project.meta gen-validate-dockerfile
-- $* $< $@
167 # This is good idea anyway
168 # and we have a test relying on this limit being sufficiently small
169 DOCKERARGS
:=--ulimit nofile
=1024:1024
171 validate-via-docker-8.2
.2:
172 docker build
$(DOCKERARGS
) -t cabal-validate
:8.2.2 -f .docker
/validate-8.2
.2.dockerfile .
174 validate-via-docker-8.4
.4:
175 docker build
$(DOCKERARGS
) -t cabal-validate
:8.4.4 -f .docker
/validate-8.4
.4.dockerfile .
177 validate-via-docker-8.6
.5:
178 docker build
$(DOCKERARGS
) -t cabal-validate
:8.6.5 -f .docker
/validate-8.6
.5.dockerfile .
180 validate-via-docker-8.8
.4:
181 docker build
$(DOCKERARGS
) -t cabal-validate
:8.8.4 -f .docker
/validate-8.8
.4.dockerfile .
183 validate-via-docker-8.10
.4:
184 docker build
$(DOCKERARGS
) -t cabal-validate
:8.10.4 -f .docker
/validate-8.10
.4.dockerfile .
186 validate-via-docker-old
:
187 docker build
$(DOCKERARGS
) -t cabal-validate
:older
-f .docker
/validate-old.dockerfile .
191 cabal build
all --project-file
=cabal.project.weeder
197 hasktags
-b Cabal-syntax
/src Cabal
/src Cabal-described
/src cabal-install
/src cabal-testsuite
/src
200 ##############################################################################
202 bootstrap-json-
%: phony
203 cabal build
--project
=cabal.project.release
--with-compiler
=ghc-
$* --dry-run cabal-install
:exe
:cabal
204 cp dist-newstyle
/cache
/plan.json bootstrap
/linux-
$*.plan.json
205 @
# -v0 to avoid build output on stdout
206 cd bootstrap
&& cabal run
-v0 cabal-bootstrap-gen
-- linux-
$*.plan.json \
207 | python3
-m json.tool
> linux-
$*.json
209 BOOTSTRAP_GHC_VERSIONS
:= 8.10.7 9.0.2 9.2.7 9.4.4
211 bootstrap-jsons
: $(BOOTSTRAP_GHC_VERSIONS
:%=bootstrap-json-
%)
214 ##############################################################################
216 # TODO: when we have sphinx-build2 ?
217 SPHINXCMD
:=sphinx-build
218 # Flag -n ("nitpick") warns about broken references
219 # Flag -W turns warnings into errors
220 # Flag --keep-going continues after errors
221 SPHINX_FLAGS
:=-n
-W
--keep-going
-E
222 SPHINX_HTML_OUTDIR
:=dist-newstyle
/doc
/users-guide
223 USERGUIDE_STAMP
:=$(SPHINX_HTML_OUTDIR
)/index.html
225 # do pip install every time so we have up to date requirements when we build
226 users-guide
: .python-sphinx-virtualenv
$(USERGUIDE_STAMP
)
227 $(USERGUIDE_STAMP
) : doc
/*.rst
228 mkdir
-p
$(SPHINX_HTML_OUTDIR
)
229 (. .
/.python-sphinx-virtualenv
/bin
/activate
&& pip
install -r doc
/requirements.txt
&& $(SPHINXCMD
) $(SPHINX_FLAGS
) doc
$(SPHINX_HTML_OUTDIR
))
231 .python-sphinx-virtualenv
:
232 python3
-m venv .python-sphinx-virtualenv
233 (. .
/.python-sphinx-virtualenv
/bin
/activate
)
235 # This goal is intended for manual invocation, always rebuilds.
236 .PHONY
: users-guide-requirements
237 users-guide-requirements
: doc
/requirements.txt
239 .PHONY
: doc
/requirements.txt
240 doc
/requirements.txt
: .python-sphinx-virtualenv
241 . .python-sphinx-virtualenv
/bin
/activate \
242 && make
-C doc build-and-check-requirements
244 ifeq ($(shell uname
), Darwin
)
245 PROCS
:= $(shell sysctl
-n hw.logicalcpu
)
247 PROCS
:= $(shell nproc
)