@@ -83,7 +83,7 @@ import Distribution.Simple.Compiler
83
83
, compilerFlavor
84
84
)
85
85
import Distribution.Simple.Configure
86
- ( configCompilerEx
86
+ ( configCompilerEx , localBuildInfoFile , getPersistBuildConfig , writePersistBuildConfig
87
87
)
88
88
import Distribution.Simple.PackageDescription
89
89
( readGenericPackageDescription
@@ -99,10 +99,10 @@ import Distribution.Simple.Program
99
99
, getProgramSearchPath
100
100
, ghcProgram
101
101
, ghcjsProgram
102
- , runDbProgramCwd
102
+ , runDbProgramCwd , programOverrideEnv , updateProgram
103
103
)
104
104
import Distribution.Simple.Program.Db
105
- ( prependProgramSearchPath
105
+ ( prependProgramSearchPath , lookupProgramByName , updatePathProgDb
106
106
)
107
107
import Distribution.Simple.Program.Find
108
108
( programSearchPathAsPATHVar
@@ -193,6 +193,7 @@ import Distribution.Utils.NubList
193
193
( toNubListR
194
194
)
195
195
import Distribution.Types.LocalBuildInfo ( LocalBuildInfo )
196
+ import qualified Distribution.Types.LocalBuildInfo as LBI
196
197
import Distribution.Verbosity
197
198
import Distribution.Client.Errors
198
199
import qualified Distribution.Client.InLibrary as InLibrary
@@ -204,7 +205,7 @@ import Distribution.Client.SetupHooks.CallHooksExe
204
205
205
206
import Data.List (foldl1' )
206
207
import Data.Kind ( Type , Constraint )
207
- import System.Directory (doesFileExist )
208
+ import System.Directory (doesFileExist , removeFile )
208
209
import System.FilePath ((<.>) , (</>) , takeFileName )
209
210
import System.IO (Handle , hPutStr )
210
211
import System.Process (StdStream (.. ))
@@ -634,6 +635,7 @@ setupWrapper verbosity options mpkg cmd getCommonFlags getFlags getExtraArgs wra
634
635
NotInLibrary -> Don'tAllowInLibrary
635
636
InLibraryArgs {} -> AllowInLibrary
636
637
ASetup (setup :: Setup kind ) <- getSetup verbosity options mpkg allowInLibrary
638
+ ASetup (setup' :: Setup kind' ) <- getSetup verbosity options mpkg Don'tAllowInLibrary
637
639
let version = setupVersion setup
638
640
flags = getFlags version
639
641
extraArgs = getExtraArgs version
@@ -666,7 +668,48 @@ setupWrapper verbosity options mpkg cmd getCommonFlags getFlags getExtraArgs wra
666
668
InLibrary. configure
667
669
(InLibrary. libraryConfigureInputsFromElabPackage progDb' elabSharedConfig elabReadyPkg)
668
670
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'
670
713
InLibraryPostConfigureArgs sPhase mbLBI ->
671
714
case mbLBI of
672
715
NotInLibraryNoLBI ->
@@ -676,6 +719,8 @@ setupWrapper verbosity options mpkg cmd getCommonFlags getFlags getExtraArgs wra
676
719
-- LocalBuildInfo (see "whenReconfigure"
677
720
-- in Distribution.Client.ProjectBuilding.UnpackedPackage).
678
721
InLibraryLBI lbi ->
722
+ -- withExtraPathEnv (useExtraPathEnv options) $
723
+ -- withEnvOverrides (useExtraEnvOverrides options) $
679
724
case sPhase of
680
725
SBuildPhase -> InLibrary. build flags lbi
681
726
SHaddockPhase -> InLibrary. haddock flags lbi
0 commit comments