From: <kr_...@us...> - 2005-02-01 13:04:19
|
Update of /cvsroot/htoolkit/HSQL/SQLite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26145/SQLite Added Files: SQLite.cabal Setup.lhs Log Message: Add cabalized version of HSQL --- NEW FILE: SQLite.cabal --- name: hsql-sqlite version: 1.5 license: BSD3 author: Krasimir Angelov <ka2...@ya...> category: Database description: SQLite driver for HSQL. exposed-modules:Database.HSQL.SQLite build-depends: base, hsql extensions: ForeignFunctionInterface, CPP extra-libs: sqlite --- NEW FILE: Setup.lhs --- #! runghc \begin{code} import Distribution.PackageDescription import Distribution.Setup import Distribution.Simple import Distribution.Simple.LocalBuildInfo import Distribution.Simple.Utils(rawSystemVerbose) import System.Info import System.Exit import System.Directory import Control.Monad(when) import Control.Exception(try) main = defaultMainWithHooks defaultUserHooks{preConf=preConf, postConf=postConf} where preConf :: [String] -> ConfigFlags -> IO HookedBuildInfo preConf args flags = do try (removeFile "SQLite.buildinfo") return emptyHookedBuildInfo postConf :: [String] -> LocalBuildInfo -> IO ExitCode postConf args localbuildinfo = do testCompileRes <- testForSqlite localbuildinfo 0 case testCompileRes of ExitSuccess -> do message "sqlite library and headers are found" return testCompileRes ExitFailure n -> do message "sqlite library or headers aren't found" message "The package will not be build" let hbi = (Just emptyBuildInfo{buildable=False},[]) writeHookedBuildInfo "SQLite.buildinfo" hbi return testCompileRes \end{code} \begin{code} testForSqlite :: LocalBuildInfo -> Int -> IO ExitCode testForSqlite lbi verbose = do -- create program when (verbose > 0) $ do putStrLn "Test whether compile (test.hs):" putStrLn testProgram writeFile "test.hs" testProgram -- try to compile it let ghcPath = compilerPath (compiler lbi) let ghcArgs = ["test.hs", "-lsqlite", "--make", "-ffi", "-o", "test.bin"] res <- rawSystemVerbose verbose ghcPath ghcArgs try (removeFile "test.hs") try (removeFile "test.hi") try (removeFile "test.o") try (removeFile "test.bin") return res where testProgram = "import Foreign\n" ++ "import Foreign.C\n" ++ "foreign import ccall \"sqlite.h sqlite_open\" sqlite_open :: CString -> CInt -> Ptr CString -> IO (Ptr ())\n"++ "main = return ()" message :: String -> IO () message s = putStrLn $ "configure: " ++ s \end{code} |