on master help sign in
Merge pull request #634 from obsidiansystems/eac@respect-buildable

command: Respect buildable flag in cabal packages when loading into ghci

commit13440378c4b6545b82fe4f4218bc5509d34befda authorElliot Cameron <3noch@users.noreply.github.com> dateThu 30 Jan 2020, 21:09 (7 years ago) parent80f019c186744d
1 file changed+7−4
lib/command/src/Obelisk/Command/Run.hs+7−4
lib/command/src/Obelisk/Command/Run.hs+7−4
@@ -55,6 +55,7 @@ data CabalPackageInfo = CabalPackageInfo
5555 { _cabalPackageInfo_packageFile :: FilePath
5656 , _cabalPackageInfo_packageName :: T.Text
5757 , _cabalPackageInfo_packageRoot :: FilePath
58+ , _cabalPackageInfo_buildable :: Bool
5859 , _cabalPackageInfo_sourceDirs :: NE.NonEmpty FilePath
5960 -- ^ List of hs src dirs of the library component
6061 , _cabalPackageInfo_defaultExtensions :: [Extension]
@@ -220,6 +221,7 @@ parseCabalPackage' pkg = runExceptT $ do
220221 { _cabalPackageInfo_packageName = T.pack packageName
221222 , _cabalPackageInfo_packageFile = packageFile
222223 , _cabalPackageInfo_packageRoot = takeDirectory packageFile
224+ , _cabalPackageInfo_buildable = buildable $ libBuildInfo lib
223225 , _cabalPackageInfo_sourceDirs =
224226 fromMaybe (pure ".") $ NE.nonEmpty $ hsSourceDirs $ libBuildInfo lib
225227 , _cabalPackageInfo_defaultExtensions =
@@ -236,15 +238,16 @@ parsePackagesOrFail :: MonadObelisk m => [FilePath] -> m (NE.NonEmpty CabalPacka
236238parsePackagesOrFail dirs = do
237239 (pkgDirErrs, packageInfos') <- fmap partitionEithers $ for dirs $ \dir -> do
238240 flip fmap (parseCabalPackage dir) $ \case
239− Nothing -> Left dir
240− Just packageInfo -> Right packageInfo
241+ Just packageInfo
242+ | _cabalPackageInfo_buildable packageInfo -> Right packageInfo
243+ _ -> Left dir
241244
242245 packageInfos <- case NE.nonEmpty packageInfos' of
243− Nothing -> failWith $ T.pack $ "No valid packages found in " <> intercalate ", " dirs
246+ Nothing -> failWith $ T.pack $ "No valid, buildable packages found in " <> intercalate ", " dirs
244247 Just xs -> pure xs
245248
246249 unless (null pkgDirErrs) $
247− putLog Warning $ T.pack $ "Failed to find packages in " <> intercalate ", " pkgDirErrs
250+ putLog Warning $ T.pack $ "Failed to find buildable packages in " <> intercalate ", " pkgDirErrs
248251
249252 pure packageInfos
250253