diff options
Diffstat (limited to 'hadrian/src/Rules')
-rw-r--r-- | hadrian/src/Rules/Compile.hs | 8 | ||||
-rw-r--r-- | hadrian/src/Rules/Library.hs | 9 | ||||
-rw-r--r-- | hadrian/src/Rules/Program.hs | 4 |
3 files changed, 18 insertions, 3 deletions
diff --git a/hadrian/src/Rules/Compile.hs b/hadrian/src/Rules/Compile.hs index 12a8707f31..0efcea9474 100644 --- a/hadrian/src/Rules/Compile.hs +++ b/hadrian/src/Rules/Compile.hs @@ -39,6 +39,9 @@ compilePackage rs = do [ root -/- "**/build/cmm/**/*." ++ wayPat ++ "o" | wayPat <- wayPats] |%> compileNonHsObject rs Cmm + [ root -/- "**/build/cpp/**/*." ++ wayPat ++ "o" + | wayPat <- wayPats] |%> compileNonHsObject rs Cxx + [ root -/- "**/build/s/**/*." ++ wayPat ++ "o" | wayPat <- wayPats] |%> compileNonHsObject rs Asm @@ -112,12 +115,13 @@ compilePackage rs = do -} -- | Non Haskell source languages that we compile to get object files. -data SourceLang = Asm | C | Cmm deriving (Eq, Show) +data SourceLang = Asm | C | Cmm | Cxx deriving (Eq, Show) parseSourceLang :: Parsec.Parsec String () SourceLang parseSourceLang = Parsec.choice [ Parsec.char 'c' *> Parsec.choice [ Parsec.string "mm" *> pure Cmm + , Parsec.string "pp" *> pure Cxx , pure C ] , Parsec.char 's' *> pure Asm @@ -227,11 +231,13 @@ compileNonHsObject rs lang path = do ctx = objectContext b builder = case lang of C -> Ghc CompileCWithGhc + Cxx-> Ghc CompileCppWithGhc _ -> Ghc CompileHs src <- case lang of Asm -> obj2src "S" (const False) ctx path C -> obj2src "c" (const False) ctx path Cmm -> obj2src "cmm" isGeneratedCmmFile ctx path + Cxx -> obj2src "cpp" (const False) ctx path need [src] needDependencies ctx src (path <.> "d") buildWithResources rs $ target ctx (builder stage) [src] [path] diff --git a/hadrian/src/Rules/Library.hs b/hadrian/src/Rules/Library.hs index 4b9d7d6235..c67346f5d6 100644 --- a/hadrian/src/Rules/Library.hs +++ b/hadrian/src/Rules/Library.hs @@ -117,10 +117,17 @@ nonHsObjects context = do asmSrcs <- interpretInContext context (getContextData asmSrcs) asmObjs <- mapM (objectPath context) asmSrcs cObjs <- cObjects context + cxxObjs <- cxxObjects context cmmSrcs <- interpretInContext context (getContextData cmmSrcs) cmmObjs <- mapM (objectPath context) cmmSrcs eObjs <- extraObjects context - return $ asmObjs ++ cObjs ++ cmmObjs ++ eObjs + return $ asmObjs ++ cObjs ++ cxxObjs ++ cmmObjs ++ eObjs + +-- | Return all the Cxx object files needed to build the given library context. +cxxObjects :: Context -> Action [FilePath] +cxxObjects context = do + srcs <- interpretInContext context (getContextData cxxSrcs) + mapM (objectPath context) srcs -- | Return all the C object files needed to build the given library context. cObjects :: Context -> Action [FilePath] diff --git a/hadrian/src/Rules/Program.hs b/hadrian/src/Rules/Program.hs index df542c0f1e..04a3bf3aaa 100644 --- a/hadrian/src/Rules/Program.hs +++ b/hadrian/src/Rules/Program.hs @@ -117,9 +117,11 @@ buildBinary rs bin context@Context {..} = do asmSrcs <- interpretInContext context (getContextData asmSrcs) asmObjs <- mapM (objectPath context) asmSrcs cSrcs <- interpretInContext context (getContextData cSrcs) + cxxSrcs <- interpretInContext context (getContextData cxxSrcs) cObjs <- mapM (objectPath context) cSrcs + cxxObjs <- mapM (objectPath context) cxxSrcs hsObjs <- hsObjects context - let binDeps = asmObjs ++ cObjs ++ hsObjs + let binDeps = asmObjs ++ cObjs ++ cxxObjs ++ hsObjs need binDeps buildWithResources rs $ target context (Ghc LinkHs stage) binDeps [bin] synopsis <- pkgSynopsis package |