@@ -167,7 +167,7 @@ run root interpretPaths = do
167 withGhciScript pkgs $ \dotGhciPath -> do
167 withGhciScript pkgs $ \dotGhciPath -> do
168 assets <- findProjectAssets root
168 assets <- findProjectAssets root
169 putLog Debug $ "Assets impurely loaded from: " <> assets
169 putLog Debug $ "Assets impurely loaded from: " <> assets
170− ghciArgs <- getGhciSessionSettings pkgs root
170+ ghciArgs <- getGhciSessionSettings pkgs root True
171 freePort <- getFreePort
171 freePort <- getFreePort
172 runGhcid root True (ghciArgs <> mkGhciScriptArg dotGhciPath) pkgs $ Just $ unwords
172 runGhcid root True (ghciArgs <> mkGhciScriptArg dotGhciPath) pkgs $ Just $ unwords
173 [ "Obelisk.Run.run"
173 [ "Obelisk.Run.run"
@@ -180,21 +180,21 @@ run root interpretPaths = do
180runRepl :: MonadObelisk m => FilePath -> PathTree Interpret -> m ()
180runRepl :: MonadObelisk m => FilePath -> PathTree Interpret -> m ()
181runRepl root interpretPaths = do
181runRepl root interpretPaths = do
182 pkgs <- getParsedLocalPkgs root interpretPaths
182 pkgs <- getParsedLocalPkgs root interpretPaths
183− ghciArgs <- getGhciSessionSettings pkgs "."
183+ ghciArgs <- getGhciSessionSettings pkgs "." True
184 withGhciScript pkgs $ \dotGhciPath ->
184 withGhciScript pkgs $ \dotGhciPath ->
185 runGhciRepl root pkgs (ghciArgs <> mkGhciScriptArg dotGhciPath)
185 runGhciRepl root pkgs (ghciArgs <> mkGhciScriptArg dotGhciPath)
187runWatch :: MonadObelisk m => FilePath -> PathTree Interpret -> m ()
187runWatch :: MonadObelisk m => FilePath -> PathTree Interpret -> m ()
188runWatch root interpretPaths = do
188runWatch root interpretPaths = do
189 pkgs <- getParsedLocalPkgs root interpretPaths
189 pkgs <- getParsedLocalPkgs root interpretPaths
190− ghciArgs <- getGhciSessionSettings pkgs root
190+ ghciArgs <- getGhciSessionSettings pkgs root True
191 withGhciScript pkgs $ \dotGhciPath ->
191 withGhciScript pkgs $ \dotGhciPath ->
192 runGhcid root True (ghciArgs <> mkGhciScriptArg dotGhciPath) pkgs Nothing
192 runGhcid root True (ghciArgs <> mkGhciScriptArg dotGhciPath) pkgs Nothing
194−exportGhciConfig :: MonadObelisk m => FilePath -> PathTree Interpret -> m [String]
194+exportGhciConfig :: MonadObelisk m => Bool -> FilePath -> PathTree Interpret -> m [String]
195−exportGhciConfig root interpretPaths = do
195+exportGhciConfig useRelativePaths root interpretPaths = do
196 pkgs <- getParsedLocalPkgs root interpretPaths
196 pkgs <- getParsedLocalPkgs root interpretPaths
197− getGhciSessionSettings pkgs "."
197+ getGhciSessionSettings pkgs "." useRelativePaths
199nixShellForInterpretPaths :: MonadObelisk m => Bool -> String -> FilePath -> PathTree Interpret -> Maybe String -> m ()
199nixShellForInterpretPaths :: MonadObelisk m => Bool -> String -> FilePath -> PathTree Interpret -> Maybe String -> m ()
200nixShellForInterpretPaths isPure shell root interpretPaths cmd = do
200nixShellForInterpretPaths isPure shell root interpretPaths cmd = do
@@ -427,8 +427,9 @@ getGhciSessionSettings
427 :: (MonadObelisk m, Foldable f)
427 :: (MonadObelisk m, Foldable f)
428 => f CabalPackageInfo -- ^ List of packages to load into ghci
428 => f CabalPackageInfo -- ^ List of packages to load into ghci
429 -> FilePath -- ^ All paths will be relative to this path
429 -> FilePath -- ^ All paths will be relative to this path
430+ -> Bool -- ^ Use relative paths
430 -> m [String]
431 -> m [String]
431−getGhciSessionSettings (toList -> packageInfos) pathBase = do
432+getGhciSessionSettings (toList -> packageInfos) pathBase useRelativePaths = do
432 -- N.B. ghci settings do NOT support escaping in any way. To minimize the likelihood that
433 -- N.B. ghci settings do NOT support escaping in any way. To minimize the likelihood that
433 -- paths-with-spaces ruin our day, we first canonicalize everything, and then relativize
434 -- paths-with-spaces ruin our day, we first canonicalize everything, and then relativize
434 -- all paths to 'pathBase'.
435 -- all paths to 'pathBase'.
@@ -438,13 +439,15 @@ getGhciSessionSettings (toList -> packageInfos) pathBase = do
438 (pkgFiles, pkgSrcPaths :: [NonEmpty FilePath]) <- fmap unzip $ liftIO $ for packageInfos $ \pkg -> do
439 (pkgFiles, pkgSrcPaths :: [NonEmpty FilePath]) <- fmap unzip $ liftIO $ for packageInfos $ \pkg -> do
439 canonicalSrcDirs <- traverse canonicalizePath $ (_cabalPackageInfo_packageRoot pkg </>) <$> _cabalPackageInfo_sourceDirs pkg
440 canonicalSrcDirs <- traverse canonicalizePath $ (_cabalPackageInfo_packageRoot pkg </>) <$> _cabalPackageInfo_sourceDirs pkg
440 canonicalPkgFile <- canonicalizePath $ _cabalPackageInfo_packageFile pkg
441 canonicalPkgFile <- canonicalizePath $ _cabalPackageInfo_packageFile pkg
441− pure (canonicalPkgFile `relativeTo` canonicalPathBase, (`relativeTo` canonicalPathBase) <$> canonicalSrcDirs)
442+ pure (canonicalPkgFile `relativeTo'` canonicalPathBase, (`relativeTo'` canonicalPathBase) <$> canonicalSrcDirs)
444 $ baseGhciOptions
445 $ baseGhciOptions
445 <> ["-F", "-pgmF", selfExe, "-optF", preprocessorIdentifier]
446 <> ["-F", "-pgmF", selfExe, "-optF", preprocessorIdentifier]
446 <> concatMap (\p -> ["-optF", p]) pkgFiles
447 <> concatMap (\p -> ["-optF", p]) pkgFiles
447 <> [ "-i" <> intercalate ":" (concatMap toList pkgSrcPaths) ]
448 <> [ "-i" <> intercalate ":" (concatMap toList pkgSrcPaths) ]
450+ relativeTo' = if useRelativePaths then relativeTo else const
449baseGhciOptions :: [String]
452baseGhciOptions :: [String]
450baseGhciOptions =
453baseGhciOptions =
@@ -537,4 +540,4 @@ relativeTo dir base
537 $ zipDefaultWith Nothing Nothing (,)
540 $ zipDefaultWith Nothing Nothing (,)
538 (map Just $ splitDirectories base)
541 (map Just $ splitDirectories base)
539 (map Just $ splitDirectories dir)
542 (map Just $ splitDirectories dir)
540− where collapse = foldr (</>) ""
543+ where collapse = foldr (</>) ""