Compilation pipeline



doMake :: [(String,Maybe Phase)] -> Ghc ()
doMake srcs  = do
    let (hs_srcs, non_hs_srcs) = partition haskellish srcs

        haskellish (f,Nothing) =
          looksLikeModuleName f || isHaskellSrcFilename f || '.' `notElem` f
        haskellish (_,Just phase) =
          phase `notElem` [As, Cc, Cobjc, Cobjcpp, CmmCpp, Cmm, StopLn]

    hsc_env <- GHC.getSession

    -- if we have no haskell sources from which to do a dependency
    -- analysis, then just do one-shot compilation and/or linking.
    -- This means that "ghc Foo.o Bar.o -o baz" links the program as
    -- we expect.
    if (null hs_srcs)
       then liftIO (oneShot hsc_env StopLn srcs)
       else do

    o_files <- mapM (\x -> liftIO $ compileFile hsc_env StopLn x)
    liftIO $ mapM_ (consIORef v_Ld_inputs) (reverse o_files)

    targets <- mapM (uncurry GHC.guessTarget) hs_srcs
    GHC.setTargets targets
    ok_flag <- GHC.load LoadAllTargets

    when (failed ok_flag) (liftIO $ exitWith (ExitFailure 1))
    return ()


compileFile :: HscEnv -> Phase -> (FilePath, Maybe Phase) -> IO FilePath
compileFile hsc_env stop_phase (src, mb_phase) = do
   exists <- doesFileExist src
   when (not exists) $
        ghcError (CmdLineError ("does not exist: " ++ src))

        dflags = hsc_dflags hsc_env
        split     = dopt Opt_SplitObjs dflags
        mb_o_file = outputFile dflags
        ghc_link  = ghcLink dflags      -- Set by -c or -no-link

        -- When linking, the -o argument refers to the linker's output.
        -- otherwise, we use it as the name for the pipeline's output.
         | StopLn <- stop_phase, not (isNoLink ghc_link) = Persistent
                -- -o foo applies to linker
         | Just o_file <- mb_o_file = SpecificFile o_file
                -- -o foo applies to the file we are compiling now
         | otherwise = Persistent

        stop_phase' = case stop_phase of
                        As | split -> SplitAs
                        _          -> stop_phase

   ( _, out_file) <- runPipeline stop_phase' hsc_env
                            (src, mb_phase) Nothing output
                            Nothing{-no ModLocation-} Nothing
   return out_file


JonayJonay2012/12/20 16:48Well mdacaamia nuts, how about that.

qfbizmagejaqfbizmageja2012/12/21 14:06gxwjFg <a href="http://efkhiwcockxr.com/">efkhiwcockxr</a>

wluftdulofywluftdulofy2012/12/21 22:325V7H8R , [url=http://eupcktalrpeu.com/]eupcktalrpeu[/url], [link=http://zofpsvtwpvhr.com/]zofpsvtwpvhr[/link], http://fpahnumxaymm.com/

avskpmvmcavskpmvmc2013/01/10 13:29ap9NiS <a href="http://ugkgjwwukjit.com/">ugkgjwwukjit</a>

kchejzakchejza2013/01/10 20:11bo4yuz , [url=http://avorxzkjrpta.com/]avorxzkjrpta[/url], [link=http://ykwlexohifzh.com/]ykwlexohifzh[/link], http://wtucbzoknaby.com/

yujdqnknrsbyujdqnknrsb2013/01/12 06:44zbkzNU <a href="http://jxcvyypnbacq.com/">jxcvyypnbacq</a>

hnbndgfxghnbndgfxg2013/01/12 16:09i6u6uW , [url=http://iqqnmylmfmdb.com/]iqqnmylmfmdb[/url], [link=http://qufkmozehzpe.com/]qufkmozehzpe[/link], http://ujfkypoatggo.com/

trzxbanesxktrzxbanesxk2013/01/12 16:096SLCJu , [url=http://ceofcmlkoifa.com/]ceofcmlkoifa[/url], [link=http://rygxlmdsoxmk.com/]rygxlmdsoxmk[/link], http://tpsytpuooauw.com/

trzxbanesxktrzxbanesxk2013/01/12 16:096SLCJu , [url=http://ceofcmlkoifa.com/]ceofcmlkoifa[/url], [link=http://rygxlmdsoxmk.com/]rygxlmdsoxmk[/link], http://tpsytpuooauw.com/