Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pattern errors in windows #93

Merged
merged 6 commits into from
Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions cabal-helper.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down
17 changes: 12 additions & 5 deletions src/CabalHelper/Compiletime/CompPrograms.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module CabalHelper.Compiletime.CompPrograms where

import Control.Monad (when)
import Data.List
import Data.Maybe
import System.Directory
Expand Down Expand Up @@ -80,9 +81,12 @@ 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
when (ghcProgram progs /= "ghc") $
createProgSymlink bindir $ ghcProgram progs
when (ghcPkgProgram progs /= "ghc-pkg") $
createProgSymlink bindir $ ghcPkgProgram progs
when (haddockProgram progs /= "haddock") $
createProgSymlink bindir $ haddockProgram progs
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this isn't going to work either. IIRC Stack will search for the ghc related tools in the directory it found ghc.

So if ghc is unqualified here but the other tools aren't we create the symlink farm but stack will search for ghc, find it on PATH, say in /usr/bin or something and pick up ghc-pkg and haddock from there too instead of the ones the user specified.

Also you're not handling the case where the tools are unqualified but have a version postfix.

return $ progs
{ stackEnv =
[("PATH", EnvPrepend $ bindir ++ [searchPathSeparator])] ++
Expand All @@ -92,8 +96,11 @@ patchBuildToolProgs SStack progs = do
createProgSymlink :: FilePath -> FilePath -> IO ()
createProgSymlink 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 -> error $ "Error trying to create symlink to " ++ target ++ ": "
++ exe ++ " executable not found."
| otherwise = do
cwd <- getCurrentDirectory
createSymbolicLink (cwd </> target) (bindir </> takeFileName target)
2 changes: 1 addition & 1 deletion src/CabalHelper/Compiletime/Program/Stack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down