X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=utils%2Fext-core%2FSetup.lhs;fp=utils%2Fext-core%2FSetup.lhs;h=0000000000000000000000000000000000000000;hb=0434f5bf9a2712a99e9e6c99d67991a3f09af91d;hp=35661d4b2a4c4e92aa23b539bd0af39326b32446;hpb=e6232609a0b08ff7136a479f2e2d7d2be5040b1d;p=ghc-hetmet.git diff --git a/utils/ext-core/Setup.lhs b/utils/ext-core/Setup.lhs deleted file mode 100644 index 35661d4..0000000 --- a/utils/ext-core/Setup.lhs +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env runhaskell -\begin{code} -{-# OPTIONS -Wall -cpp #-} - -import Control.Monad -import Distribution.PackageDescription -import Distribution.Simple -import Distribution.Simple.LocalBuildInfo -import Distribution.Simple.Utils -import System.Cmd -import System.FilePath -import System.Exit -import System.Directory -import Control.Exception - -main :: IO () -main = do - let hooks = simpleUserHooks { - buildHook = build_primitive_sources - $ buildHook simpleUserHooks - } - defaultMainWithHooks hooks -\end{code} - -Mostly snarfed from ghc-prim's Setup.hs. - -\begin{code} -type Hook a = PackageDescription -> LocalBuildInfo -> UserHooks -> a -> IO () - - --- Hack: If PrimEnv.hs exists *and* genprimopcode or --- primops.txt doesn't exist, don't rebuild PrimEnv.hs - -build_primitive_sources :: Hook a -> Hook a -build_primitive_sources f pd lbi uhs x - = do when (compilerFlavor (compiler lbi) == GHC) $ do - let genprimopcode = joinPath ["..", "..", "utils", - "genprimopcode", "genprimopcode"] - primops = joinPath ["..", "..", "compiler", "prelude", - "primops.txt"] - primhs = joinPath ["Language", "Core", "PrimEnv.hs"] - primhs_tmp = addExtension primhs "tmp" - primEnvExists <- doesFileExist primhs - genprimopcodeExists <- doesFileExist genprimopcode - primopsExists <- doesFileExist primops - unless (primEnvExists && not genprimopcodeExists && not primopsExists) $ do - maybeExit $ system (genprimopcode ++ " --make-ext-core-source < " - ++ primops ++ " > " ++ primhs_tmp) - maybeUpdateFile primhs_tmp primhs - maybeExit $ system ("make -C lib/GHC_ExtCore") - f pd lbi uhs x - --- Replace a file only if the new version is different from the old. --- This prevents make from doing unnecessary work after we run 'setup makefile' -maybeUpdateFile :: FilePath -> FilePath -> IO () -maybeUpdateFile source target = do - r <- rawSystem "cmp" ["-s" {-quiet-}, source, target] - case r of - ExitSuccess -> removeFile source - ExitFailure _ -> do -#if __GLASGOW_HASKELL__ >= 610 - (try :: IO () -> IO (Either IOException ())) -#else - try -#endif - (removeFile target) - renameFile source target -\end{code} \ No newline at end of file