X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=utils%2Fext-core%2FSetup.lhs;h=f7706b8a4cd7e6b06ff783d74ef97a73d4e45510;hp=bdcd784ca0a3cc3967c5f945ba5ba3eb8171413b;hb=460784c371813cb92eac71df403fe34258c8f3b8;hpb=b84b5969798530dbf5be9b8bb795b77e5dfbf042 diff --git a/utils/ext-core/Setup.lhs b/utils/ext-core/Setup.lhs index bdcd784..f7706b8 100644 --- a/utils/ext-core/Setup.lhs +++ b/utils/ext-core/Setup.lhs @@ -28,6 +28,10 @@ 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 @@ -37,10 +41,14 @@ build_primitive_sources f pd lbi uhs x "primops.txt"] primhs = joinPath ["Language", "Core", "PrimEnv.hs"] primhs_tmp = addExtension primhs "tmp" - maybeExit $ system (genprimopcode ++ " --make-ext-core-source < " + 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") + 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.