[commit: ghc] wip/nfs-locking: Add buildProgram rule. (3ceca89)

git at git.haskell.org git at git.haskell.org
Thu Oct 26 23:23:08 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/nfs-locking
Link       : http://ghc.haskell.org/trac/ghc/changeset/3ceca89902487a91a337e5a75f7f1de8b5bd4add/ghc

>---------------------------------------------------------------

commit 3ceca89902487a91a337e5a75f7f1de8b5bd4add
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Mon Dec 7 01:44:10 2015 +0000

    Add buildProgram rule.


>---------------------------------------------------------------

3ceca89902487a91a337e5a75f7f1de8b5bd4add
 src/Rules/Package.hs |  4 +++-
 src/Rules/Program.hs | 29 +++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/src/Rules/Package.hs b/src/Rules/Package.hs
index 9da4f8b..7a7d854 100644
--- a/src/Rules/Package.hs
+++ b/src/Rules/Package.hs
@@ -7,6 +7,7 @@ import Rules.Dependencies
 import Rules.Documentation
 import Rules.Generate
 import Rules.Library
+import Rules.Program
 import Rules.Resources
 import Target
 
@@ -17,4 +18,5 @@ buildPackage = mconcat
     , generatePackageCode
     , compilePackage
     , buildPackageLibrary
-    , buildPackageDocumentation ]
+    , buildPackageDocumentation
+    , buildProgram ]
diff --git a/src/Rules/Program.hs b/src/Rules/Program.hs
new file mode 100644
index 0000000..14cbea0
--- /dev/null
+++ b/src/Rules/Program.hs
@@ -0,0 +1,29 @@
+module Rules.Program (buildProgram) where
+
+import Expression hiding (splitPath)
+import Oracles
+import Rules.Actions
+import Rules.Library
+import Rules.Resources
+import Settings
+
+buildProgram :: Resources -> PartialTarget -> Rules ()
+buildProgram _ target @ (PartialTarget stage pkg) = do
+    let path      = targetPath stage pkg
+        buildPath = path -/- "build"
+        program   = programPath stage pkg
+
+    (\f -> program == Just f) ?> \bin -> do
+        cSrcs <- cSources target -- TODO: remove code duplication (Library.hs)
+        hSrcs <- hSources target
+        let cObjs = [ buildPath -/- src -<.> osuf vanilla | src <- cSrcs ]
+            hObjs = [ buildPath -/- src  <.> osuf vanilla | src <- hSrcs ]
+            objs  = cObjs ++ hObjs
+        need objs
+        build $ fullTargetWithWay target (Ghc stage) vanilla objs [bin]
+        synopsis <- interpretPartial target $ getPkgData Synopsis
+        putSuccess $ "/--------\n| Successfully built program '"
+            ++ pkgName pkg ++ "' (stage " ++ show stage ++ ")."
+        putSuccess $ "| Executable: " ++ bin
+        putSuccess $ "| Package synopsis: "
+            ++ dropWhileEnd isPunctuation synopsis ++ "." ++ "\n\\--------"



More information about the ghc-commits mailing list