aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier Neira <atreyu.bbb@gmail.com>2020-02-10 13:25:49 +0100
committerGitHub <noreply@github.com>2020-02-10 13:25:49 +0100
commit4ca6570ecda0a39fc056c239ada6c2368b4dd698 (patch)
tree3d662edbabea7ea2a6ac57e3e5ac623388827547
parentc677e7239c95268175d1ad155c2d40b82eb9887a (diff)
Fix patchBuildToolProgs when haddock cannot be found
Cabal's GHC.configure doesn't demand haddock exist, so we have to handle the case where it's not installed.
-rw-r--r--cabal-helper.cabal12
-rw-r--r--src/CabalHelper/Compiletime/CompPrograms.hs19
-rw-r--r--src/CabalHelper/Compiletime/Program/Stack.hs2
3 files changed, 19 insertions, 14 deletions
diff --git a/cabal-helper.cabal b/cabal-helper.cabal
index 2d735ba..ff2b1b7 100644
--- a/cabal-helper.cabal
+++ b/cabal-helper.cabal
@@ -110,7 +110,7 @@ common build-deps
build-depends: unix-compat < 0.6 && >= 0.4.3.1
if flag(dev)
- ghc-options: -Wall
+ ghc-options: -Wall -fwarn-incomplete-uni-patterns
common c-h-internal
@@ -174,14 +174,14 @@ test-suite compile-test
main-is: CompileTest.hs
other-modules: TestOptions
hs-source-dirs: tests
- ghc-options: -Wall
+ ghc-options: -Wall -fwarn-incomplete-uni-patterns
test-suite programs-test
import: build-deps, extensions, c-h-internal
type: exitcode-stdio-1.0
main-is: ProgramsTest.hs
hs-source-dirs: tests
- ghc-options: -Wall
+ ghc-options: -Wall -fwarn-incomplete-uni-patterns
build-depends: pretty-show
test-suite ghc-session
@@ -190,7 +190,7 @@ test-suite ghc-session
main-is: GhcSession.hs
other-modules: TestOptions
hs-source-dirs: tests
- ghc-options: -Wall
+ ghc-options: -Wall -fwarn-incomplete-uni-patterns
build-depends: ghc < 8.9 && >= 8.0.2
, pretty-show < 1.9 && >= 1.8.1
@@ -199,7 +199,7 @@ test-suite examples
type: exitcode-stdio-1.0
main-is: Examples.hs
hs-source-dirs: tests
- ghc-options: -Wall
+ ghc-options: -Wall -fwarn-incomplete-uni-patterns
executable cabal-helper-main
default-language: Haskell2010
@@ -220,7 +220,7 @@ executable cabal-helper-main
else
buildable: False
- ghc-options: -Wall -fno-warn-unused-imports
+ ghc-options: -Wall -fno-warn-unused-imports -fwarn-incomplete-uni-patterns
build-depends: base < 5 && >= 4.9.1.0
, Cabal
, containers
diff --git a/src/CabalHelper/Compiletime/CompPrograms.hs b/src/CabalHelper/Compiletime/CompPrograms.hs
index 020bab4..24bc50f 100644
--- a/src/CabalHelper/Compiletime/CompPrograms.hs
+++ b/src/CabalHelper/Compiletime/CompPrograms.hs
@@ -2,6 +2,7 @@
module CabalHelper.Compiletime.CompPrograms where
+import Control.Monad (when)
import Data.List
import Data.Maybe
import System.Directory
@@ -10,6 +11,7 @@ import System.IO.Temp
import CabalHelper.Compiletime.Types
import CabalHelper.Compiletime.Cabal (getCabalVerbosity)
+import CabalHelper.Shared.Common (panicIO)
import Symlink (createSymbolicLink)
import Distribution.Simple.GHC as GHC (configure)
@@ -80,20 +82,23 @@ patchBuildToolProgs SStack progs = do
-- being able to pass executable paths straight through to stack but
-- currently there is no option to let us do that.
withSystemTempDirectory "cabal-helper-symlinks" $ \bindir -> do
- createProgSymlink bindir $ ghcProgram progs
- createProgSymlink bindir $ ghcPkgProgram progs
- createProgSymlink bindir $ haddockProgram progs
+ createProgSymlink True bindir $ ghcProgram progs
+ createProgSymlink True bindir $ ghcPkgProgram progs
+ createProgSymlink False bindir $ haddockProgram progs
return $ progs
{ stackEnv =
[("PATH", EnvPrepend $ bindir ++ [searchPathSeparator])] ++
stackEnv progs
}
-createProgSymlink :: FilePath -> FilePath -> IO ()
-createProgSymlink bindir target
+createProgSymlink :: Bool -> FilePath -> FilePath -> IO ()
+createProgSymlink required bindir target
| [exe] <- splitPath target = do
- Just exe_path <- findExecutable exe
- createSymbolicLink exe_path (bindir </> takeFileName target)
+ mb_exe_path <- findExecutable exe
+ case mb_exe_path of
+ Just exe_path -> createSymbolicLink exe_path (bindir </> takeFileName target)
+ Nothing -> when required $ panicIO $ "Error trying to create symlink to '" ++ target ++ "': "
+ ++ "'" ++ exe ++ "'" ++ " executable not found."
| otherwise = do
cwd <- getCurrentDirectory
createSymbolicLink (cwd </> target) (bindir </> takeFileName target)
diff --git a/src/CabalHelper/Compiletime/Program/Stack.hs b/src/CabalHelper/Compiletime/Program/Stack.hs
index d057d65..dc0b0e5 100644
--- a/src/CabalHelper/Compiletime/Program/Stack.hs
+++ b/src/CabalHelper/Compiletime/Program/Stack.hs
@@ -85,7 +85,7 @@ paths qe@QueryEnv{qeProjLoc=ProjLocStackYaml stack_yaml} cwd
workdirArg qe ++ [ "path", "--stack-yaml="++stack_yaml ]
return $ \k -> let Just x = lookup k $ map split $ lines out in x
where
- split l = let (key, ' ' : val) = span (not . isSpace) l in (key, val)
+ split l = let (key, val) = break isSpace l in (key, dropWhile isSpace val)
listPackageCabalFiles :: QueryEnvI c 'Stack -> IO [CabalFile]
listPackageCabalFiles qe@QueryEnv{qeProjLoc}