@@ -83,7 +83,7 @@ import Distribution.Simple.Compiler
8383 , compilerFlavor
8484 )
8585import Distribution.Simple.Configure
86- ( configCompilerEx
86+ ( configCompilerEx , localBuildInfoFile , getPersistBuildConfig , writePersistBuildConfig
8787 )
8888import Distribution.Simple.PackageDescription
8989 ( readGenericPackageDescription
@@ -99,10 +99,10 @@ import Distribution.Simple.Program
9999 , getProgramSearchPath
100100 , ghcProgram
101101 , ghcjsProgram
102- , runDbProgramCwd
102+ , runDbProgramCwd , programOverrideEnv , updateProgram
103103 )
104104import Distribution.Simple.Program.Db
105- ( prependProgramSearchPath
105+ ( prependProgramSearchPath , lookupProgramByName , updatePathProgDb
106106 )
107107import Distribution.Simple.Program.Find
108108 ( programSearchPathAsPATHVar
@@ -193,6 +193,7 @@ import Distribution.Utils.NubList
193193 ( toNubListR
194194 )
195195import Distribution.Types.LocalBuildInfo ( LocalBuildInfo )
196+ import qualified Distribution.Types.LocalBuildInfo as LBI
196197import Distribution.Verbosity
197198import Distribution.Client.Errors
198199import qualified Distribution.Client.InLibrary as InLibrary
@@ -204,7 +205,7 @@ import Distribution.Client.SetupHooks.CallHooksExe
204205
205206import Data.List (foldl1' )
206207import Data.Kind ( Type , Constraint )
207- import System.Directory (doesFileExist )
208+ import System.Directory (doesFileExist , removeFile )
208209import System.FilePath ((<.>) , (</>) , takeFileName )
209210import System.IO (Handle , hPutStr )
210211import System.Process (StdStream (.. ))
@@ -634,6 +635,7 @@ setupWrapper verbosity options mpkg cmd getCommonFlags getFlags getExtraArgs wra
634635 NotInLibrary -> Don'tAllowInLibrary
635636 InLibraryArgs {} -> AllowInLibrary
636637 ASetup (setup :: Setup kind ) <- getSetup verbosity options mpkg allowInLibrary
638+ ASetup (setup' :: Setup kind' ) <- getSetup verbosity options mpkg Don'tAllowInLibrary
637639 let version = setupVersion setup
638640 flags = getFlags version
639641 extraArgs = getExtraArgs version
@@ -666,7 +668,48 @@ setupWrapper verbosity options mpkg cmd getCommonFlags getFlags getExtraArgs wra
666668 InLibrary. configure
667669 (InLibrary. libraryConfigureInputsFromElabPackage progDb' elabSharedConfig elabReadyPkg)
668670 flags
669- return $ InLibraryLBI lbi
671+ let mbWorkDir = useWorkingDir options
672+ distPref = useDistPref options
673+ {-
674+ lbiPath = interpretSymbolicPath mbWorkDir $ localBuildInfoFile distPref
675+ removeFile lbiPath
676+ let
677+ notInLibraryMethod' :: kind' ~ GeneralSetup => IO ()
678+ notInLibraryMethod' = runSetupCommand verbosity setup' cmd getCommonFlags flags extraArgs NotInLibrary
679+ runSetup' :: IO ()
680+ runSetup' =
681+ case setupMethod setup' of
682+ InternalMethod -> notInLibraryMethod'
683+ ExternalMethod {} -> notInLibraryMethod'
684+ SelfExecMethod -> notInLibraryMethod'
685+ LibraryMethod -> error "internal error: NotInLibrary argument but getSetup chose InLibrary"
686+ runSetup'
687+ --setupLBI <- getPersistBuildConfig mbWorkDir distPref
688+ --when True $ do
689+ -- putStrLn "SetupWrapper: InLibrary LBI comparison"
690+ -- putStrLn $ unlines
691+ -- [ "extraPathEnv: " ++ show (useExtraPathEnv options)
692+ -- , "extraEnvOverrides: " ++ show (useExtraEnvOverrides options) ]
693+ -- putStrLn $ replicate 80 '='
694+ -- putStrLn "In-library GHC"
695+ -- putStrLn $ show $ lookupProgramByName "ghc" $ LBI.withPrograms lbi
696+ -- putStrLn $ replicate 80 '-'
697+ -- putStrLn "Setup GHC"
698+ -- putStrLn $ show $ lookupProgramByName "ghc" $ LBI.withPrograms setupLBI
699+ -- putStrLn $ replicate 80 '='
700+ -}
701+
702+ let progs0 = LBI. withPrograms lbi
703+ progs1 <- updatePathProgDb verbosity (useExtraEnvOverrides options) progs0
704+ let
705+ lbi' =
706+ lbi
707+ { LBI. withPrograms = progs1
708+ }
709+ -- (When we're comparing in-library and Setup, make sure that
710+ -- the final LBI is the one from in-library.)
711+ writePersistBuildConfig mbWorkDir distPref lbi'
712+ return $ InLibraryLBI lbi'
670713 InLibraryPostConfigureArgs sPhase mbLBI ->
671714 case mbLBI of
672715 NotInLibraryNoLBI ->
@@ -676,6 +719,8 @@ setupWrapper verbosity options mpkg cmd getCommonFlags getFlags getExtraArgs wra
676719 -- LocalBuildInfo (see "whenReconfigure"
677720 -- in Distribution.Client.ProjectBuilding.UnpackedPackage).
678721 InLibraryLBI lbi ->
722+ -- withExtraPathEnv (useExtraPathEnv options) $
723+ -- withEnvOverrides (useExtraEnvOverrides options) $
679724 case sPhase of
680725 SBuildPhase -> InLibrary. build flags lbi
681726 SHaddockPhase -> InLibrary. haddock flags lbi
0 commit comments