Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add pre-compilation to the build step (Setup.hs)

  • Loading branch information...
commit f84ba7f18c24e8641db864e588d3a912756c8a15 1 parent e9c5e56
jeanphilippe.bernardy@gmail.com authored
Showing with 36 additions and 21 deletions.
  1. +2 −13 Makefile
  2. +34 −8 Setup.hs
View
15 Makefile
@@ -9,10 +9,10 @@ runtime-config:
mkdir -p $(HOME)/.yi
cp examples/*.hs $(HOME)/.yi
-emacs: $(flavour)-static install
+emacs: install
$(prefix)/bin/yi --as=emacs
-vim: $(flavour)-static install
+vim: install
$(prefix)/bin/yi --as=vim
distclean: clean
@@ -23,17 +23,6 @@ maintainer-clean: distclean
rm -f configure cbits/config.h.in
rm -rf autom4te.cache
-yi-vty-static:
- ghc -DGHC_LIBDIR=\"dummy\" -odir vty -hidir vty -ivty -fglasgow-exts -package ghc -cpp --make Static.hs
-
-yi-gtk-static:
- ghc -DGHC_LIBDIR=\"dummy\" -odir gtk -hidir gtk -igtk -fglasgow-exts -package ghc -cpp --make Static.hs
-
-
-interactive:
- ghci -fglasgow-exts -package ghc -cpp -hidirdist/build/yi/yi-tmp/ -odirdist/build/yi/yi-tmp/ -i/home/jp/.yi ./dist/build/yi/yi-tmp/cbits/YiUtils.o Yi/Yi.hs
-
-
yi-lib:
make -C packages/yi-lib install
View
42 Setup.hs
@@ -1,16 +1,18 @@
#!/usr/bin/env runhaskell
module Main where
-import Distribution.Simple
-import Distribution.Setup
+import Control.Monad(when, filterM, unless)
+import Data.List
+import Data.Maybe
import Distribution.PackageDescription
+import Distribution.Setup
+import Distribution.Simple
import Distribution.Simple.LocalBuildInfo
+import Distribution.Simple.Utils
+import System.Exit
+import System.IO
import System.Info
import System.Process
-import Data.List
-import System.IO
-import System.Exit
-import Data.Maybe
main :: IO ()
main = defaultMainWithHooks defaultUserHooks
@@ -27,11 +29,35 @@ mkOpt (name,def) = "-D"++name++"="++def
bHook :: PackageDescription -> LocalBuildInfo -> Maybe UserHooks -> BuildFlags -> IO ()
bHook pd lbi hooks bfs = do
- libdir <- getLibDir (compilerPath . compiler $ lbi)
+ let ghc = compilerPath . compiler $ lbi
+ libdir <- getLibDir ghc
let pbi = (Nothing,
[("yi", emptyBuildInfo
{ options = [(GHC,[mkOpt ("GHC_LIBDIR",show libdir)])] })])
pd' = updatePackageDescription pbi pd
buildHook defaultUserHooks pd' lbi hooks bfs
-
+ let preCompile flavour = do
+ putStrLn ("Precompiling " ++ flavour)
+ exitCode <- rawSystemVerbose 0 ghc $ precompArgs flavour
+ when (exitCode /= ExitSuccess) $
+ putStrLn $ "Precompile of " ++ flavour ++ " failed. Install the corresponding library if needed."
+ return exitCode
+ exitCodes <- mapM preCompile ["vty", "gtk"]
+ let exitCode = foldr1 optimistic exitCodes
+ unless (exitCode == ExitSuccess) $ exitWith exitCode
+
+optimistic ExitSuccess x = ExitSuccess
+optimistic x ExitSuccess = ExitSuccess
+optimistic (ExitFailure x) (ExitFailure y) = ExitFailure (min x y)
+
+precompArgs flavour = ["-DGHC_LIBDIR=\"dummy\"",
+ "-i" ++ flavour,
+ "-odir " ++ flavour,
+ "-hidir "++flavour,
+ "-fglasgow-exts",
+ "-package ghc",
+ "-cpp",
+ "--make","Static.hs"]
+ -- please note: These args must match the args given in Yi.Boot
+ -- TODO: factorize.
Please sign in to comment.
Something went wrong with that request. Please try again.