Add new builder HsCpp.
authorAndrey Mokhov <andrey.mokhov@gmail.com>
Thu, 24 Sep 2015 11:44:38 +0000 (12:44 +0100)
committerAndrey Mokhov <andrey.mokhov@gmail.com>
Thu, 24 Sep 2015 11:44:38 +0000 (12:44 +0100)
cfg/system.config.in
src/Builder.hs
src/Rules/Actions.hs
src/Settings/Args.hs
src/Settings/Builders/GhcCabal.hs
src/Settings/Builders/HsCpp.hs [new file with mode: 0644]
src/Settings/Builders/Hsc2Hs.hs

index 87d2b93..e85788b 100644 (file)
@@ -23,6 +23,8 @@ hsc2hs         = @hardtop@/inplace/bin/hsc2hs
 \r
 genprimopcode  = @hardtop@/inplace/bin/genprimopcode\r
 \r
+hs-cpp         = @HaskellCPPCmd@ @HaskellCPPArgs@\r
+\r
 unlit          = @hardtop@/inplace/lib/unlit\r
 ghc-split      = @hardtop@/inplace/lib/ghc-split\r
 \r
index a6521a1..e1c69be 100644 (file)
@@ -30,6 +30,7 @@ data Builder = Alex
              | Haddock
              | Happy
              | HsColour
+             | HsCpp
              | Hsc2Hs
              | Ld
              | Unlit
@@ -58,6 +59,7 @@ builderKey builder = case builder of
     Haddock          -> "haddock"
     HsColour         -> "hscolour"
     Hsc2Hs           -> "hsc2hs"
+    HsCpp            -> "hs-cpp"
     Ld               -> "ld"
     Unlit            -> "unlit"
 
index 1e0472a..8214112 100644 (file)
@@ -32,6 +32,11 @@ buildWithResources rs target = do
                 forM_ (chunksOfSize maxChunk remainingArgs) $ \argsChunk ->
                     unit . cmd [path] $ persistentArgs ++ argsChunk
 
+            HsCpp -> do
+                let file = head $ Target.files target  -- TODO: ugly
+                Stdout output <- cmd [path] argList
+                writeFileChanged file output
+
             GenPrimopCode -> do
                 let src  = head $ Target.sources target -- TODO: ugly
                     file = head $ Target.files   target
index 349668a..231f5ed 100644 (file)
@@ -11,6 +11,7 @@ import Settings.Builders.GhcPkg
 import Settings.Builders.Haddock
 import Settings.Builders.Happy
 import Settings.Builders.Hsc2Hs
+import Settings.Builders.HsCpp
 import Settings.Builders.Ld
 import Settings.User
 
@@ -41,4 +42,5 @@ defaultArgs = mconcat
     , haddockArgs
     , happyArgs
     , hsc2HsArgs
+    , hsCppArgs
     , ldArgs ]
index 54452d8..b68da27 100644 (file)
@@ -1,6 +1,6 @@
 module Settings.Builders.GhcCabal (
     cabalArgs, ghcCabalHsColourArgs, bootPackageDbArgs, customPackageArgs,
-    ccArgs, ccWarnings, argStagedSettingList
+    ccArgs, cppArgs, ccWarnings, argStagedSettingList
     ) where
 
 import Expression
diff --git a/src/Settings/Builders/HsCpp.hs b/src/Settings/Builders/HsCpp.hs
new file mode 100644 (file)
index 0000000..da104cc
--- /dev/null
@@ -0,0 +1,17 @@
+module Settings.Builders.HsCpp (hsCppArgs) where
+
+import Expression
+import Predicates (builder)
+import Settings.Builders.GhcCabal
+
+-- TODO: why process the result with grep -v '^#pragma GCC'? No such lines!
+hsCppArgs :: Args
+hsCppArgs = builder HsCpp ? do
+    stage <- getStage
+    src   <- getSource
+    mconcat [ arg "-P"
+            , cppArgs
+            , arg $ "-Icompiler/stage" ++ show stage
+            , arg "-x"
+            , arg "c"
+            , arg src ]
index 7dfe286..dcf44fc 100644 (file)
@@ -4,7 +4,7 @@ import Expression
 import Oracles
 import Predicates (builder, stage0, notStage0)
 import Settings
-import Settings.Builders.GhcCabal
+import Settings.Builders.GhcCabal hiding (cppArgs)
 
 hsc2HsArgs :: Args
 hsc2HsArgs = builder Hsc2Hs ? do