From e11c78c0ceb801db2b2904a693565924417da672 Mon Sep 17 00:00:00 2001 From: Mathieu Boespflug Date: Sat, 4 Jun 2016 23:48:46 +0200 Subject: [PATCH] Support .buildinfo files in stack ghci. `Distribution.Simple` based `Setup.hs` sometimes create `.buildinfo` files as an artifact of the configure phase. This is the case in particular when using the autoconf hooks. Since this is an internal detail private to any given package's `Setup.hs`, Stack shouldn't (and doesn't) need to care or be aware of this. But `stack ghci` does, since in that use case we're not using Cabal to build - we're taking care of the build ourselves. In particular, ignoring the ` buildinfofp) + let mbuildinfofp + | hasDotBuildinfo = Just (parent cabalfp buildinfofp) + | otherwise = Nothing + mbuildinfo <- forM mbuildinfofp readDotBuildinfo + let pkg = + packageFromPackageDescription config gpkgdesc $ + maybe id (updatePackageDescription) mbuildinfo $ + resolvePackageDescription config gpkgdesc + mapM_ (printCabalFileWarning cabalfp) warnings (mods,files,opts) <- getPackageOpts (packageOpts pkg) sourceMap installedMap locals addPkgs cabalfp let filteredOpts = filterWanted opts diff --git a/src/Stack/Package.hs b/src/Stack/Package.hs index 62b69a3801..b96addbde8 100644 --- a/src/Stack/Package.hs +++ b/src/Stack/Package.hs @@ -18,6 +18,7 @@ module Stack.Package (readPackage ,readPackageBS ,readPackageDescriptionDir + ,readDotBuildinfo ,readPackageUnresolved ,readPackageUnresolvedBS ,resolvePackage @@ -147,6 +148,17 @@ readPackageDescriptionDir config pkgDir = do gdesc <- liftM snd (readPackageUnresolved cabalfp) return (gdesc, resolvePackageDescription config gdesc) +-- | Read @.buildinfo@ ancillary files produced by some Setup.hs hooks. +-- The file includes Cabal file syntax to be merged into the package description +-- derived from the package's .cabal file. +-- +-- NOTE: not to be confused with BuildInfo, an Stack-internal datatype. +readDotBuildinfo :: MonadIO m + => Path Abs File + -> m HookedBuildInfo +readDotBuildinfo buildinfofp = + liftIO $ readHookedBuildInfo D.silent (toFilePath buildinfofp) + -- | Print cabal file warnings. printCabalFileWarning :: (MonadLogger m)