diff options
author | Andrey Mokhov <andrey.mokhov@gmail.com> | 2019-02-09 02:19:46 +0000 |
---|---|---|
committer | Andrey Mokhov <andrey.mokhov@gmail.com> | 2019-02-09 02:21:59 +0000 |
commit | 5498f16ec5e7cae4c3000a73c7eddf7a85f7c77f (patch) | |
tree | 2558fd18d0dff4fa2baa210530b9d190836072e1 | |
parent | 0ba321efc0729018bb4dfcfd5afaa806675ccff1 (diff) | |
download | haskell-5498f16ec5e7cae4c3000a73c7eddf7a85f7c77f.tar.gz |
Make sure autogen files have been generated before scanning sources.
Part of https://gitlab.haskell.org/ghc/ghc/merge_requests/317.
-rw-r--r-- | hadrian/src/Hadrian/Haskell/Cabal/Parse.hs | 9 | ||||
-rw-r--r-- | hadrian/src/Oracles/ModuleFiles.hs | 1 | ||||
-rw-r--r-- | hadrian/src/Packages.hs | 12 | ||||
-rw-r--r-- | hadrian/src/Rules/Gmp.hs | 7 | ||||
-rw-r--r-- | hadrian/src/Rules/Register.hs | 5 |
5 files changed, 18 insertions, 16 deletions
diff --git a/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs b/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs index fd1cd9c824..7e78aa2c05 100644 --- a/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs +++ b/hadrian/src/Hadrian/Haskell/Cabal/Parse.hs @@ -107,8 +107,7 @@ biModules pd = go [ comp | comp@(bi,_,_) <- -- the package the 'Context' points to. configurePackage :: Context -> Action () configurePackage context@Context {..} = do - putLoud $ "| Configure package " ++ quote (pkgName package) - + putProgressInfo $ "| Configure package " ++ quote (pkgName package) gpd <- pkgGenericDescription package depPkgs <- packageDependencies <$> readPackageData package @@ -155,7 +154,7 @@ configurePackage context@Context {..} = do -- corresponding to the 'Stage' of the 'Context'. copyPackage :: Context -> Action () copyPackage context@Context {..} = do - putLoud $ "| Copy package " ++ quote (pkgName package) + putProgressInfo $ "| Copy package " ++ quote (pkgName package) gpd <- pkgGenericDescription package ctxPath <- Context.contextPath context pkgDbPath <- packageDbPath stage @@ -167,7 +166,7 @@ copyPackage context@Context {..} = do -- | Register the 'Package' of a given 'Context' into the package database. registerPackage :: Context -> Action () registerPackage context@Context {..} = do - putLoud $ "| Register package " ++ quote (pkgName package) + putProgressInfo $ "| Register package " ++ quote (pkgName package) ctxPath <- Context.contextPath context gpd <- pkgGenericDescription package verbosity <- getVerbosity @@ -289,7 +288,7 @@ buildAutogenFiles :: Context -> Action () buildAutogenFiles context = do cPath <- Context.contextPath context setupConfig <- pkgSetupConfigFile context - need [setupConfig] + need [setupConfig] -- This triggers 'configurePackage' pd <- packageDescription <$> readContextData context -- Note: the @cPath@ is ignored. The path that's used is the 'buildDir' path -- from the local build info @lbi@. diff --git a/hadrian/src/Oracles/ModuleFiles.hs b/hadrian/src/Oracles/ModuleFiles.hs index 0ec157380f..d2f0299563 100644 --- a/hadrian/src/Oracles/ModuleFiles.hs +++ b/hadrian/src/Oracles/ModuleFiles.hs @@ -131,6 +131,7 @@ moduleFilesOracle :: Rules () moduleFilesOracle = void $ do void . addOracleCache $ \(ModuleFiles (stage, package)) -> do let context = vanillaContext stage package + ensureConfigured context srcDirs <- interpretInContext context (getContextData PD.srcDirs) mainIs <- interpretInContext context (getContextData PD.mainIs) let removeMain = case mainIs of diff --git a/hadrian/src/Packages.hs b/hadrian/src/Packages.hs index 9a70420eda..6104148d37 100644 --- a/hadrian/src/Packages.hs +++ b/hadrian/src/Packages.hs @@ -13,7 +13,7 @@ module Packages ( -- * Package information programName, nonHsMainPackage, autogenPath, programPath, timeoutPath, rtsContext, rtsBuildPath, libffiContext, libffiBuildPath, libffiLibraryName, - generatedGhcDependencies + generatedGhcDependencies, ensureConfigured ) where import Hadrian.Package @@ -184,6 +184,16 @@ autogenPath context@Context {..} where autogen dir = contextPath context <&> (-/- dir -/- "autogen") +-- | Make sure a given context has already been fully configured. The +-- implementation simply calls 'need' on the context's @autogen/cabal_macros.h@ +-- file, which triggers 'configurePackage' and 'buildAutogenFiles'. Why this +-- indirection? Going via @autogen/cabal_macros.h@ allows us to cache the +-- configuration steps, i.e. not to repeat them if they have already been done. +ensureConfigured :: Context -> Action () +ensureConfigured context = do + autogen <- autogenPath context + need [autogen -/- "cabal_macros.h"] + -- | RTS is considered a Stage1 package. This determines RTS build directory. rtsContext :: Stage -> Context rtsContext stage = vanillaContext stage rts diff --git a/hadrian/src/Rules/Gmp.hs b/hadrian/src/Rules/Gmp.hs index 9b56a3e4fd..a78170cf6a 100644 --- a/hadrian/src/Rules/Gmp.hs +++ b/hadrian/src/Rules/Gmp.hs @@ -92,12 +92,7 @@ gmpRules = do copyFile (gmpPath -/- gmpLibraryH) -- This file is created when 'integerGmp' is configured. - gmpPath -/- "config.mk" %> \_ -> do - -- Calling 'need' on @setup-config@ triggers 'configurePackage'. Why - -- this indirection? Going via @setup-config@ allows us to cache the - -- configuration step, i.e. not to repeat it if it's already been done. - setupConfig <- pkgSetupConfigFile gmpContext - need [setupConfig] + gmpPath -/- "config.mk" %> \_ -> ensureConfigured gmpContext -- Run GMP's configure script gmpPath -/- "Makefile" %> \mk -> do diff --git a/hadrian/src/Rules/Register.hs b/hadrian/src/Rules/Register.hs index 625fca8d43..d215938385 100644 --- a/hadrian/src/Rules/Register.hs +++ b/hadrian/src/Rules/Register.hs @@ -92,10 +92,7 @@ registerPackageRules rs stage = do buildConf :: [(Resource, Int)] -> Context -> FilePath -> Action () buildConf _ context@Context {..} conf = do depPkgIds <- cabalDependencies context - - -- Calling 'need' on @setupConfig@, triggers the package configuration. - setupConfig <- pkgSetupConfigFile context - need [setupConfig] + ensureConfigured context need =<< mapM (\pkgId -> packageDbPath stage <&> (-/- pkgId <.> "conf")) depPkgIds ways <- interpretInContext context (getLibraryWays <> if package == rts then getRtsWays else mempty) |