summaryrefslogtreecommitdiff
path: root/hadrian/src/Rules/Compile.hs
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-01-08 11:25:48 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-02-05 19:10:04 -0500
commitc7922ced8f89e9c9ab4dae152a5d964aa8628858 (patch)
tree428b9ef54c74bbf164a3cefb6a691e014e8d04e1 /hadrian/src/Rules/Compile.hs
parent441724e30d19e1abab4a9b04e270837bfb2c49e6 (diff)
downloadhaskell-c7922ced8f89e9c9ab4dae152a5d964aa8628858.tar.gz
Hadrian: Add support for packages with C++ files
Diffstat (limited to 'hadrian/src/Rules/Compile.hs')
-rw-r--r--hadrian/src/Rules/Compile.hs8
1 files changed, 7 insertions, 1 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]