- if null srcs then throwDyn (UsageError "no input files") else do
-
- let compileFile src = do
- restoreDynFlags
-
- exists <- doesFileExist src
- when (not exists) $
- throwDyn (CmdLineError ("file `" ++ src ++ "' does not exist"))
-
- -- We compile in two stages, because the file may have an
- -- OPTIONS pragma that affects the compilation pipeline (eg. -fvia-C)
- let (basename, suffix) = splitFilename src
-
- -- just preprocess (Haskell source only)
- let src_and_suff = (src, getFileSuffix src)
- let not_hs_file = not (haskellish_src_file src)
- pp <- if not_hs_file || mode == StopBefore Hsc || mode == StopBefore HsPp
- then return src_and_suff else do
- phases <- genPipeline (StopBefore Hsc) stop_flag
- False{-not persistent-} defaultHscLang
- src_and_suff
- pipeLoop phases src_and_suff False{-no linking-} False{-no -o flag-}
- basename suffix
-
- -- rest of compilation
- hsc_lang <- dynFlag hscLang
- phases <- genPipeline mode stop_flag True hsc_lang pp
- (r,_) <- pipeLoop phases pp (mode==DoLink || mode==DoMkDLL)
- True{-use -o flag-} basename suffix
- return r
-
- o_files <- mapM compileFile srcs
-
- when (mode == DoMkDependHS) endMkDependHS
- when (mode == DoLink) (staticLink o_files)
- when (mode == DoMkDLL) (doMkDLL o_files)
-
-
-
-beginMake :: [String] -> IO ()
-beginMake fileish_args = do
- -- anything that doesn't look like a Haskell source filename or
- -- a module name is passed straight through to the linker
- let (inputs, objects) = partition looks_like_an_input fileish_args
- mapM_ (add v_Ld_inputs) objects
-
- case inputs of
- [] -> throwDyn (UsageError "no input files")
- _ -> do dflags <- getDynFlags
- state <- cmInit Batch
- graph <- cmDepAnal state dflags inputs
- (_, ok_flag, _) <- cmLoadModules state dflags graph
- when (failed ok_flag) (exitWith (ExitFailure 1))
- return ()
- where
- looks_like_an_input m = haskellish_src_file m || looksLikeModuleName m
-
-
-beginInteractive :: [String] -> IO ()
-#ifndef GHCI
-beginInteractive = throwDyn (CmdLineError "not built for interactive use")
-#else
-beginInteractive fileish_args
- = do state <- cmInit Interactive