diff options
Diffstat (limited to 'CabalHelper')
| -rw-r--r-- | CabalHelper/Compile.hs | 8 | ||||
| -rw-r--r-- | CabalHelper/Main.hs | 27 | ||||
| -rw-r--r-- | CabalHelper/Types.hs | 2 | 
3 files changed, 28 insertions, 9 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 | 
