@@ -14,7 +14,7 @@ module Obelisk.Command.Run where
1414import Control.Arrow ((&&&))
1515import Control.Exception (Exception, bracket)
1616import Control.Lens (ifor, (.~), (&))
17−import Control.Monad (filterM)
17+import Control.Monad (filterM, unless)
1818import Control.Monad.Except (runExceptT, throwError)
1919import Control.Monad.IO.Class (liftIO)
2020import Control.Monad.Reader (MonadIO)
@@ -160,8 +160,8 @@ profile profileBasePattern rtsFlags = withProjectRoot "." $ \root -> do
160160 ] <> rtsFlags
161161 <> [ "-RTS" ]
162162
163−run :: MonadObelisk m => FilePath -> PathTree Interpret -> m ()
164−run root interpretPaths = do
163+run :: MonadObelisk m => Maybe FilePath -> FilePath -> PathTree Interpret -> m ()
164+run certDir root interpretPaths = do
165165 pkgs <- getParsedLocalPkgs root interpretPaths
166166 assets <- findProjectAssets root
167167 putLog Debug $ "Assets impurely loaded from: " <> assets
@@ -171,6 +171,7 @@ run root interpretPaths = do
171171 runGhcid root True (ghciArgs <> dotGhciArgs) pkgs $ Just $ unwords
172172 [ "Obelisk.Run.run"
173173 , show freePort
174+ , "(" ++ show certDir ++ ")"
174175 , "(Obelisk.Run.runServeAsset " ++ show assets ++ ")"
175176 , "Backend.backend"
176177 , "Frontend.frontend"
@@ -304,16 +305,15 @@ parseCabalPackage
304305 -> m (Maybe CabalPackageInfo)
305306parseCabalPackage dir = parseCabalPackage' dir >>= \case
306307 Left err -> Nothing <$ putLog Error err
307− Right (Just (warnings, pkgInfo)) -> do
308+ Right (warnings, pkgInfo) -> do
308309 for_ warnings $ putLog Warning . T.pack . show
309310 pure $ Just pkgInfo
310− Right Nothing -> pure Nothing
311311
312312-- | Like 'parseCabalPackage' but returns errors and warnings directly so as to avoid 'MonadObelisk'.
313313parseCabalPackage'
314314 :: (MonadIO m)
315315 => FilePath -- ^ Package directory
316− -> m (Either T.Text (Maybe ([Dist.PWarning], CabalPackageInfo)))
316+ -> m (Either T.Text ([Dist.PWarning], CabalPackageInfo))
317317parseCabalPackage' pkg = runExceptT $ do
318318 (cabalContents, packageFile, packageName) <- guessCabalPackageFile pkg >>= \case
319319 Left GuessPackageFileError_NotFound -> throwError $ "No .cabal or package.yaml file found in " <> T.pack pkg
@@ -341,7 +341,7 @@ parseCabalPackage' pkg = runExceptT $ do
341341 case condLibrary <$> result of
342342 Right (Just condLib) -> do
343343 let (_, lib) = simplifyCondTree evalConfVar condLib
344− pure $ Just $ (warnings,) $ CabalPackageInfo
344+ pure $ (warnings,) $ CabalPackageInfo
345345 { _cabalPackageInfo_packageName = T.pack packageName
346346 , _cabalPackageInfo_packageFile = packageFile
347347 , _cabalPackageInfo_packageRoot = takeDirectory packageFile
@@ -355,17 +355,17 @@ parseCabalPackage' pkg = runExceptT $ do
355355 , _cabalPackageInfo_compilerOptions = options $ libBuildInfo lib
356356 , _cabalPackageInfo_cppOptions = cppOptions $ libBuildInfo lib
357357 }
358− Right Nothing -> pure Nothing
358+ Right Nothing -> throwError "Haskell package has no library component"
359359 Left (_, errors) ->
360360 throwError $ T.pack $ "Failed to parse " <> packageFile <> ":\n" <> unlines (map show errors)
361361
362362parsePackagesOrFail :: (MonadObelisk m, Foldable f) => f FilePath -> m (NE.NonEmpty CabalPackageInfo)
363363parsePackagesOrFail dirs' = do
364− packageInfos' <- fmap catMaybes $ for dirs $ \dir -> do
364+ (pkgDirErrs, packageInfos') <- fmap partitionEithers $ for dirs $ \dir -> do
365365 flip fmap (parseCabalPackage dir) $ \case
366366 Just packageInfo
367− | _cabalPackageInfo_buildable packageInfo -> Just packageInfo
368− _ -> Nothing
367+ | _cabalPackageInfo_buildable packageInfo -> Right packageInfo
368+ _ -> Left dir
369369
370370 -- Sort duplicate packages such that we prefer shorter paths, but fall back to alphabetical ordering.
371371 let packagesByName = Map.map (NE.sortBy $ comparing $ \p -> let n = _cabalPackageInfo_packageFile p in (length n, n))
@@ -387,6 +387,9 @@ parsePackagesOrFail dirs' = do
387387 "No valid, buildable packages found" <> (if null dirs then "" else " in " <> intercalate ", " dirs)
388388 Just xs -> pure xs
389389
390+ unless (null pkgDirErrs) $
391+ putLog Warning $ T.pack $ "Failed to find buildable packages in " <> intercalate ", " pkgDirErrs
392+
390393 pure packageInfos
391394 where
392395 dirs = toList dirs'