diff --git a/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs b/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs index e30a8790c2b..bcfa608e149 100644 --- a/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs +++ b/Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs @@ -34,4 +34,4 @@ md5CheckGenericPackageDescription proxy = md5Check proxy md5CheckLocalBuildInfo :: Proxy LocalBuildInfo -> Assertion md5CheckLocalBuildInfo proxy = md5Check proxy - 0x2c8550e1552f68bf169fafbfcd8f845a + 0xd8d6695c12b407e453f192a4d833cb79 diff --git a/Cabal/src/Distribution/Simple/GHC/Build/ExtraSources.hs b/Cabal/src/Distribution/Simple/GHC/Build/ExtraSources.hs index 166f2a2ebc5..a49dfe35753 100644 --- a/Cabal/src/Distribution/Simple/GHC/Build/ExtraSources.hs +++ b/Cabal/src/Distribution/Simple/GHC/Build/ExtraSources.hs @@ -23,6 +23,7 @@ import Distribution.Simple.GHC.Build.Modules import Distribution.Simple.GHC.Build.Utils import Distribution.Simple.LocalBuildInfo import Distribution.Simple.Program.Types +import Distribution.Simple.Setup.Common (commonSetupTempFileOptions) import Distribution.System (Arch (JavaScript), Platform (..)) import Distribution.Types.ComponentLocalBuildInfo import Distribution.Utils.Path @@ -177,11 +178,13 @@ buildExtraSources comp = compiler lbi platform = hostPlatform lbi responseFileDir = coerceSymbolicPath buildTargetDir + tempFileOptions = commonSetupTempFileOptions $ buildingWhatCommonFlags buildingWhat runGhcProg = runGHCWithResponseFile "ghc.rsp" Nothing responseFileDir + tempFileOptions verbosity ghcProg comp diff --git a/Cabal/src/Distribution/Simple/GHC/Build/Link.hs b/Cabal/src/Distribution/Simple/GHC/Build/Link.hs index 7b87092514f..6bf8c5b3a45 100644 --- a/Cabal/src/Distribution/Simple/GHC/Build/Link.hs +++ b/Cabal/src/Distribution/Simple/GHC/Build/Link.hs @@ -99,6 +99,7 @@ linkOrLoadComponent isIndef = componentIsIndefinite clbi mbWorkDir = mbWorkDirLBI lbi responseFileDir = coerceSymbolicPath buildTargetDir + tempFileOptions = commonSetupTempFileOptions $ buildingWhatCommonFlags what -- See Note [Symbolic paths] in Distribution.Utils.Path i = interpretSymbolicPathLBI lbi @@ -204,6 +205,7 @@ linkOrLoadComponent "ghc.rsp" Nothing responseFileDir + tempFileOptions verbosity ghcProg comp @@ -748,12 +750,14 @@ runReplOrWriteFlags ghcProg lbi rflags ghcOpts pkg_name target responseFileDir = common = configCommonFlags $ configFlags lbi mbWorkDir = mbWorkDirLBI lbi verbosity = fromFlag $ setupVerbosity common + tempFileOptions = commonSetupTempFileOptions common in case replOptionsFlagOutput (replReplOptions rflags) of NoFlag -> runGHCWithResponseFile "ghc.rsp" Nothing responseFileDir + tempFileOptions verbosity ghcProg comp diff --git a/Cabal/src/Distribution/Simple/GHC/Build/Modules.hs b/Cabal/src/Distribution/Simple/GHC/Build/Modules.hs index 257d458cad1..55e0ec7ecf9 100644 --- a/Cabal/src/Distribution/Simple/GHC/Build/Modules.hs +++ b/Cabal/src/Distribution/Simple/GHC/Build/Modules.hs @@ -150,11 +150,13 @@ buildHaskellModules numJobs ghcProg mbMainFile inputModules buildTargetDir neede mbWorkDir = mbWorkDirLBI lbi responseFileDir = coerceSymbolicPath buildTargetDir + tempFileOptions = commonSetupTempFileOptions $ buildingWhatCommonFlags what runGhcProg = runGHCWithResponseFile "ghc.rsp" Nothing responseFileDir + tempFileOptions verbosity ghcProg comp diff --git a/Cabal/src/Distribution/Simple/Haddock.hs b/Cabal/src/Distribution/Simple/Haddock.hs index ba025a85549..3b69f6e0630 100644 --- a/Cabal/src/Distribution/Simple/Haddock.hs +++ b/Cabal/src/Distribution/Simple/Haddock.hs @@ -67,12 +67,9 @@ import Distribution.Simple.Program.GHC import qualified Distribution.Simple.Program.HcPkg as HcPkg import Distribution.Simple.Program.ResponseFile import Distribution.Simple.Register -import Distribution.Simple.Setup.Common -import Distribution.Simple.Setup.Haddock -import Distribution.Simple.Setup.Hscolour +import Distribution.Simple.Setup import Distribution.Simple.SetupHooks.Internal ( BuildHooks (..) - , BuildingWhat (..) , noBuildHooks ) import qualified Distribution.Simple.SetupHooks.Internal as SetupHooks @@ -265,6 +262,7 @@ haddock_setupHooks mbWorkDir = flagToMaybe $ haddockWorkingDir flags comp = compiler lbi platform = hostPlatform lbi + config = configFlags lbi quickJmpFlag = haddockQuickJump flags' flags = case haddockTarget of @@ -282,9 +280,7 @@ haddock_setupHooks flag f = fromFlag $ f flags tmpFileOpts = - defaultTempFileOptions - { optKeepTempFiles = flag haddockKeepTempFiles - } + commonSetupTempFileOptions $ configCommonFlags config htmlTemplate = fmap toPathTemplate . flagToMaybe . haddockHtmlLocation $ flags diff --git a/Cabal/src/Distribution/Simple/Program/GHC.hs b/Cabal/src/Distribution/Simple/Program/GHC.hs index 12027ce35c0..b7e04d31bf4 100644 --- a/Cabal/src/Distribution/Simple/Program/GHC.hs +++ b/Cabal/src/Distribution/Simple/Program/GHC.hs @@ -36,7 +36,7 @@ import Distribution.Simple.Program.Find (getExtraPathEnv) import Distribution.Simple.Program.ResponseFile import Distribution.Simple.Program.Run import Distribution.Simple.Program.Types -import Distribution.Simple.Utils (defaultTempFileOptions) +import Distribution.Simple.Utils (TempFileOptions) import Distribution.System import Distribution.Types.ComponentId import Distribution.Types.ParStrat @@ -645,6 +645,7 @@ runGHCWithResponseFile :: FilePath -> Maybe TextEncoding -> SymbolicPath Pkg (Dir Response) + -> TempFileOptions -> Verbosity -> ConfiguredProgram -> Compiler @@ -652,7 +653,7 @@ runGHCWithResponseFile -> Maybe (SymbolicPath CWD (Dir Pkg)) -> GhcOptions -> IO () -runGHCWithResponseFile fileNameTemplate encoding responseFileDir verbosity ghcProg comp platform maybeWorkDir opts = do +runGHCWithResponseFile fileNameTemplate encoding responseFileDir tempFileOptions verbosity ghcProg comp platform maybeWorkDir opts = do invocation <- ghcInvocation verbosity ghcProg comp platform maybeWorkDir opts -- Don't use response files if the first argument is `--interactive`, for @@ -686,7 +687,7 @@ runGHCWithResponseFile fileNameTemplate encoding responseFileDir verbosity ghcPr withResponseFile verbosity - defaultTempFileOptions + tempFileOptions maybeWorkDir responseFileDir fileNameTemplate diff --git a/Cabal/src/Distribution/Simple/Setup.hs b/Cabal/src/Distribution/Simple/Setup.hs index dfde4466b30..691a0ba5901 100644 --- a/Cabal/src/Distribution/Simple/Setup.hs +++ b/Cabal/src/Distribution/Simple/Setup.hs @@ -41,6 +41,7 @@ module Distribution.Simple.Setup , globalCommand , CommonSetupFlags (..) , defaultCommonSetupFlags + , commonSetupTempFileOptions , ConfigFlags (..) , emptyConfigFlags , defaultConfigFlags diff --git a/Cabal/src/Distribution/Simple/Setup/Common.hs b/Cabal/src/Distribution/Simple/Setup/Common.hs index 0a1422b327f..3f6db6a365c 100644 --- a/Cabal/src/Distribution/Simple/Setup/Common.hs +++ b/Cabal/src/Distribution/Simple/Setup/Common.hs @@ -23,6 +23,7 @@ module Distribution.Simple.Setup.Common ( CommonSetupFlags (..) , defaultCommonSetupFlags , withCommonSetupOptions + , commonSetupTempFileOptions , CopyDest (..) , configureCCompiler , configureLinker @@ -85,6 +86,13 @@ data CommonSetupFlags = CommonSetupFlags -- -- TODO: this one should not be here, it's just that the silly -- UserHooks stop us from passing extra info in other ways + , setupKeepTempFiles :: Flag Bool + -- ^ When this flag is set, temporary files will be kept after building. + -- + -- Note: Keeping temporary files is important functionality for HLS, which + -- runs @cabal repl@ with a fake GHC to get CLI arguments. It will need the + -- temporary files (including multi unit repl response files) to stay, even + -- after the @cabal repl@ command exits. } deriving (Eq, Show, Read, Generic) @@ -106,6 +114,15 @@ defaultCommonSetupFlags = , setupDistPref = NoFlag , setupCabalFilePath = NoFlag , setupTargets = [] + , setupKeepTempFiles = NoFlag + } + +-- | Get `TempFileOptions` that respect the `setupKeepTempFiles` flag. +commonSetupTempFileOptions :: CommonSetupFlags -> TempFileOptions +commonSetupTempFileOptions options = + TempFileOptions + { optKeepTempFiles = + fromFlagOrDefault False (setupKeepTempFiles options) } commonSetupOptions :: ShowOrParseArgs -> [OptionField CommonSetupFlags] @@ -124,8 +141,16 @@ commonSetupOptions showOrParseArgs = setupCabalFilePath (\v flags -> flags{setupCabalFilePath = v}) (reqSymbolicPathArgFlag "PATH") - -- NB: no --working-dir flag, as that value is populated using the - -- global flag (see Distribution.Simple.Setup.Global.globalCommand). + , -- NB: no --working-dir flag, as that value is populated using the + -- global flag (see Distribution.Simple.Setup.Global.globalCommand). + option + "" + ["keep-temp-files"] + ( "Keep temporary files." + ) + setupKeepTempFiles + (\v flags -> flags{setupKeepTempFiles = v}) + trueArg ] withCommonSetupOptions diff --git a/Cabal/src/Distribution/Simple/Setup/Haddock.hs b/Cabal/src/Distribution/Simple/Setup/Haddock.hs index aee2210d907..d6fc816b7f1 100644 --- a/Cabal/src/Distribution/Simple/Setup/Haddock.hs +++ b/Cabal/src/Distribution/Simple/Setup/Haddock.hs @@ -111,7 +111,6 @@ data HaddockFlags = HaddockFlags , haddockHscolourCss :: Flag FilePath , haddockContents :: Flag PathTemplate , haddockIndex :: Flag PathTemplate - , haddockKeepTempFiles :: Flag Bool , haddockBaseUrl :: Flag String , haddockResourcesDir :: Flag String , haddockOutputDir :: Flag FilePath @@ -166,7 +165,6 @@ defaultHaddockFlags = , haddockQuickJump = Flag False , haddockHscolourCss = NoFlag , haddockContents = NoFlag - , haddockKeepTempFiles = Flag False , haddockIndex = NoFlag , haddockBaseUrl = NoFlag , haddockResourcesDir = NoFlag @@ -219,13 +217,6 @@ haddockOptions showOrParseArgs = (\c f -> f{haddockCommonFlags = c}) showOrParseArgs [ option - "" - ["keep-temp-files"] - "Keep temporary files" - haddockKeepTempFiles - (\b flags -> flags{haddockKeepTempFiles = b}) - trueArg - , option "" ["hoogle"] "Generate a hoogle database" @@ -413,7 +404,8 @@ data Visibility = Visible | Hidden deriving (Eq, Show) data HaddockProjectFlags = HaddockProjectFlags - { haddockProjectHackage :: Flag Bool + { haddockProjectCommonFlags :: !CommonSetupFlags + , haddockProjectHackage :: Flag Bool -- ^ a shortcut option which builds documentation linked to hackage. It implies: -- * `--html-location='https://hackage.haskell.org/package/$prg-$version/docs' -- * `--quickjump` @@ -457,7 +449,8 @@ data HaddockProjectFlags = HaddockProjectFlags defaultHaddockProjectFlags :: HaddockProjectFlags defaultHaddockProjectFlags = HaddockProjectFlags - { haddockProjectHackage = Flag False + { haddockProjectCommonFlags = defaultCommonSetupFlags + , haddockProjectHackage = Flag False , haddockProjectDir = Flag "./haddocks" , haddockProjectPrologue = NoFlag , haddockProjectTestSuites = Flag False @@ -517,140 +510,144 @@ haddockProjectCommand = emptyProgramDb haddockProjectOptions :: ShowOrParseArgs -> [OptionField HaddockProjectFlags] -haddockProjectOptions _showOrParseArgs = - [ option - "" - ["hackage"] - ( concat - [ "A short-cut option to build documentation linked to hackage." - ] - ) - haddockProjectHackage - (\v flags -> flags{haddockProjectHackage = v}) - trueArg - , option - "" - ["output"] - "Output directory" - haddockProjectDir - (\v flags -> flags{haddockProjectDir = v}) - (optArg' "DIRECTORY" maybeToFlag (fmap Just . flagToList)) - , option - "" - ["prologue"] - "File path to a prologue file in haddock format" - haddockProjectPrologue - (\v flags -> flags{haddockProjectPrologue = v}) - (optArg' "PATH" maybeToFlag (fmap Just . flagToList)) - , option - "" - ["hoogle"] - "Generate a hoogle database" - haddockProjectHoogle - (\v flags -> flags{haddockProjectHoogle = v}) - trueArg - , option - "" - ["html-location"] - "Location of HTML documentation for pre-requisite packages" - haddockProjectHtmlLocation - (\v flags -> flags{haddockProjectHtmlLocation = v}) - (reqArgFlag "URL") - , option - "" - ["executables"] - "Run haddock for Executables targets" - haddockProjectExecutables - (\v flags -> flags{haddockProjectExecutables = v}) - trueArg - , option - "" - ["tests"] - "Run haddock for Test Suite targets" - haddockProjectTestSuites - (\v flags -> flags{haddockProjectTestSuites = v}) - trueArg - , option - "" - ["benchmarks"] - "Run haddock for Benchmark targets" - haddockProjectBenchmarks - (\v flags -> flags{haddockProjectBenchmarks = v}) - trueArg - , option - "" - ["foreign-libraries"] - "Run haddock for Foreign Library targets" - haddockProjectForeignLibs - (\v flags -> flags{haddockProjectForeignLibs = v}) - trueArg - , option - "" - ["all", "haddock-all"] - "Run haddock for all targets" - ( \f -> - allFlags - [ haddockProjectExecutables f - , haddockProjectTestSuites f - , haddockProjectBenchmarks f - , haddockProjectForeignLibs f +haddockProjectOptions showOrParseArgs = + withCommonSetupOptions + haddockProjectCommonFlags + (\c f -> f{haddockProjectCommonFlags = c}) + showOrParseArgs + [ option + "" + ["hackage"] + ( concat + [ "A short-cut option to build documentation linked to hackage." ] - ) - ( \v flags -> - flags - { haddockProjectExecutables = v - , haddockProjectTestSuites = v - , haddockProjectBenchmarks = v - , haddockProjectForeignLibs = v - } - ) - trueArg - , option - "" - ["internal"] - "Run haddock for internal modules and include all symbols" - haddockProjectInternal - (\v flags -> flags{haddockProjectInternal = v}) - trueArg - , option - "" - ["css"] - "Use PATH as the haddock stylesheet" - haddockProjectCss - (\v flags -> flags{haddockProjectCss = v}) - (reqArgFlag "PATH") - , option - "" - ["hscolour-css"] - "Use PATH as the HsColour stylesheet" - haddockProjectHscolourCss - (\v flags -> flags{haddockProjectHscolourCss = v}) - (reqArgFlag "PATH") - , option - "" - ["keep-temp-files"] - "Keep temporary files" - haddockProjectKeepTempFiles - (\b flags -> flags{haddockProjectKeepTempFiles = b}) - trueArg - , optionVerbosity - haddockProjectVerbosity - (\v flags -> flags{haddockProjectVerbosity = v}) - , option - "" - ["resources-dir"] - "location of Haddocks static / auxiliary files" - haddockProjectResourcesDir - (\v flags -> flags{haddockProjectResourcesDir = v}) - (reqArgFlag "DIR") - , option - "" - ["use-unicode"] - "Pass --use-unicode option to haddock" - haddockProjectUseUnicode - (\v flags -> flags{haddockProjectUseUnicode = v}) - trueArg - ] + ) + haddockProjectHackage + (\v flags -> flags{haddockProjectHackage = v}) + trueArg + , option + "" + ["output"] + "Output directory" + haddockProjectDir + (\v flags -> flags{haddockProjectDir = v}) + (optArg' "DIRECTORY" maybeToFlag (fmap Just . flagToList)) + , option + "" + ["prologue"] + "File path to a prologue file in haddock format" + haddockProjectPrologue + (\v flags -> flags{haddockProjectPrologue = v}) + (optArg' "PATH" maybeToFlag (fmap Just . flagToList)) + , option + "" + ["hoogle"] + "Generate a hoogle database" + haddockProjectHoogle + (\v flags -> flags{haddockProjectHoogle = v}) + trueArg + , option + "" + ["html-location"] + "Location of HTML documentation for pre-requisite packages" + haddockProjectHtmlLocation + (\v flags -> flags{haddockProjectHtmlLocation = v}) + (reqArgFlag "URL") + , option + "" + ["executables"] + "Run haddock for Executables targets" + haddockProjectExecutables + (\v flags -> flags{haddockProjectExecutables = v}) + trueArg + , option + "" + ["tests"] + "Run haddock for Test Suite targets" + haddockProjectTestSuites + (\v flags -> flags{haddockProjectTestSuites = v}) + trueArg + , option + "" + ["benchmarks"] + "Run haddock for Benchmark targets" + haddockProjectBenchmarks + (\v flags -> flags{haddockProjectBenchmarks = v}) + trueArg + , option + "" + ["foreign-libraries"] + "Run haddock for Foreign Library targets" + haddockProjectForeignLibs + (\v flags -> flags{haddockProjectForeignLibs = v}) + trueArg + , option + "" + ["all", "haddock-all"] + "Run haddock for all targets" + ( \f -> + allFlags + [ haddockProjectExecutables f + , haddockProjectTestSuites f + , haddockProjectBenchmarks f + , haddockProjectForeignLibs f + ] + ) + ( \v flags -> + flags + { haddockProjectExecutables = v + , haddockProjectTestSuites = v + , haddockProjectBenchmarks = v + , haddockProjectForeignLibs = v + } + ) + trueArg + , option + "" + ["internal"] + "Run haddock for internal modules and include all symbols" + haddockProjectInternal + (\v flags -> flags{haddockProjectInternal = v}) + trueArg + , option + "" + ["css"] + "Use PATH as the haddock stylesheet" + haddockProjectCss + (\v flags -> flags{haddockProjectCss = v}) + (reqArgFlag "PATH") + , option + "" + ["hscolour-css"] + "Use PATH as the HsColour stylesheet" + haddockProjectHscolourCss + (\v flags -> flags{haddockProjectHscolourCss = v}) + (reqArgFlag "PATH") + , option + "" + ["keep-temp-files"] + "Keep temporary files" + haddockProjectKeepTempFiles + (\b flags -> flags{haddockProjectKeepTempFiles = b}) + trueArg + , optionVerbosity + haddockProjectVerbosity + (\v flags -> flags{haddockProjectVerbosity = v}) + , option + "" + ["resources-dir"] + "location of Haddocks static / auxiliary files" + haddockProjectResourcesDir + (\v flags -> flags{haddockProjectResourcesDir = v}) + (reqArgFlag "DIR") + , option + "" + ["use-unicode"] + "Pass --use-unicode option to haddock" + haddockProjectUseUnicode + (\v flags -> flags{haddockProjectUseUnicode = v}) + trueArg + ] emptyHaddockProjectFlags :: HaddockProjectFlags emptyHaddockProjectFlags = mempty diff --git a/cabal-install/src/Distribution/Client/CmdHaddockProject.hs b/cabal-install/src/Distribution/Client/CmdHaddockProject.hs index f632e8b7caa..2087a6db746 100644 --- a/cabal-install/src/Distribution/Client/CmdHaddockProject.hs +++ b/cabal-install/src/Distribution/Client/CmdHaddockProject.hs @@ -85,7 +85,6 @@ import Distribution.Simple.Setup , HaddockProjectFlags (..) , HaddockTarget (..) , Visibility (..) - , defaultCommonSetupFlags , defaultHaddockFlags , haddockProjectCommand ) @@ -121,7 +120,7 @@ haddockProjectAction flags _extraArgs globalFlags = do -- build all packages with appropriate haddock flags let commonFlags = - defaultCommonSetupFlags + (haddockProjectCommonFlags flags) { setupVerbosity = haddockProjectVerbosity flags } haddockFlags = @@ -158,7 +157,6 @@ haddockProjectAction flags _extraArgs globalFlags = do if localStyle then Flag (toPathTemplate "../doc-index.html") else NoFlag - , haddockKeepTempFiles = haddockProjectKeepTempFiles flags , haddockResourcesDir = haddockProjectResourcesDir flags , haddockUseUnicode = haddockProjectUseUnicode flags -- NOTE: we don't pass `haddockOutputDir`. If we do, we'll need to diff --git a/cabal-install/src/Distribution/Client/CmdRepl.hs b/cabal-install/src/Distribution/Client/CmdRepl.hs index e381b291d7d..f762c3d72bf 100644 --- a/cabal-install/src/Distribution/Client/CmdRepl.hs +++ b/cabal-install/src/Distribution/Client/CmdRepl.hs @@ -103,11 +103,11 @@ import Distribution.Simple.Compiler ) import Distribution.Simple.Setup ( ReplOptions (..) + , commonSetupTempFileOptions , setupVerbosity ) import Distribution.Simple.Utils - ( TempFileOptions (..) - , debugNoWrap + ( debugNoWrap , dieWithException , withTempDirectoryEx , wrapText @@ -411,7 +411,7 @@ replAction flags@NixStyleFlags{extraFlags = r@ReplFlags{..}, ..} targetStrings g -- Multi Repl implemention see: https://well-typed.com/blog/2023/03/cabal-multi-unit/ for -- a high-level overview about how everything fits together. if Set.size (distinctTargetComponents targets) > 1 - then withTempDirectoryEx verbosity (TempFileOptions keepTempFiles) distDir "multi-out" $ \dir' -> do + then withTempDirectoryEx verbosity tempFileOptions distDir "multi-out" $ \dir' -> do -- multi target repl dir <- makeAbsolute dir' -- Modify the replOptions so that the ./Setup repl command will write options @@ -507,7 +507,7 @@ replAction flags@NixStyleFlags{extraFlags = r@ReplFlags{..}, ..} targetStrings g go m _ = m verbosity = fromFlagOrDefault normal (setupVerbosity $ configCommonFlags configFlags) - keepTempFiles = fromFlagOrDefault False replKeepTempFiles + tempFileOptions = commonSetupTempFileOptions $ configCommonFlags configFlags validatedTargets ctx compiler elaboratedPlan targetSelectors = do let multi_repl_enabled = multiReplDecision ctx compiler r diff --git a/cabal-install/src/Distribution/Client/Config.hs b/cabal-install/src/Distribution/Client/Config.hs index 2faf9e1756d..ea6e92ac9b6 100644 --- a/cabal-install/src/Distribution/Client/Config.hs +++ b/cabal-install/src/Distribution/Client/Config.hs @@ -469,6 +469,7 @@ instance Semigroup SavedConfig where , setupCabalFilePath = combine setupCabalFilePath , setupVerbosity = combine setupVerbosity , setupTargets = lastNonEmpty setupTargets + , setupKeepTempFiles = combine setupKeepTempFiles } where lastNonEmpty = lastNonEmpty' which @@ -629,7 +630,6 @@ instance Semigroup SavedConfig where , haddockQuickJump = combine haddockQuickJump , haddockHscolourCss = combine haddockHscolourCss , haddockContents = combine haddockContents - , haddockKeepTempFiles = combine haddockKeepTempFiles , haddockIndex = combine haddockIndex , haddockBaseUrl = combine haddockBaseUrl , haddockResourcesDir = combine haddockResourcesDir diff --git a/cabal-install/src/Distribution/Client/ProjectBuilding/UnpackedPackage.hs b/cabal-install/src/Distribution/Client/ProjectBuilding/UnpackedPackage.hs index 23dff3ff3ab..f2567f099c7 100644 --- a/cabal-install/src/Distribution/Client/ProjectBuilding/UnpackedPackage.hs +++ b/cabal-install/src/Distribution/Client/ProjectBuilding/UnpackedPackage.hs @@ -168,7 +168,7 @@ buildAndRegisterUnpackedPackage verbosity distDirLayout@DistDirLayout{distTempDirectory} maybe_semaphore - buildTimeSettings@BuildTimeSettings{buildSettingNumJobs} + buildTimeSettings@BuildTimeSettings{buildSettingNumJobs, buildSettingKeepTempFiles} registerLock cacheLock pkgshared@ElaboratedSharedConfig @@ -273,7 +273,7 @@ buildAndRegisterUnpackedPackage mbWorkDir = useWorkingDir scriptOptions commonFlags v = flip filterCommonFlags v $ - setupHsCommonFlags verbosity mbWorkDir builddir + setupHsCommonFlags verbosity mbWorkDir builddir buildSettingKeepTempFiles configureCommand = Cabal.configureCommand defaultProgramDb configureFlags v = diff --git a/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs b/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs index fe8ea884ccc..78622d53be6 100644 --- a/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs +++ b/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs @@ -858,9 +858,9 @@ convertLegacyBuildOnlyFlags configFlags installFlags clientInstallFlags - haddockFlags - _ - _ = + _haddockFlags + _testFlags + _benchmarkFlags = ProjectConfigBuildOnly{..} where projectConfigClientInstallFlags = clientInstallFlags @@ -877,6 +877,7 @@ convertLegacyBuildOnlyFlags CommonSetupFlags { setupVerbosity = projectConfigVerbosity + , setupKeepTempFiles = projectConfigKeepTempFiles } = commonFlags InstallFlags @@ -896,10 +897,6 @@ convertLegacyBuildOnlyFlags , installOfflineMode = projectConfigOfflineMode } = installFlags - HaddockFlags - { haddockKeepTempFiles = projectConfigKeepTempFiles -- TODO: this ought to live elsewhere - } = haddockFlags - convertToLegacyProjectConfig :: ProjectConfig -> LegacyProjectConfig convertToLegacyProjectConfig projectConfig@ProjectConfig @@ -972,6 +969,7 @@ convertToLegacySharedConfig mempty { setupVerbosity = projectConfigVerbosity , setupDistPref = fmap makeSymbolicPath $ projectConfigDistDir + , setupKeepTempFiles = projectConfigKeepTempFiles } configFlags = @@ -1044,8 +1042,7 @@ convertToLegacySharedConfig convertToLegacyAllPackageConfig :: ProjectConfig -> LegacyPackageConfig convertToLegacyAllPackageConfig ProjectConfig - { projectConfigBuildOnly = ProjectConfigBuildOnly{..} - , projectConfigShared = ProjectConfigShared{..} + { projectConfigShared = ProjectConfigShared{..} } = LegacyPackageConfig { legacyConfigureFlags = configFlags @@ -1121,8 +1118,6 @@ convertToLegacyAllPackageConfig haddockFlags = mempty - { haddockKeepTempFiles = projectConfigKeepTempFiles - } convertToLegacyPerPackageConfig :: PackageConfig -> LegacyPackageConfig convertToLegacyPerPackageConfig PackageConfig{..} = @@ -1222,7 +1217,6 @@ convertToLegacyPerPackageConfig PackageConfig{..} = , haddockQuickJump = packageConfigHaddockQuickJump , haddockHscolourCss = packageConfigHaddockHscolourCss , haddockContents = packageConfigHaddockContents - , haddockKeepTempFiles = mempty , haddockIndex = packageConfigHaddockIndex , haddockBaseUrl = packageConfigHaddockBaseUrl , haddockResourcesDir = packageConfigHaddockResourcesDir diff --git a/cabal-install/src/Distribution/Client/ProjectOrchestration.hs b/cabal-install/src/Distribution/Client/ProjectOrchestration.hs index 8fb0ca8e65f..7fa36cc7392 100644 --- a/cabal-install/src/Distribution/Client/ProjectOrchestration.hs +++ b/cabal-install/src/Distribution/Client/ProjectOrchestration.hs @@ -946,7 +946,7 @@ printPlan printPlan verbosity ProjectBaseContext - { buildSettings = BuildTimeSettings{buildSettingDryRun} + { buildSettings = BuildTimeSettings{buildSettingDryRun, buildSettingKeepTempFiles} , projectConfig = ProjectConfig { projectConfigAllPackages = @@ -1048,6 +1048,7 @@ printPlan verbosity Nothing -- omit working directory (makeSymbolicPath "$builddir") + buildSettingKeepTempFiles fullConfigureFlags = setupHsConfigureFlags elaboratedPlan diff --git a/cabal-install/src/Distribution/Client/ProjectPlanning.hs b/cabal-install/src/Distribution/Client/ProjectPlanning.hs index 6082e816c99..369887597ea 100644 --- a/cabal-install/src/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/src/Distribution/Client/ProjectPlanning.hs @@ -4085,14 +4085,16 @@ setupHsCommonFlags :: Verbosity -> Maybe (SymbolicPath CWD (Dir Pkg)) -> SymbolicPath Pkg (Dir Dist) + -> Bool -> Cabal.CommonSetupFlags -setupHsCommonFlags verbosity mbWorkDir builddir = +setupHsCommonFlags verbosity mbWorkDir builddir keepTempFiles = Cabal.CommonSetupFlags { setupDistPref = toFlag builddir , setupVerbosity = toFlag verbosity , setupCabalFilePath = mempty , setupWorkingDir = maybeToFlag mbWorkDir , setupTargets = [] + , setupKeepTempFiles = toFlag keepTempFiles } setupHsBuildFlags @@ -4221,7 +4223,7 @@ setupHsHaddockFlags setupHsHaddockFlags (ElaboratedConfiguredPackage{..}) (ElaboratedSharedConfig{..}) - (BuildTimeSettings{buildSettingKeepTempFiles = keepTmpFiles}) + _buildTimeSettings common = Cabal.HaddockFlags { haddockCommonFlags = common @@ -4249,7 +4251,6 @@ setupHsHaddockFlags , haddockQuickJump = toFlag elabHaddockQuickJump , haddockHscolourCss = maybe mempty toFlag elabHaddockHscolourCss , haddockContents = maybe mempty toFlag elabHaddockContents - , haddockKeepTempFiles = toFlag keepTmpFiles , haddockIndex = maybe mempty toFlag elabHaddockIndex , haddockBaseUrl = maybe mempty toFlag elabHaddockBaseUrl , haddockResourcesDir = maybe mempty toFlag elabHaddockResourcesDir diff --git a/cabal-install/src/Distribution/Client/ReplFlags.hs b/cabal-install/src/Distribution/Client/ReplFlags.hs index a7136aa572d..0d587b1d501 100644 --- a/cabal-install/src/Distribution/Client/ReplFlags.hs +++ b/cabal-install/src/Distribution/Client/ReplFlags.hs @@ -27,7 +27,6 @@ import Distribution.Simple.Setup , falseArg , replOptions , toFlag - , trueArg ) import Distribution.Types.Dependency ( Dependency (..) @@ -55,11 +54,10 @@ data ReplFlags = ReplFlags { configureReplOptions :: ReplOptions , replEnvFlags :: EnvFlags , replUseMulti :: Flag Bool - , replKeepTempFiles :: Flag Bool } instance Semigroup ReplFlags where - (ReplFlags a1 a2 a3 a4) <> (ReplFlags b1 b2 b3 b4) = ReplFlags (a1 <> b1) (a2 <> b2) (a3 <> b3) (a4 <> b4) + (ReplFlags a1 a2 a3) <> (ReplFlags b1 b2 b3) = ReplFlags (a1 <> b1) (a2 <> b2) (a3 <> b3) instance Monoid ReplFlags where mempty = defaultReplFlags @@ -70,7 +68,6 @@ defaultReplFlags = { configureReplOptions = mempty , replEnvFlags = defaultEnvFlags , replUseMulti = NoFlag - , replKeepTempFiles = NoFlag } topReplOptions :: ShowOrParseArgs -> [OptionField ReplFlags] @@ -78,18 +75,6 @@ topReplOptions showOrParseArgs = liftOptions configureReplOptions set1 (replOptions showOrParseArgs) ++ liftOptions replEnvFlags set2 (envOptions showOrParseArgs) ++ [ liftOption replUseMulti set3 multiReplOption - , -- keeping temporary files is important functionality for HLS, - -- which runs @cabal repl@ with fake GHC to get cli arguments. - -- It will need the temporary files (incl. multi unit repl response files) - -- to stay, even after the @cabal repl@ command exits. - -- - option - [] - ["keep-temp-files"] - "Keep temporary files" - replKeepTempFiles - (\b flags -> flags{replKeepTempFiles = b}) - trueArg ] where set1 a x = x{configureReplOptions = a} diff --git a/cabal-install/src/Distribution/Client/Setup.hs b/cabal-install/src/Distribution/Client/Setup.hs index 78e864d1a65..5c3b65d586e 100644 --- a/cabal-install/src/Distribution/Client/Setup.hs +++ b/cabal-install/src/Distribution/Client/Setup.hs @@ -647,9 +647,11 @@ filterCommonFlags flags cabalLibVersion flags_latest = flags flags_3_13_0 = flags_latest - { setupWorkingDir = NoFlag + { -- Cabal < 3.13 does not support the --working-dir flag. + setupWorkingDir = NoFlag + , -- Or the --keep-temp-files flag. + setupKeepTempFiles = NoFlag } - -- Cabal < 3.13 does not support the --working-dir flag. flags_2_1_0 = flags_3_13_0 { -- Cabal < 2.1 doesn't know about -v +timestamp modifier diff --git a/validate.sh b/validate.sh index ff1c9e139a9..6b0824dd4ea 100755 --- a/validate.sh +++ b/validate.sh @@ -299,15 +299,35 @@ JOBS="-j$JOBS" # assume compiler is GHC RUNHASKELL=$(echo "$HC" | sed -E 's/ghc(-[0-9.]*)$/runghc\1/') -case "$(uname)" in +ARCH=$(uname -m) + +case "$ARCH" in + arm64) + ARCH=aarch64 + ;; + x86_64) + ARCH=x86_64 + ;; + *) + echo "Warning: Unknown architecture '$ARCH'" + ;; +esac + +OS=$(uname) + +case "$OS" in MINGW64*) - ARCH="x86_64-windows" + ARCH="$ARCH-windows" + ;; + Linux) + ARCH="$ARCH-linux" ;; - Linux ) - ARCH="x86_64-linux" + Darwin) + ARCH="$ARCH-osx" ;; *) - ARCH="x86_64-osx" + echo "Warning: Unknown operating system '$OS'" + ARCH="$ARCH-$OS" ;; esac