@@ -126,6 +126,7 @@ data ExecuteEnv = ExecuteEnv
126
126
, setupExe :: ! (Maybe (Path Abs File ))
127
127
-- ^ Compiled version of eeSetupHs
128
128
, cabalPkgVer :: ! Version
129
+ -- ^ The version of the compiler's Cabal boot package.
129
130
, totalWanted :: ! Int
130
131
, locals :: ! [LocalPackage ]
131
132
, globalDB :: ! (Path Abs Dir )
@@ -142,6 +143,15 @@ data ExecuteEnv = ExecuteEnv
142
143
-- ^ Value of the PATH environment variable
143
144
}
144
145
146
+ -- | Type representing setup executable circumstances.
147
+ data SetupExe
148
+ = SimpleSetupExe ! (Path Abs File )
149
+ -- ^ The build type is Simple and there is a path to an existing setup
150
+ -- executable.
151
+ | OtherSetupHs ! (Path Abs File )
152
+ -- ^ Other circumstances with a path to the source code for the setup
153
+ -- executable.
154
+
145
155
buildSetupArgs :: [String ]
146
156
buildSetupArgs =
147
157
[ " -rtsopts"
@@ -669,13 +679,13 @@ withSingleContext
669
679
}
670
680
menv <- liftIO $ config. processContextSettings envSettings
671
681
distRelativeDir' <- distRelativeDir
672
- esetupexehs <-
682
+ setupexehs <-
673
683
-- Avoid broken Setup.hs files causing problems for simple build
674
684
-- types, see:
675
685
-- https://github.com/commercialhaskell/stack/issues/370
676
686
case (package. buildType, ee. setupExe) of
677
- (C. Simple , Just setupExe) -> pure $ Left setupExe
678
- _ -> liftIO $ Right <$> getSetupHs pkgDir
687
+ (C. Simple , Just setupExe) -> pure $ SimpleSetupExe setupExe
688
+ _ -> liftIO $ OtherSetupHs <$> getSetupHs pkgDir
679
689
inner $ \ keepOutputOpen stripTHLoading args -> do
680
690
let cabalPackageArg
681
691
-- Omit cabal package dependency when building
@@ -717,11 +727,10 @@ withSingleContext
717
727
getPackageArgs :: Path Abs Dir -> RIO env [String ]
718
728
getPackageArgs setupDir =
719
729
case package. setupDeps of
720
- -- The package is using the Cabal custom-setup
721
- -- configuration introduced in Cabal 1.24. In
722
- -- this case, the package is providing an
723
- -- explicit list of dependencies, and we
724
- -- should simply use all of them.
730
+ -- The package is using the Cabal custom-setup configuration
731
+ -- introduced in Cabal 1.24. In this case, the package is
732
+ -- providing an explicit list of dependencies, and we should
733
+ -- simply use all of them.
725
734
Just customSetupDeps -> do
726
735
unless (Map. member (mkPackageName " Cabal" ) customSetupDeps) $
727
736
prettyWarnL
@@ -789,13 +798,13 @@ withSingleContext
789
798
-- NOTE: This is different from packageDBArgs above in
790
799
-- that it does not include the local database and does
791
800
-- not pass in the -hide-all-packages argument
792
- ++ ( " -clear-package-db"
793
- : " -global-package-db"
794
- : map
795
- ((" -package-db=" ++ ) . toFilePathNoTrailingSep)
796
- ee. baseConfigOpts. extraDBs
797
- ++ [ " -package-db="
798
- ++ toFilePathNoTrailingSep ee. baseConfigOpts. snapDB
801
+ <> ( " -clear-package-db"
802
+ : " -global-package-db"
803
+ : map
804
+ ((" -package-db=" ++ ) . toFilePathNoTrailingSep)
805
+ ee. baseConfigOpts. extraDBs
806
+ <> [ " -package-db="
807
+ <> toFilePathNoTrailingSep ee. baseConfigOpts. snapDB
799
808
]
800
809
)
801
810
@@ -861,9 +870,9 @@ withSingleContext
861
870
ExcludeTHLoading -> ConvertPathsToAbsolute
862
871
KeepTHLoading -> KeepPathsAsIs
863
872
864
- exeName <- case esetupexehs of
865
- Left setupExe -> pure setupExe
866
- Right setuphs -> do
873
+ exeName <- case setupexehs of
874
+ SimpleSetupExe setupExe -> pure setupExe
875
+ OtherSetupHs setuphs -> do
867
876
distDir <- distDirFromDir pkgDir
868
877
let setupDir = distDir </> relDirSetup
869
878
outputFile = setupDir </> relFileSetupLower
@@ -875,32 +884,32 @@ withSingleContext
875
884
compilerPath <- view $ compilerPathsL . to (. compiler)
876
885
packageArgs <- getPackageArgs setupDir
877
886
runExe compilerPath $
878
- [ " --make"
879
- , " -odir" , toFilePathNoTrailingSep setupDir
880
- , " -hidir" , toFilePathNoTrailingSep setupDir
881
- , " -i" , " -i."
882
- ] ++ packageArgs ++
883
- [ toFilePath setuphs
884
- , toFilePath ee . setupShimHs
885
- , " -main-is "
886
- , " StackSetupShim.mainOverride "
887
- , " -o " , toFilePath outputFile
888
- , " -threaded "
889
- ] ++
890
-
887
+ [ " --make"
888
+ , " -odir" , toFilePathNoTrailingSep setupDir
889
+ , " -hidir" , toFilePathNoTrailingSep setupDir
890
+ , " -i" , " -i."
891
+ ]
892
+ <> packageArgs
893
+ <> [ toFilePath setuphs
894
+ , toFilePath ee . setupShimHs
895
+ , " -main-is "
896
+ , " StackSetupShim.mainOverride "
897
+ , " -o " , toFilePath outputFile
898
+ , " -threaded "
899
+ ]
891
900
-- Apply GHC options
892
901
-- https://github.com/commercialhaskell/stack/issues/4526
893
- map
894
- T. unpack
895
- ( Map. findWithDefault
896
- []
897
- AGOEverything
898
- config. ghcOptionsByCat
899
- ++ case config. applyGhcOptions of
900
- AGOEverything -> ee. buildOptsCLI. ghcOptions
901
- AGOTargets -> []
902
- AGOLocals -> []
903
- )
902
+ <> map
903
+ T. unpack
904
+ ( Map. findWithDefault
905
+ []
906
+ AGOEverything
907
+ config. ghcOptionsByCat
908
+ <> case config. applyGhcOptions of
909
+ AGOEverything -> ee. buildOptsCLI. ghcOptions
910
+ AGOTargets -> []
911
+ AGOLocals -> []
912
+ )
904
913
905
914
liftIO $ atomicModifyIORef' ee. customBuilt $
906
915
\ oldCustomBuilt ->
0 commit comments