packages feed

cabal-helper 0.3.9.0 → 0.4.0.0

raw patch · 4 files changed

+43/−25 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Distribution.Helper: runQuery :: Monad m => FilePath -> Query m a -> m a
+ Distribution.Helper: runQuery :: Monad m => FilePath -> FilePath -> Query m a -> m a
- Distribution.Helper: runQuery' :: Monad m => Programs -> FilePath -> Query m a -> m a
+ Distribution.Helper: runQuery' :: Monad m => Programs -> FilePath -> FilePath -> Query m a -> m a

Files

CabalHelper/Main.hs view
@@ -118,7 +118,7 @@ main = do   args <- getArgs -  distdir:args' <- case args of+  projdir:distdir:args' <- case args of                     [] -> usage >> exitFailure                     _ -> return args @@ -159,6 +159,7 @@   print =<< flip mapM cmds $$ \cmd -> do   case cmd of     "write-autogen-files":[] -> do+      -- can't use @projdir@ here       let pd = localPkgDescr lbi        -- calls writeAutogenFiles       initialBuildSteps distdir pd lbi v
CabalHelper/Wrapper.hs view
@@ -46,6 +46,7 @@ import CabalHelper.Data import CabalHelper.Common import CabalHelper.GuessGhc+import CabalHelper.Sandbox (getSandboxPkgDb)  usage :: IO () usage = do@@ -59,7 +60,7 @@ \  [--with-ghc=GHC_PATH]\n\ \  [--with-ghc-pkg=GHC_PKG_PATH]\n\ \  [--with-cabal=CABAL_PATH]\n\-\  DIST_DIR ( print-exe | [CABAL_HELPER_ARGS...] ) )\n"+\  PROJ_DIR DIST_DIR ( print-exe | [CABAL_HELPER_ARGS...] ) )\n"  data Options = Options {           verbose       :: Bool@@ -122,7 +123,7 @@     "version":[] -> putStrLn $ showVersion version     "print-appdatadir":[] -> putStrLn =<< appDataDir     "print-build-platform":[] -> putStrLn $ display buildPlatform-    distdir:args' -> do+    projdir:distdir:args' -> do       cfgf <- canonicalizePath (distdir </> "setup-config")       mhdr <- getCabalConfigHeader cfgf       case mhdr of@@ -131,7 +132,7 @@ \- Check first line of: %s\n\ \- Maybe try: $ cabal configure" cfgf         Just (hdrCabalVersion, _) -> do-          eexe <- compileHelper opts hdrCabalVersion distdir+          eexe <- compileHelper opts hdrCabalVersion projdir distdir           case eexe of               Left e -> exitWith e               Right exe ->@@ -140,21 +141,23 @@                   _ -> do                     (_,_,_,h) <- createProcess $ proc exe args                     exitWith =<< waitForProcess h+    _ -> error "invalid command line"  appDataDir :: IO FilePath appDataDir = (</> "cabal-helper") <$> getAppUserDataDirectory "ghc-mod" -compileHelper :: Options -> Version -> FilePath -> IO (Either ExitCode FilePath)-compileHelper opts cabalVer distdir = withHelperSources $ \chdir -> do+compileHelper :: Options -> Version -> FilePath -> FilePath -> IO (Either ExitCode FilePath)+compileHelper opts cabalVer projdir distdir = withHelperSources $ \chdir -> do   run [ compileCabalSource chdir -- TODO: here ghc's caching fails and it always                                  -- recompiles, probably because we write the                                  -- sources to a tempdir and they always look                                  -- newer than the Cabal sources, not sure if we                                  -- can fix this       , Right <$> MaybeT (cachedExe cabalVer)+      , compileSandbox chdir       , compileGlobal chdir       , cachedCabalPkg chdir-      , MaybeT (Just <$> compileSandbox chdir)+      , MaybeT (Just <$> compilePrivatePkgDb chdir)       ]   where@@ -175,6 +178,15 @@        vLog opts $ logMsg ++ "user/global package-db"        liftIO $ compileWithPkg chdir Nothing ver +   -- | Check if this version is available in the project sandbox+   compileSandbox :: FilePath -> MaybeT IO (Either ExitCode FilePath)+   compileSandbox chdir = do+       sandbox <- MaybeT $ getSandboxPkgDb projdir (display buildPlatform) =<< ghcVersion opts+       ver <- MaybeT $ find (== cabalVer) <$> listCabalVersions' opts (Just sandbox)+       vLog opts $ logMsg ++ "sandbox package-db"+       liftIO $ compileWithPkg chdir (Just sandbox) ver++    -- | Check if we already compiled this version of cabal into a private    -- package-db    cachedCabalPkg :: FilePath -> MaybeT IO (Either ExitCode FilePath)@@ -190,8 +202,7 @@    -- | See if we're in a cabal source tree    compileCabalSource :: FilePath -> MaybeT IO (Either ExitCode FilePath)    compileCabalSource chdir = do-       let couldBeSrcDir = takeDirectory distdir-           cabalFile = couldBeSrcDir </> "Cabal.cabal"+       let cabalFile = projdir </> "Cabal.cabal"            isCabalMagicVer = cabalVer == Version [1,9999] []        cabalSrc <- liftIO $ doesFileExist cabalFile @@ -206,11 +217,11 @@          True -> liftIO $ do            ver <- cabalFileVersion <$> readFile cabalFile            vLog opts $ "compiling helper with local Cabal source tree"-           compileWithCabalTree chdir ver couldBeSrcDir+           compileWithCabalTree chdir ver projdir     -- | Compile the requested cabal version into an isolated package-db-   compileSandbox :: FilePath -> IO (Either ExitCode FilePath)-   compileSandbox chdir = do+   compilePrivatePkgDb :: FilePath -> IO (Either ExitCode FilePath)+   compilePrivatePkgDb chdir = do        db <- installCabal opts cabalVer `E.catch`              \(SomeException _) -> errorInstallCabal cabalVer distdir        compileWithPkg chdir (Just db) cabalVer
Distribution/Helper.hs view
@@ -106,31 +106,35 @@ -- as reading in Cabal's @LocalBuildInfo@ datatype from disk is very slow but -- running all possible queries against it at once is cheap. newtype Query m a = Query { unQuery :: StateT (Maybe SomeLocalBuildInfo)-                                         (ReaderT (Programs, FilePath) m) a }+                                         (ReaderT (Programs, FilePath, FilePath) m) a }     deriving (Functor, Applicative, Monad, MonadIO)  type MonadQuery m = ( MonadIO m                     , MonadState (Maybe SomeLocalBuildInfo) m-                    , MonadReader (Programs, FilePath) m)+                    , MonadReader (Programs, FilePath, FilePath) m)  run :: Monad m-  => (Programs, FilePath) -> Maybe SomeLocalBuildInfo -> Query m a -> m a+  => (Programs, FilePath, FilePath) -> Maybe SomeLocalBuildInfo -> Query m a -> m a run r s action = flip runReaderT r (flip evalStateT s (unQuery action))  -- | @runQuery query distdir@. Run a 'Query'. @distdir@ is where Cabal's -- @setup-config@ file is located. runQuery :: Monad m-         => FilePath -- ^ Path to @dist/@+         => FilePath -- ^ Path to project directory, i.e. the one containing the+                     -- @project.cabal@ file+         -> FilePath -- ^ Path to @dist/@          -> Query m a          -> m a-runQuery fp action = run (def, fp) Nothing action+runQuery pd dd action = run (def, pd, dd) Nothing action  runQuery' :: Monad m          => Programs+         -> FilePath -- ^ Path to project directory, i.e. the one containing the+                     -- @project.cabal@ file          -> FilePath -- ^ Path to @dist/@          -> Query m a          -> m a-runQuery' progs fp action = run (progs, fp) Nothing action+runQuery' progs pd dd action = run (progs, pd, dd) Nothing action  getSlbi :: MonadQuery m => m SomeLocalBuildInfo getSlbi = do@@ -196,7 +200,7 @@     return ()  getSomeConfigState :: MonadQuery m => m SomeLocalBuildInfo-getSomeConfigState = ask >>= \(progs, distdir) -> do+getSomeConfigState = ask >>= \(progs, projdir, distdir) -> do   let progArgs = [ "--with-ghc="     ++ ghcProgram progs                  , "--with-ghc-pkg=" ++ ghcPkgProgram progs                  , "--with-cabal="   ++ cabalProgram progs@@ -214,7 +218,7 @@    res <- liftIO $ do     exe  <- findLibexecExe "cabal-helper-wrapper"-    out <- readProcess exe (distdir:args) ""+    out <- readProcess exe (projdir:distdir:args) ""     evaluate (read out) `E.catch` \(SomeException _) ->       error $ concat ["getSomeConfigState", ": ", exe, " "                      , intercalate " " (map show $ distdir:args)@@ -239,7 +243,7 @@                   -> m () writeAutogenFiles distdir = liftIO $ do   exe  <- findLibexecExe "cabal-helper-wrapper"-  void $ readProcess exe [distdir, "write-autogen-files"] ""+  void $ readProcess exe ["/nowhere/../..", distdir, "write-autogen-files"] ""  -- | Get the path to the sandbox package-db in a project getSandboxPkgDb :: FilePath
cabal-helper.cabal view
@@ -1,10 +1,12 @@ name:                cabal-helper-version:             0.3.9.0+version:             0.4.0.0 synopsis:            Simple interface to some of Cabal's configuration state used by ghc-mod description:-    @cabal-helper@ provides a library which wraps the internal use of executables-    to lift the restrictions imposed by linking against versions of GHC before-    @7.10@.+    @cabal-helper@ provides a library which wraps the internal use of+    anexecutable to lift the restrictions imposed by linking against versions of+    GHC before @7.10@. This has the pleasant side effect of isolating the user+    from having to deal with Cabal version changes manually as @cabal-helper@+    can simply recompile it's helper program automatically as needed.     .     @cabal-helper@ uses a wrapper executable to compile the actual cabal-helper     executable at runtime while linking against an arbitrary version of