diff options
-rw-r--r-- | CabalHelper/Compile.hs | 8 | ||||
-rw-r--r-- | CabalHelper/Main.hs | 27 | ||||
-rw-r--r-- | CabalHelper/Types.hs | 2 | ||||
-rw-r--r-- | tests/Spec.hs | 2 |
4 files changed, 29 insertions, 10 deletions
diff --git a/CabalHelper/Compile.hs b/CabalHelper/Compile.hs index f84b2e8..2d9628c 100644 --- a/CabalHelper/Compile.hs +++ b/CabalHelper/Compile.hs @@ -167,9 +167,9 @@ compile distdir opts@Options {..} Compile {..} = do vLog opts $ "outdir: " ++ outdir vLog opts $ "exedir: " ++ exedir - let (mj, mi) = case compCabalVersion of - Left _commitid -> (1, 10000) - Right (Version (x:y:_) _) -> (x, y) + let (mj:mi:_) = case compCabalVersion of + Left _commitid -> [1, 10000] + Right (Version vs _) -> vs let ghc_opts = concat [ [ "-outputdir", outdir @@ -370,7 +370,7 @@ unpackCabalHEAD tmpdir = do let dir = tmpdir </> "cabal-head.git" url = "https://github.com/haskell/cabal.git" ExitSuccess <- rawSystem "git" [ "clone", "--depth=1", url, dir] - commit <- trim <$> readProcess "git" ["rev-parse", "HEAD"] "" + commit <- trim <$> readProcess "git" ["-C", dir, "rev-parse", "HEAD"] "" return (dir </> "Cabal", commit) errorInstallCabal :: Version -> FilePath -> a diff --git a/CabalHelper/Main.hs b/CabalHelper/Main.hs index f35ed3f..7c0d15a 100644 --- a/CabalHelper/Main.hs +++ b/CabalHelper/Main.hs @@ -204,8 +204,7 @@ main = do return $ Just $ ChResponseFlags $ sort nonDefaultFlags "write-autogen-files":[] -> do - -- calls writeAutogenFiles - initialBuildSteps distdir pd lbi v + initialBuildStepsForAllComponents distdir pd lbi v return Nothing "compiler-version":[] -> do @@ -328,6 +327,8 @@ componentsMap lbi v distdir f = do lr <- newIORef [] + -- withComponentsLBI is deprecated but also exists in very old versions + -- it's equivalent to withAllComponentsInBuildOrder in newer versions withComponentsLBI pd lbi $ \c clbi -> do let bi = componentBuildInfo c name = componentNameFromComponent c @@ -354,12 +355,20 @@ componentOptions' (lbi, v, distdir) inplaceFlag flags rf f = do componentOptions (lbi, v, distdir) inplaceFlag flags f = componentOptions' (lbi, v, distdir) inplaceFlag flags renderGhcOptions' f -componentNameToCh CLibName = ChLibName +#if CABAL_MAJOR == 1 && CABAL_MINOR < 25 +componentNameToCh CLibName = ChLibName "" +#elif CABAL_MAJOR == 1 && CABAL_MINOR >= 25 +componentNameToCh (CLibName n) = ChLibName n +#endif componentNameToCh (CExeName n) = ChExeName n componentNameToCh (CTestName n) = ChTestName n componentNameToCh (CBenchName n) = ChBenchName n +#if CABAL_MAJOR == 1 && CABAL_MINOR < 25 componentNameFromComponent (CLib Library {}) = CLibName +#elif CABAL_MAJOR == 1 && CABAL_MINOR >= 25 +componentNameFromComponent (CLib Library {..}) = CLibName libName +#endif componentNameFromComponent (CExe Executable {..}) = CExeName exeName componentNameFromComponent (CTest TestSuite {..}) = CTestName testName componentNameFromComponent (CBench Benchmark {..}) = CBenchName benchmarkName @@ -450,10 +459,20 @@ renderGhcOptions' lbi v opts = do (ghcProg, _) <- requireProgram v ghcProgram (withPrograms lbi) let Just ghcVer = programVersion ghcProg return $ renderGhcOptions ghcVer opts -#elif CABAL_MAJOR == 1 && CABAL_MINOR >= 22 && CABAL_MINOR < 24 +#elif CABAL_MAJOR == 1 && CABAL_MINOR >= 20 && CABAL_MINOR < 24 -- && CABAL_MINOR < 24 return $ renderGhcOptions (compiler lbi) opts #elif CABAL_MAJOR == 1 && CABAL_MINOR >= 24 -- CABAL_MAJOR == 1 && CABAL_MINOR >= 24 return $ renderGhcOptions (compiler lbi) (hostPlatform lbi) opts #endif + + +#if CABAL_MAJOR == 1 && CABAL_MINOR < 25 +initialBuildStepsForAllComponents distdir pd lbi v = + initialBuildSteps distdir pd lbi v +#elif CABAL_MAJOR == 1 && CABAL_MINOR >= 25 +initialBuildStepsForAllComponents distdir pd lbi v = + withComponentsLBI pd lbi $ \_c clbi -> + initialBuildSteps distdir pd lbi clbi v +#endif diff --git a/CabalHelper/Types.hs b/CabalHelper/Types.hs index 6b2ac70..0ee7ec2 100644 --- a/CabalHelper/Types.hs +++ b/CabalHelper/Types.hs @@ -24,7 +24,7 @@ newtype ChModuleName = ChModuleName String deriving (Eq, Ord, Read, Show, Generic) data ChComponentName = ChSetupHsName - | ChLibName + | ChLibName String | ChExeName String | ChTestName String | ChBenchName String diff --git a/tests/Spec.hs b/tests/Spec.hs index bade29c..961f83f 100644 --- a/tests/Spec.hs +++ b/tests/Spec.hs @@ -86,7 +86,7 @@ compilePrivatePkgDb :: Either HEAD Version -> IO (Either ExitCode FilePath) compilePrivatePkgDb (Left HEAD) = do _ <- rawSystem "rm" [ "-r", "/tmp/.ghc-mod" ] (db, commit) <- installCabalHEAD defaultOptions { verbose = True } `E.catch` - \(SomeException ex) -> error $ "Inslling cabal HEAD failed: " ++ show ex + \(SomeException ex) -> error $ "Installing cabal HEAD failed: " ++ show ex compileWithPkg "." (Just db) (Left commit) compilePrivatePkgDb (Right cabalVer) = do _ <- rawSystem "rm" [ "-r", "/tmp/.ghc-mod" ] |