From a325832d82be14b4ca7be2baa2a943f79629b194 Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Sun, 13 Mar 2011 13:12:18 +0000 Subject: simplified Setup.hs --- Config.hs | 26 +++++++++++--------------- Setup.lhs | 39 ++++++++------------------------------- hmatrix.cabal | 1 - 3 files changed, 19 insertions(+), 47 deletions(-) diff --git a/Config.hs b/Config.hs index 8810bec..3e83eff 100644 --- a/Config.hs +++ b/Config.hs @@ -96,13 +96,9 @@ getUserLink = concatMap (g . drop (length linkop)) . filter (isPrefixOf linkop) cs ',' = ' ' cs x = x -config = do - info <- maybeGetPersistBuildConfig "dist" - case info of - Nothing -> putStrLn "Please run \"cabal clean\" first." >> exitFailure - Just bInfo -> mainOk bInfo - -mainOk bInfo = do +config :: LocalBuildInfo -> IO HookedBuildInfo + +config bInfo = do putStr "Checking foreign libraries..." args <- getArgs @@ -123,6 +119,7 @@ mainOk bInfo = do createDirectoryIfMissing True $ buildDir bInfo r <- try bInfo buildInfo base fwks fullOpts + case r of Nothing -> do putStrLn " FAIL" @@ -132,14 +129,13 @@ mainOk bInfo = do else putStrLn " *** Sorry, I can't link GSL." putStrLn " *** Please make sure that the appropriate -dev packages are installed." putStrLn " *** You can also specify the required libraries using" - putStrLn " *** cabal install hmatrix --configure-option=link:lib1,lib2,lib3,etc." - writeFile "hmatrix.buildinfo" ("buildable: False\n") + putStrLn " *** cabal install hmatrix --configure-option=link:lib1,lib2,lib3,etc." + return (Just emptyBuildInfo { buildable = False }, []) Just ops -> do - putStrLn " OK" + putStrLn $ " OK " ++ ops g <- checkCommand $ gsl112 bInfo buildInfo - writeFile "hmatrix.buildinfo" $ "extra-libraries: " ++ - ops ++ "\n" ++ - if g - then "" - else "cc-options: -DGSL110\n" + let hbi = if g + then emptyBuildInfo { extraLibs = words ops} + else emptyBuildInfo { extraLibs = words ops, ccOptions = ["-DGSL110"]} + return (Just hbi, []) diff --git a/Setup.lhs b/Setup.lhs index 17efee4..ba435f0 100644 --- a/Setup.lhs +++ b/Setup.lhs @@ -1,43 +1,20 @@ #! /usr/bin/env runhaskell > import Distribution.Simple -> import System.Process(system) -> -> import Config(config) -> > import Distribution.Simple.Setup > import Distribution.PackageDescription > import Distribution.Simple.LocalBuildInfo -> import Distribution.Simple.Command -> import Distribution.PackageDescription.Parse -> import Distribution.Simple.Utils(info) -> import Distribution.Verbosity - -> main = do -> defaultMainWithHooks autoconfUserHooks { -> runTests = t, -> postConf = modifiedPostConf } -> where modifiedPostConf :: Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO () -> modifiedPostConf args flags pkg_descr lbi -> = do let verbosity = fromFlag (configVerbosity flags) -> noExtraFlags args -> -> config -> -> pbi <- getHookedBuildInfo verbosity -> let pkg_descr' = updatePackageDescription pbi pkg_descr -> postConf simpleUserHooks args flags pkg_descr' lbi +> import System.Process(system) +> import Config(config) -> getHookedBuildInfo :: Verbosity -> IO HookedBuildInfo -> getHookedBuildInfo verbosity = do -> maybe_infoFile <- defaultHookedPackageDesc -> case maybe_infoFile of -> Nothing -> return emptyHookedBuildInfo -> Just infoFile -> do -> info verbosity $ "Reading parameters from " ++ infoFile -> readHookedBuildInfo verbosity infoFile +> main = defaultMainWithHooks simpleUserHooks { confHook = c, runTests = t } +> c x y = do +> binfo <- confHook simpleUserHooks x y +> pbi <- config binfo +> let pkg_descr = localPkgDescr binfo +> return $ binfo { localPkgDescr = updatePackageDescription pbi pkg_descr } > t _ _ _ _ = system ( "runhaskell examples/tests.hs") >> return() diff --git a/hmatrix.cabal b/hmatrix.cabal index 10c8173..3048217 100644 --- a/hmatrix.cabal +++ b/hmatrix.cabal @@ -29,7 +29,6 @@ build-type: Custom extra-source-files: lib/Numeric/LinearAlgebra/Tests/quickCheckCompat.h Config.hs THANKS INSTALL CHANGES -extra-tmp-files: hmatrix.buildinfo extra-source-files: examples/tests.hs examples/deriv.hs -- cgit v1.2.3