Hadrian: simple targets for building libraries and executables
[ghc.git] / hadrian / build.cabal.bat
1 @echo off
2 set CABAL=cabal
3 set CABFLAGS=--disable-documentation --disable-profiling
4
5 rem It is currently more robust to pass Cabal an absolute path to the project file.
6 set PROJ="%CD%/hadrian/cabal.project"
7
8 if not exist %PROJ% (
9 echo Current working directory must be GHC's top-level folder
10 exit /B 2
11 )
12
13 "%CABAL%" 2> NUL
14 if not %ERRORLEVEL% equ 1 (
15 echo Please make sure 'cabal' is in your PATH
16 exit /B 2
17 )
18
19 for /F "tokens=*" %%a in ('%CABAL% --numeric-version') do set CABVERSTR=%%a
20 for /F "delims=. tokens=1,2,3,4" %%a in ("%CABVERSTR%") do (
21 set CABMAJOR=%%a
22 set CABMINOR=%%b
23 set CABREV=%%c
24 set CABPATCH=%%d
25 )
26
27 set "_cabal_ok=0"
28 if %CABMAJOR% gtr 2 set _cabal_ok=1
29 if %CABMAJOR% equ 2 (
30 if %CABMINOR% geq 2 set _cabal_ok=1
31 )
32 if %_cabal_ok% equ 1 (
33 "%CABAL%" --project-file=%PROJ% new-build %CABFLAGS% -j exe:hadrian
34 "%CABAL%" --project-file=%PROJ% new-run %CABFLAGS% exe:hadrian -- ^
35 --lint ^
36 --directory "%CD%" ^
37 %*
38 ) else (
39 echo Cabal version is too old; you need at least cabal-install 2.2
40 exit /B 2
41 )