From 7a59305d551308fd3a86cef8a9ece759a20df9da Mon Sep 17 00:00:00 2001 From: sheaf Date: Tue, 7 May 2024 10:51:32 +0200 Subject: [PATCH] Remove Internal SetupMethod This SetupMethod is no longer used; it is replaced by the InLibrary SetupMethod which directly calls Cabal library functions instead of going through defaultMain. --- .../src/Distribution/Client/SetupWrapper.hs | 41 +------------------ 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/cabal-install/src/Distribution/Client/SetupWrapper.hs b/cabal-install/src/Distribution/Client/SetupWrapper.hs index f8b79bebce0..925f401a2fc 100644 --- a/cabal-install/src/Distribution/Client/SetupWrapper.hs +++ b/cabal-install/src/Distribution/Client/SetupWrapper.hs @@ -47,7 +47,6 @@ import Prelude () import qualified Distribution.Backpack as Backpack import Distribution.CabalSpecVersion (cabalSpecMinimumLibraryVersion) -import qualified Distribution.Make as Make import Distribution.Package ( ComponentId , PackageId @@ -65,7 +64,6 @@ import Distribution.PackageDescription , buildType , specVersion ) -import qualified Distribution.Simple as Simple import Distribution.Simple.Build.Macros ( generatePackageVersionMacros ) @@ -121,9 +119,6 @@ import Distribution.Client.Utils , makeRelativeToDirS , moreRecentFile , tryCanonicalizePath - , withEnv - , withEnvOverrides - , withExtraPathEnv ) #ifdef mingw32_HOST_OS import Distribution.Client.Utils @@ -285,8 +280,6 @@ data ASetup = forall kind. ASetup ( Setup kind ) -- | @SetupMethod@ represents one of the methods used to run Cabal commands. data SetupMethod (kind :: SetupKind) where - -- | run Cabal commands through @cabal@ in the current process - InternalMethod :: SetupMethod GeneralSetup -- | Directly use Cabal library functions, bypassing the Setup -- mechanism entirely. LibraryMethod :: SetupMethod InLibrary @@ -511,7 +504,6 @@ withSetupMethod verbosity options pkg buildType' allowInLibrary with with <$> getExternalSetupMethod verbosity options pkg buildType' runSetupMethod :: WithCallStack (SetupMethod GeneralSetup -> SetupRunner UseGeneralSetup) -runSetupMethod InternalMethod = internalSetupMethod runSetupMethod (ExternalMethod path) = externalSetupMethod path runSetupMethod SelfExecMethod = selfExecSetupMethod @@ -696,46 +688,15 @@ setupWrapper verbosity options mpkg cmd getCommonFlags getFlags getExtraArgs wra SRegisterPhase -> InLibrary.register flags lbi extraArgs NotInLibrary -> error "internal error: NotInLibrary argument but getSetup chose InLibrary" - InternalMethod -> notInLibraryMethod ExternalMethod {} -> notInLibraryMethod SelfExecMethod -> notInLibraryMethod -- ------------------------------------------------------------ --- * Internal SetupMethod +-- * 'invoke' function -- ------------------------------------------------------------ --- | Run a Setup script by directly invoking the @Cabal@ library. -internalSetupMethod :: SetupRunner UseGeneralSetup -internalSetupMethod verbosity options bt args NotInLibrary = do - info verbosity $ - "Using internal setup method with build-type " - ++ show bt - ++ " and args:\n " - ++ show args - -- NB: we do not set the working directory of the process here, because - -- we will instead pass the -working-dir flag when invoking the Setup script. - -- Note that the Setup script is guaranteed to support this flag, because - -- the logic in 'withSetupMethod' guarantees we have an up-to-date Cabal version. - -- - -- In the future, it would be desirable to also stop relying on the following - -- pieces of process-global state, as this would allow us to use this internal - -- setup method in concurrent contexts. - withEnv "HASKELL_DIST_DIR" (getSymbolicPath $ useDistPref options) $ - withExtraPathEnv (useExtraPathEnv options) $ - withEnvOverrides (useExtraEnvOverrides options) $ - buildTypeAction bt args - -buildTypeAction :: BuildType -> ([String] -> IO ()) -buildTypeAction Simple = Simple.defaultMainArgs -buildTypeAction Configure = - Simple.defaultMainWithSetupHooksArgs - Simple.autoconfSetupHooks -buildTypeAction Make = Make.defaultMainArgs -buildTypeAction Hooks = error "buildTypeAction Hooks" -buildTypeAction Custom = error "buildTypeAction Custom" - invoke :: Verbosity -> FilePath -> [String] -> SetupScriptOptions -> IO () invoke verbosity path args options = do info verbosity $ unwords (path : args)