hie-bios 0.1.0 → 0.1.1
raw patch · 7 files changed
+110/−28 lines, 7 filesdep ~basedep ~containersdep ~deepseq
Dependency ranges changed: base, containers, deepseq, directory, ghc, process, transformers
Files
- ChangeLog +7/−1
- hie-bios.cabal +9/−9
- src/HIE/Bios/Cradle.hs +23/−9
- src/HIE/Bios/GHCApi.hs +52/−2
- src/HIE/Bios/Load.hs +1/−0
- wrappers/cabal.bat +0/−7
- wrappers/cabal.hs +18/−0
ChangeLog view
@@ -1,2 +1,8 @@-2019-10-06 - 0.1.0+2019-09-07 - 0.1.1++ * Compat with GHC 8.4+ * Fix long paths issue on windows+ * Handle projects with .o files++2019-09-06 - 0.1.0 * First release
hie-bios.cabal view
@@ -1,5 +1,5 @@ Name: hie-bios-Version: 0.1.0+Version: 0.1.1 Author: Matthew Pickering <matthewtpickering@gmail.com> Maintainer: Matthew Pickering <matthewtpickering@gmail.com> License: BSD3@@ -14,7 +14,7 @@ Extra-Source-Files: ChangeLog wrappers/bazel wrappers/cabal- wrappers/cabal.bat+ wrappers/cabal.hs Library Default-Language: Haskell2010@@ -33,20 +33,20 @@ HIE.Bios.Things HIE.Bios.Config Build-Depends:- base >= 4.9 && < 5,+ base >= 4.8 && < 5, base16-bytestring >= 0.1.1 && < 0.2, bytestring >= 0.10.8 && < 0.11,- deepseq >= 1.4.4 && < 1.5,- containers >= 0.6.0 && < 0.7,+ deepseq >= 1.4.3 && < 1.5,+ containers >= 0.5.11 && < 0.7, cryptohash-sha1 >= 0.11.100 && < 0.12,- directory >= 1.3.3 && < 1.4,+ directory >= 1.3.1 && < 1.4, filepath >= 1.4.2 && < 1.5, time >= 1.8.0 && < 1.9, extra >= 1.6.18 && < 1.7,- process >= 1.6.5 && < 1.7,+ process >= 1.6.1 && < 1.7, file-embed >= 0.0.11 && < 0.1,- ghc >= 8.6.1 && < 8.7,- transformers >= 0.5.6 && < 0.6,+ ghc >= 8.4.1 && < 8.7,+ transformers >= 0.5.5 && < 0.6, temporary >= 1.3 && < 1.4, text >= 1.2.3 && < 1.3, unix-compat >= 0.5.2 && < 0.6,
src/HIE/Bios/Cradle.hs view
@@ -127,8 +127,8 @@ cabalWrapper :: String cabalWrapper = $(embedStringFile "wrappers/cabal") -cabalWrapperBat :: String-cabalWrapperBat = $(embedStringFile "wrappers/cabal.bat")+cabalWrapperHs :: String+cabalWrapperHs = $(embedStringFile "wrappers/cabal.hs") processCabalWrapperArgs :: String -> Maybe [String] processCabalWrapperArgs args =@@ -138,15 +138,29 @@ in trace dir $ Just final_args _ -> Nothing +-- generate a fake GHC that can be passed to cabal+-- when run with --interactive, it will print out its+-- command-line arguments and exit+getCabalWrapperTool :: IO FilePath+getCabalWrapperTool = do+ wrapper_fp <-+ if isWindows+ then do+ wrapper_hs <- writeSystemTempFile "wrapper.hs" cabalWrapperHs+ -- the initial contents will be overwritten immediately after by ghc+ wrapper_fp <- writeSystemTempFile "wrapper.exe" ""+ callProcess "ghc" ["-o", wrapper_fp, wrapper_hs]+ return wrapper_fp+ else do+ writeSystemTempFile "bios-wrapper" cabalWrapper+ setFileMode wrapper_fp accessModes+ _check <- readFile wrapper_fp+ return wrapper_fp+ cabalAction :: FilePath -> Maybe String -> FilePath -> IO (ExitCode, String, [String]) cabalAction work_dir mc _fp = do- wrapper_fp <- writeSystemTempFile "wrapper.bat" $- if isWindows then cabalWrapperBat else cabalWrapper- -- TODO: This isn't portable for windows- setFileMode wrapper_fp accessModes- check <- readFile wrapper_fp- traceM check- let cab_args = ["v2-repl", "-v0", "--with-compiler", wrapper_fp]+ wrapper_fp <- getCabalWrapperTool+ let cab_args = ["v2-repl", "-v0", "--disable-documentation", "--with-compiler", wrapper_fp] ++ [component_name | Just component_name <- [mc]] (ex, args, stde) <- withCurrentDirectory work_dir (readProcessWithExitCode "cabal" cab_args [])
src/HIE/Bios/GHCApi.hs view
@@ -20,10 +20,12 @@ import Exception (ghandle, SomeException(..), ExceptionMonad(..), throwIO, Exception(..)) import GHC (Ghc, DynFlags(..), GhcLink(..), HscTarget(..), LoadHowMuch(..), GhcMonad, GhcT) import qualified GHC as G+import qualified DriverPhases as G import qualified Outputable as G import qualified MonadUtils as G import qualified HscMain as G import qualified GhcMake as G+import qualified Util as G import DynFlags import Control.Monad (void, when)@@ -152,6 +154,9 @@ $ setLinkerOptions df' ) G.setLogAction (\_df _wr _s _ss _pp _m -> return ())+#if __GLASGOW_HASKELL__ < 806+ (\_df -> return ())+#endif G.setTargets targets -- Get the module graph using the function `getModuleGraph` mod_graph <- G.depanal [] True@@ -214,8 +219,11 @@ cur_dir = '.' : [pathSeparator] nfp = normalise fp normal_fileish_paths = map (normalise_hyp . G.unLoc) leftovers- ts <- mapM (flip G.guessTarget Nothing) normal_fileish_paths- return (df2, ts)+ let+ (srcs, objs) = partition_args normal_fileish_paths [] []+ df3 = df2 { ldInputs = map (FileOption "") objs ++ ldInputs df2 }+ ts <- mapM (uncurry G.guessTarget) srcs+ return (df3, ts) -- TODO: Need to handle these as well -- Ideally it requires refactoring to work in GHCi monad rather than -- Ghc monad and then can just use newDynFlags.@@ -261,6 +269,48 @@ void $ G.setSessionDynFlags dflag return dflag teardown = void . G.setSessionDynFlags++-- partition_args, along with some of the other code in this file,+-- was copied from ghc/Main.hs+-- -----------------------------------------------------------------------------+-- Splitting arguments into source files and object files. This is where we+-- interpret the -x <suffix> option, and attach a (Maybe Phase) to each source+-- file indicating the phase specified by the -x option in force, if any.+partition_args :: [String] -> [(String, Maybe G.Phase)] -> [String]+ -> ([(String, Maybe G.Phase)], [String])+partition_args [] srcs objs = (reverse srcs, reverse objs)+partition_args ("-x":suff:args) srcs objs+ | "none" <- suff = partition_args args srcs objs+ | G.StopLn <- phase = partition_args args srcs (slurp ++ objs)+ | otherwise = partition_args rest (these_srcs ++ srcs) objs+ where phase = G.startPhase suff+ (slurp,rest) = break (== "-x") args+ these_srcs = zip slurp (repeat (Just phase))+partition_args (arg:args) srcs objs+ | looks_like_an_input arg = partition_args args ((arg,Nothing):srcs) objs+ | otherwise = partition_args args srcs (arg:objs)++ {-+ We split out the object files (.o, .dll) and add them+ to ldInputs for use by the linker.+ The following things should be considered compilation manager inputs:+ - haskell source files (strings ending in .hs, .lhs or other+ haskellish extension),+ - module names (not forgetting hierarchical module names),+ - things beginning with '-' are flags that were not recognised by+ the flag parser, and we want them to generate errors later in+ checkOptions, so we class them as source files (#5921)+ - and finally we consider everything without an extension to be+ a comp manager input, as shorthand for a .hs or .lhs filename.+ Everything else is considered to be a linker object, and passed+ straight through to the linker.+ -}+looks_like_an_input :: String -> Bool+looks_like_an_input m = G.isSourceFilename m+ || G.looksLikeModuleName m+ || "-" `isPrefixOf` m+ || not (hasExtension m)+ ----------------------------------------------------------------
src/HIE/Bios/Load.hs view
@@ -25,6 +25,7 @@ import Data.Time.Clock #if __GLASGOW_HASKELL__ < 806+pprTraceM :: Monad m => String -> SDoc -> m () pprTraceM x s = pprTrace x s (return ()) #endif
− wrappers/cabal.bat
@@ -1,7 +0,0 @@-@ECHO OFF -IF "%i" == "--interactive" ( - ECHO %CD% - ECHO %* -) ELSE ( - ghc %* -)
+ wrappers/cabal.hs view
@@ -0,0 +1,18 @@+module Main (main) where++import System.Directory (getCurrentDirectory)+import System.Environment (getArgs)+import System.Exit (exitWith)+import System.Process (spawnProcess, waitForProcess)++main = do+ args <- getArgs+ case args of+ "--interactive":_ -> do+ getCurrentDirectory >>= putStrLn+ -- note this probably breaks if paths have spaces in+ putStrLn $ unwords args+ _ -> do+ ph <- spawnProcess "ghc" args+ code <- waitForProcess ph+ exitWith code