packages feed

cabal-helper 0.3.1.0 → 0.3.2.0

raw patch · 5 files changed

+96/−49 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Distribution.Helper: ghcLangOptions :: MonadIO m => Query m [(ChComponentName, [String])]

Files

CabalHelper/Common.hs view
@@ -63,19 +63,17 @@  -- | @getCabalConfigHeader "dist/setup-config"@ returns the cabal version and -- compiler version-getCabalConfigHeader :: FilePath -> IO (Maybe (Version, Version))+getCabalConfigHeader :: FilePath -> IO (Maybe (Version, (ByteString, Version))) getCabalConfigHeader file = bracket (openFile file ReadMode) hClose $ \h -> do   parseHeader <$> BS.hGetLine h -parseHeader :: ByteString -> Maybe (Version, Version)+parseHeader :: ByteString -> Maybe (Version, (ByteString, Version)) parseHeader header = case BS8.words header of   ["Saved", "package", "config", "for", _pkgId ,    "written", "by", cabalId,    "using", compId]-    -> liftM2 (,) (ver cabalId) (ver compId)+    -> liftM2 (,) (snd <$> parsePkgId cabalId) (parsePkgId compId)   _ -> Nothing- where-   ver i = snd <$> parsePkgId i  parsePkgId :: ByteString -> Maybe (ByteString, Version) parsePkgId bs =@@ -86,11 +84,11 @@ parseVer :: String -> Version parseVer vers = runReadP parseVersion vers --- majorVer :: Version -> Version--- majorVer (Version b _) = Version (take 2 b) []+majorVer :: Version -> Version+majorVer (Version b _) = Version (take 2 b) [] --- sameMajorVersion :: Version -> Version -> Bool--- sameMajorVersion a b = majorVer a == majorVer b+sameMajorVersionAs :: Version -> Version -> Bool+sameMajorVersionAs a b = majorVer a == majorVer b  runReadP :: ReadP t -> String -> t runReadP p i = case filter ((=="") . snd) $ readP_to_S p i of
CabalHelper/Main.hs view
@@ -92,6 +92,7 @@      ++"         | ghc-options     [--with-inplace]\n"      ++"         | ghc-src-options [--with-inplace]\n"      ++"         | ghc-pkg-options [--with-inplace]\n"+     ++"         | ghc-lang-options [--with-inplace]\n"      ++"         | entrypoints\n"      ++"         | source-dirs\n"      ++"         ) ...\n"@@ -103,6 +104,7 @@            , "ghc-options"            , "ghc-src-options"            , "ghc-pkg-options"+           , "ghc-lang-options"            , "entrypoints"            , "source-dirs"] @@ -178,7 +180,7 @@             opts' = mempty {                -- Not really needed but "unexpected package db stack: []"-               ghcOptPackageDBs      = [GlobalPackageDB],+               ghcOptPackageDBs      = [GlobalPackageDB, UserPackageDB],                 ghcOptCppOptions      = ghcOptCppOptions opts,                ghcOptCppIncludePath  = ghcOptCppIncludePath opts,@@ -203,6 +205,25 @@                        ghcOptPackageDBs = ghcOptPackageDBs opts,                        ghcOptPackages   = ghcOptPackages opts,                        ghcOptHideAllPackages = ghcOptHideAllPackages opts+                   }+         in renderGhcOptions' lbi v $ opts' `mappend` adopts+      return $ Just $ ChResponseStrings (res ++ [(ChSetupHsName, [])])++    "ghc-lang-options":flags -> do+      res <- componentsMap lbi v distdir $ \c clbi bi -> let+           comp = compiler lbi+           outdir = componentOutDir lbi c+           (clbi', adopts) = case flags of+                               ["--with-inplace"] -> (clbi, mempty)+                               [] -> removeInplaceDeps v lbi pd clbi+           opts = componentGhcOptions v lbi bi clbi' outdir++           opts' = mempty {+                       ghcOptPackageDBs      = [GlobalPackageDB, UserPackageDB],++                       ghcOptLanguage = ghcOptLanguage opts,+                       ghcOptExtensions = ghcOptExtensions opts,+                       ghcOptExtensionMap = ghcOptExtensionMap opts                    }          in renderGhcOptions' lbi v $ opts' `mappend` adopts       return $ Just $ ChResponseStrings (res ++ [(ChSetupHsName, [])])
CabalHelper/Wrapper.hs view
@@ -119,17 +119,23 @@ \Could not read Cabal's persistent setup configuration header\n\ \- Check first line of: %s\n\ \- Maybe try: $ cabal configure" cfgf--        Just (hdrCabalVersion, _hdrCompilerVersion) -> do-          eexe <- compileHelper opts hdrCabalVersion distdir-          case eexe of-              Left e -> exitWith e-              Right exe ->-                case args' of-                  "print-exe":_ -> putStrLn exe-                  _ -> do-                    (_,_,_,h) <- createProcess $ proc exe args-                    exitWith =<< waitForProcess h+        Just (hdrCabalVersion, (_compilerName, hdrCompilerVersion)) -> do+          ghcVer <- ghcVersion opts+          if not $ ghcVer `sameMajorVersionAs` hdrCompilerVersion+            then panic $ printf "\+\GHC major version changed! (was %s, now %s)\n\+\- Reconfigure the project: $ cabal clean && cabal configure\+\ " (showVersion hdrCompilerVersion) (showVersion ghcVer)+            else do+              eexe <- compileHelper opts hdrCabalVersion distdir+              case eexe of+                  Left e -> exitWith e+                  Right exe ->+                    case args' of+                      "print-exe":_ -> putStrLn exe+                      _ -> do+                        (_,_,_,h) <- createProcess $ proc exe args+                        exitWith =<< waitForProcess h  appDataDir :: IO FilePath appDataDir = (</> "cabal-helper") <$> getAppUserDataDirectory "ghc-mod"@@ -179,7 +185,7 @@    compileSandbox :: FilePath -> IO (Either ExitCode FilePath)    compileSandbox chdir = do        db <- installCabal opts cabalVer `E.catch`-             \(SomeException _) -> errorInstallCabal cabalVer+             \(SomeException _) -> errorInstallCabal cabalVer distdir        compileWithPkg chdir (Just db)     compileWithCabalTree chdir ver srcDir =@@ -190,26 +196,37 @@     cabalPkgId v = "Cabal-" ++ showVersion v --- errorNoCabal :: Version -> a--- errorNoCabal cabalVer = panic $ printf "\--- \No appropriate Cabal package found, wanted version %s.\n"---  where---    sver = showVersion cabalVer--errorInstallCabal :: Version -> a-errorInstallCabal cabalVer = panic $ printf "\+errorInstallCabal :: Version -> FilePath -> a+errorInstallCabal cabalVer distdir = panic $ printf "\ \Installing Cabal version %s failed.\n\-\n\-\You have two choices now:\n\-\- Either you install this version of Cabal in your globa/luser package-db\n\-\  somehow\n\-\n\-\- Or you can see if you can update your cabal-install to use a different\n\-\  version of the Cabal library that we can build with:\n\-\    $ cabal install cabal-install --constraint 'Cabal > %s'\n\-\n\-\To check the version cabal-install is currently using try:\n\-\    $ cabal --version\n" sver sver+\\n\+\You have the following choices to fix this:\n\+\\n\+\- The easiest way to try and fix this is just reconfigure the project and try\n\+\  again:\n\+\        $ cabal clean && cabal configure\n\+\\n\+\- If that fails you can try to install the version of Cabal mentioned above\n\+\  into your global/user package-db somehow, you'll probably have to fix\n\+\  something otherwise it wouldn't have failed above:\n\+\        $ cabal install Cabal --constraint 'Cabal == %s'\n\+\\n\+\- If you're using `Build-Type: Simple`:\n\+\  - You can see if you can reinstall your cabal-install executable while\n\+\    having it linked to a version of Cabal that's available in you\n\+\    package-dbs or can be built automatically:\n\+\        $ ghc-pkg list | grep Cabal  # find an available Cabal version\n\+\        $ cabal install cabal-install --constraint 'Cabal == $the_found_version'\n\+\    Afterwards you'll have to reconfigure your project:\n\+\        $ cabal clean && cabal configure\n\+\\n\+\- If you're using `Build-Type: Custom`:\n\+\  - Have cabal-install rebuild your Setup.hs executable with a version of the\n\+\    Cabal library that you have available in your global/user package-db:\n\+\        $ cabal clean && cabal configure\n\+\    You might also have to install some version of the Cabal to do this:\n\+\        $ cabal install Cabal\n\+\\n" sver (distdir </> "setup-config") sver sver  where    sver = showVersion cabalVer @@ -283,6 +300,7 @@ installCabal :: Options -> Version -> IO FilePath installCabal opts ver = do   appdir <- appDataDir+  let sver = showVersion ver   hPutStr stderr $ printf "\ \cabal-helper-wrapper: Installing a private copy of Cabal, this might take a\n\ \while but will only happen once per Cabal version.\n\@@ -290,10 +308,11 @@ \If anything goes horribly wrong just delete this directory and try again:\n\ \    %s\n\ \\n\-\If you want to avoid this automatic installation altogether install version\n\-\%s of Cabal manually (into your user or global package-db):\n\+\If you want to avoid this automatic installation altogether install\n\+\version %s of Cabal manually (into your user or global package-db):\n\ \    $ cabal install Cabal-%s\n\-\..." appdir (showVersion ver) (showVersion ver)+\\n\+\Building Cabal-%s..." appdir sver sver sver    db <- createPkgDb opts ver   callProcessStderr (Just "/") (cabalProgram opts) $ concat@@ -310,7 +329,7 @@             else []         , [ "install", "Cabal-"++showVersion ver ]       ]-  hPutStrLn stderr "Done"+  hPutStrLn stderr "done"   return db  ghcVersion :: Options -> IO Version
Distribution/Helper.hs view
@@ -32,6 +32,7 @@   , ghcOptions   , ghcSrcOptions   , ghcPkgOptions+  , ghcLangOptions    -- * Result types   , ChModuleName(..)@@ -87,7 +88,8 @@       slbiSourceDirs    :: [(ChComponentName, [String])],       slbiGhcOptions    :: [(ChComponentName, [String])],       slbiGhcSrcOptions :: [(ChComponentName, [String])],-      slbiGhcPkgOptions :: [(ChComponentName, [String])]+      slbiGhcPkgOptions :: [(ChComponentName, [String])],+      slbiGhcLangOptions :: [(ChComponentName, [String])]     } deriving (Eq, Ord, Read, Show)  -- | Caches helper executable result so it doesn't have to be run more than once@@ -146,11 +148,15 @@ -- access any home modules. ghcPkgOptions :: MonadIO m => Query m [(ChComponentName, [String])] +-- | Only language related options, i.e. @-XSomeExtension@+ghcLangOptions :: MonadIO m => Query m [(ChComponentName, [String])]+ entrypoints   = Query $ slbiEntrypoints   `liftM` getSlbi sourceDirs    = Query $ slbiSourceDirs    `liftM` getSlbi ghcOptions    = Query $ slbiGhcOptions    `liftM` getSlbi ghcSrcOptions = Query $ slbiGhcSrcOptions `liftM` getSlbi ghcPkgOptions = Query $ slbiGhcPkgOptions `liftM` getSlbi+ghcLangOptions = Query $ slbiGhcLangOptions `liftM` getSlbi  -- | Run @cabal configure@ reconfigure :: MonadIO m@@ -181,6 +187,7 @@              , "ghc-options"              , "ghc-src-options"              , "ghc-pkg-options"+             , "ghc-lang-options"              ] ++ progArgs    res <- liftIO $ do@@ -195,9 +202,11 @@         Just (ChResponseStrings srcDirs),         Just (ChResponseStrings ghcOpts),         Just (ChResponseStrings ghcSrcOpts),-        Just (ChResponseStrings ghcPkgOpts) ] = res+        Just (ChResponseStrings ghcPkgOpts),+        Just (ChResponseStrings ghcLangOpts) ] = res -  return $ SomeLocalBuildInfo eps srcDirs ghcOpts ghcSrcOpts ghcPkgOpts+  return $ SomeLocalBuildInfo+             eps srcDirs ghcOpts ghcSrcOpts ghcPkgOpts ghcLangOpts  -- | Create @cabal_macros.h@ and @Paths_\<pkg\>@ possibly other generated files -- in the usual place.
cabal-helper.cabal view
@@ -1,5 +1,5 @@ name:                cabal-helper-version:             0.3.1.0+version:             0.3.2.0 synopsis:            Simple interface to Cabal's configuration state used by ghc-mod description:     @cabal-helper@ provides a library which wraps the internal use of executables