Build Hadrian in _build.
authorAndrey Mokhov <andrey.mokhov@gmail.com>
Sat, 30 Apr 2016 01:40:55 +0000 (02:40 +0100)
committerAndrey Mokhov <andrey.mokhov@gmail.com>
Sat, 30 Apr 2016 01:40:55 +0000 (02:40 +0100)
build.bat
build.sh
src/Base.hs
src/Rules/Clean.hs

index 2f6d4cd..19a2a05 100644 (file)
--- a/build.bat
+++ b/build.bat
@@ -1,24 +1,24 @@
 @cd %~dp0\r
-@mkdir .shake 2> nul\r
+@mkdir ../_build 2> nul\r
 \r
-@set ghcArgs=--make                   ^\r
-             -Wall                    ^\r
-             -fno-warn-name-shadowing ^\r
-             -XRecordWildCards        ^\r
-             src/Main.hs              ^\r
-             -threaded                ^\r
-             -isrc                    ^\r
-             -rtsopts                 ^\r
-             -with-rtsopts=-I0        ^\r
-             -outputdir=.shake        ^\r
-             -j                       ^\r
-             -O                       ^\r
-             -o .shake/build\r
+@set ghcArgs=--make                       ^\r
+             -Wall                        ^\r
+             -fno-warn-name-shadowing     ^\r
+             -XRecordWildCards            ^\r
+             src/Main.hs                  ^\r
+             -threaded                    ^\r
+             -isrc                        ^\r
+             -rtsopts                     ^\r
+             -with-rtsopts=-I0            ^\r
+             -outputdir=../_build/hadrian ^\r
+             -j                           ^\r
+             -O                           ^\r
+             -o ../_build/hadrian\r
 \r
-@set shakeArgs=--lint      ^\r
-               --directory ^\r
-               ".."        ^\r
-               %*\r
+@set hadrianArgs=--lint      ^\r
+                 --directory ^\r
+                 ".."        ^\r
+                 %*\r
 \r
 \r
 @ghc %ghcArgs%\r
@@ -27,4 +27,4 @@
 \r
 @rem Unset GHC_PACKAGE_PATH variable, as otherwise ghc-cabal complains\r
 @set GHC_PACKAGE_PATH=\r
-@.shake\build %shakeArgs%\r
+@..\_build\hadrian %hadrianArgs%\r
index 95de2e6..8b53f81 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -30,22 +30,22 @@ function rl {
 
 root="$(dirname "$(rl "$0")")"
 
-mkdir -p "$root/.shake"
-
-ghc                           \
-    "$root/src/Main.hs"       \
-    -Wall                     \
-    -fno-warn-name-shadowing  \
-    -XRecordWildCards         \
-    -i"$root/src"             \
-    -rtsopts                  \
-    -with-rtsopts=-I0         \
-    -threaded                 \
-    -outputdir="$root/.shake" \
-    -j -O                     \
-    -o "$root/.shake/build"
-
-"$root/.shake/build"       \
+mkdir -p "$root/../_build"
+
+ghc                                      \
+    "$root/src/Main.hs"                  \
+    -Wall                                \
+    -fno-warn-name-shadowing             \
+    -XRecordWildCards                    \
+    -i"$root/src"                        \
+    -rtsopts                             \
+    -with-rtsopts=-I0                    \
+    -threaded                            \
+    -outputdir="$root/../_build/hadrian" \
+    -j -O                                \
+    -o "$root/../_build/hadrian"
+
+"$root/../_build/hadrian"  \
     --lint                 \
     --directory "$root/.." \
     --colour               \
index b94648e..53bb197 100644 (file)
@@ -50,6 +50,7 @@ import System.IO
 shakePath :: FilePath
 shakePath = "hadrian"
 
+-- TODO: Move to buildRootPath.
 shakeFilesPath :: FilePath
 shakeFilesPath = shakePath -/- ".db"
 
index ea1cc37..357ac34 100644 (file)
@@ -9,17 +9,19 @@ import Settings.Paths
 import Settings.User
 import Stage
 
+clean :: FilePath -> Action ()
+clean dir = do
+    putBuild $ "| Remove files in " ++ dir ++ "..."
+    removeDirectoryIfExists dir
+
 cleanRules :: Rules ()
 cleanRules = do
     "clean" ~> do
-        putBuild $ "| Remove files in " ++ buildRootPath ++ "..."
-        liftIO $ removeFiles buildRootPath ["//*"]
-        putBuild $ "| Remove files in " ++ programInplacePath ++ "..."
-        liftIO $ removeFiles programInplacePath ["//*"]
-        putBuild $ "| Remove files in inplace/lib..."
-        liftIO $ removeFiles "inplace/lib" ["//*"]
-        putBuild $ "| Remove files in " ++ derivedConstantsPath ++ "..."
-        liftIO $ removeFiles derivedConstantsPath ["//*"]
+        forM_ [Stage0 ..] $ \stage -> clean (buildRootPath -/- stageString stage)
+        clean (buildRootPath -/- "hadrian")
+        clean programInplacePath
+        clean "inplace/lib"
+        clean derivedConstantsPath
         forM_ includesDependencies $ \file -> do
             putBuild $ "| Remove " ++ file
             removeFileIfExists file