diff --git a/cabal-install/Distribution/Client/Configure.hs b/cabal-install/Distribution/Client/Configure.hs index e5c30a24e3c..adb283f32d4 100644 --- a/cabal-install/Distribution/Client/Configure.hs +++ b/cabal-install/Distribution/Client/Configure.hs @@ -134,7 +134,7 @@ configure verbosity packageDBs repoCtxt comp platform progdb ++ message ++ "\nTrying configure anyway." setupWrapper verbosity (setupScriptOptions installedPkgIndex Nothing) - Nothing configureCommand (const configFlags) extraArgs + Nothing configureCommand (const configFlags) (const extraArgs) Right installPlan0 -> let installPlan = InstallPlan.configureInstallPlan configFlags installPlan0 @@ -387,7 +387,7 @@ configurePackage verbosity platform comp scriptOptions configFlags extraArgs = setupWrapper verbosity - scriptOptions (Just pkg) configureCommand configureFlags extraArgs + scriptOptions (Just pkg) configureCommand configureFlags (const extraArgs) where gpkg = packageDescription spkg diff --git a/cabal-install/Distribution/Client/Install.hs b/cabal-install/Distribution/Client/Install.hs index 880f6d6554d..df17b1962dd 100644 --- a/cabal-install/Distribution/Client/Install.hs +++ b/cabal-install/Distribution/Client/Install.hs @@ -1551,7 +1551,7 @@ installUnpackedPackage verbosity installLock numJobs scriptOptions { useLoggingHandle = logFileHandle , useWorkingDir = workingDir } (Just pkg) - cmd flags []) + cmd flags (const [])) -- helper diff --git a/cabal-install/Distribution/Client/ProjectBuilding.hs b/cabal-install/Distribution/Client/ProjectBuilding.hs index 77fd4c24d48..0c72c4faabc 100644 --- a/cabal-install/Distribution/Client/ProjectBuilding.hs +++ b/cabal-install/Distribution/Client/ProjectBuilding.hs @@ -60,7 +60,9 @@ import Distribution.Client.JobControl import Distribution.Client.FetchUtils import Distribution.Client.GlobalFlags (RepoContext) import qualified Distribution.Client.Tar as Tar -import Distribution.Client.Setup (filterConfigureFlags) +import Distribution.Client.Setup + ( filterConfigureFlags, filterHaddockArgs + , filterHaddockFlags ) import Distribution.Client.SourceFiles import Distribution.Client.SrcDist (allPackageSourceFiles) import Distribution.Client.Utils (removeExistingFile) @@ -1039,7 +1041,7 @@ buildAndInstallUnpackedPackage verbosity configureFlags v = flip filterConfigureFlags v $ setupHsConfigureFlags rpkg pkgshared verbosity builddir - configureArgs = setupHsConfigureArgs pkg + configureArgs _ = setupHsConfigureArgs pkg buildCommand = Cabal.buildCommand defaultProgramDb buildFlags _ = setupHsBuildFlags pkg pkgshared verbosity builddir @@ -1065,9 +1067,9 @@ buildAndInstallUnpackedPackage verbosity isParallelBuild cacheLock setup :: CommandUI flags -> (Version -> flags) -> IO () - setup cmd flags = setup' cmd flags [] + setup cmd flags = setup' cmd flags (const []) - setup' :: CommandUI flags -> (Version -> flags) -> [String] -> IO () + setup' :: CommandUI flags -> (Version -> flags) -> (Version -> [String]) -> IO () setup' cmd flags args = withLogging $ \mLogFileHandle -> setupWrapper @@ -1283,46 +1285,48 @@ buildInplaceUnpackedPackage verbosity configureFlags v = flip filterConfigureFlags v $ setupHsConfigureFlags rpkg pkgshared verbosity builddir - configureArgs = setupHsConfigureArgs pkg + configureArgs _ = setupHsConfigureArgs pkg buildCommand = Cabal.buildCommand defaultProgramDb buildFlags _ = setupHsBuildFlags pkg pkgshared verbosity builddir - buildArgs = setupHsBuildArgs pkg + buildArgs _ = setupHsBuildArgs pkg testCommand = Cabal.testCommand -- defaultProgramDb testFlags _ = setupHsTestFlags pkg pkgshared verbosity builddir - testArgs = setupHsTestArgs pkg + testArgs _ = setupHsTestArgs pkg benchCommand = Cabal.benchmarkCommand benchFlags _ = setupHsBenchFlags pkg pkgshared verbosity builddir - benchArgs = setupHsBenchArgs pkg + benchArgs _ = setupHsBenchArgs pkg replCommand = Cabal.replCommand defaultProgramDb replFlags _ = setupHsReplFlags pkg pkgshared verbosity builddir - replArgs = setupHsReplArgs pkg + replArgs _ = setupHsReplArgs pkg haddockCommand = Cabal.haddockCommand - haddockFlags _ = setupHsHaddockFlags pkg pkgshared + haddockFlags v = flip filterHaddockFlags v $ + setupHsHaddockFlags pkg pkgshared verbosity builddir - haddockArgs = setupHsHaddockArgs pkg + haddockArgs v = flip filterHaddockArgs v $ + setupHsHaddockArgs pkg scriptOptions = setupHsScriptOptions rpkg plan pkgshared srcdir builddir isParallelBuild cacheLock setupInteractive :: CommandUI flags - -> (Version -> flags) -> [String] -> IO () + -> (Version -> flags) -> (Version -> [String]) -> IO () setupInteractive cmd flags args = setupWrapper verbosity scriptOptions { isInteractive = True } (Just (elabPkgDescription pkg)) cmd flags args - setup :: CommandUI flags -> (Version -> flags) -> [String] -> IO () + setup :: CommandUI flags -> (Version -> flags) -> (Version -> [String]) -> IO () setup cmd flags args = setupWrapper verbosity scriptOptions @@ -1337,7 +1341,7 @@ buildInplaceUnpackedPackage verbosity pkg pkgshared verbosity builddir pkgConfDest - setup Cabal.registerCommand registerFlags [] + setup Cabal.registerCommand registerFlags (const []) withTempInstalledPackageInfoFile :: Verbosity -> FilePath -> (FilePath -> IO ()) @@ -1397,4 +1401,3 @@ annotateFailure mlogFile annotate action = where handler :: Exception e => e -> IO a handler = throwIO . BuildFailure mlogFile . annotate . toException - diff --git a/cabal-install/Distribution/Client/ProjectPlanning.hs b/cabal-install/Distribution/Client/ProjectPlanning.hs index e559f62a37b..8afc66d9abb 100644 --- a/cabal-install/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/Distribution/Client/ProjectPlanning.hs @@ -3409,8 +3409,6 @@ setupHsHaddockFlags :: ElaboratedConfiguredPackage -> Verbosity -> FilePath -> Cabal.HaddockFlags --- TODO: reconsider whether or not Executables/TestSuites/... --- needed for component setupHsHaddockFlags (ElaboratedConfiguredPackage{..}) _ verbosity builddir = Cabal.HaddockFlags { haddockProgramPaths = mempty, --unused, set at configure time diff --git a/cabal-install/Distribution/Client/Setup.hs b/cabal-install/Distribution/Client/Setup.hs index 2377f6d92c9..c459e95e4a0 100644 --- a/cabal-install/Distribution/Client/Setup.hs +++ b/cabal-install/Distribution/Client/Setup.hs @@ -24,6 +24,7 @@ module Distribution.Client.Setup , replCommand, testCommand, benchmarkCommand , configureExOptions, reconfigureCommand , installCommand, InstallFlags(..), installOptions, defaultInstallFlags + , filterHaddockArgs, filterHaddockFlags , defaultSolver, defaultMaxBackjumps , listCommand, ListFlags(..) , updateCommand, UpdateFlags(..), defaultUpdateFlags @@ -1642,6 +1643,30 @@ installCommand = CommandUI { get3 (_,_,c,_) = c; set3 c (a,b,_,d) = (a,b,c,d) get4 (_,_,_,d) = d; set4 d (a,b,c,_) = (a,b,c,d) +filterHaddockArgs :: [String] -> Version -> [String] +filterHaddockArgs args cabalLibVersion + | cabalLibVersion >= mkVersion [2,3,0] = args_latest + | cabalLibVersion < mkVersion [2,3,0] = args_2_3_0 + | otherwise = args_latest + where + args_latest = args + + -- Cabal < 2.3 doesn't know about per-component haddock + args_2_3_0 = [] + +filterHaddockFlags :: HaddockFlags -> Version -> HaddockFlags +filterHaddockFlags flags cabalLibVersion + | cabalLibVersion >= mkVersion [2,3,0] = flags_latest + | cabalLibVersion < mkVersion [2,3,0] = flags_2_3_0 + | otherwise = flags_latest + where + flags_latest = flags + + flags_2_3_0 = flags_latest { + -- Cabal < 2.3 doesn't know about per-component haddock + haddockArgs = [] + } + haddockOptions :: ShowOrParseArgs -> [OptionField HaddockFlags] haddockOptions showOrParseArgs = [ opt { optionName = "haddock-" ++ name, diff --git a/cabal-install/Distribution/Client/SetupWrapper.hs b/cabal-install/Distribution/Client/SetupWrapper.hs index f25d5af12a6..4da0f1149f2 100644 --- a/cabal-install/Distribution/Client/SetupWrapper.hs +++ b/cabal-install/Distribution/Client/SetupWrapper.hs @@ -392,7 +392,7 @@ verbosityHack ver args0 runSetupCommand :: Verbosity -> Setup -> CommandUI flags -- ^ command definition -> flags -- ^ command flags - -> [String] -- ^ extra command-line arguments + -> [String] -- ^ extra command-line arguments -> IO () runSetupCommand verbosity setup cmd flags extraArgs = do let args = commandName cmd : commandShowOptions cmd flags ++ extraArgs @@ -406,11 +406,13 @@ setupWrapper :: Verbosity -> CommandUI flags -> (Version -> flags) -- ^ produce command flags given the Cabal library version - -> [String] + -> (Version -> [String]) -> IO () setupWrapper verbosity options mpkg cmd flags extraArgs = do setup <- getSetup verbosity options mpkg - runSetupCommand verbosity setup cmd (flags $ setupVersion setup) extraArgs + runSetupCommand verbosity setup + cmd (flags $ setupVersion setup) + (extraArgs $ setupVersion setup) -- ------------------------------------------------------------ -- * Internal SetupMethod diff --git a/cabal-install/Distribution/Client/SrcDist.hs b/cabal-install/Distribution/Client/SrcDist.hs index 07bf914e61e..ca494a7ad7c 100644 --- a/cabal-install/Distribution/Client/SrcDist.hs +++ b/cabal-install/Distribution/Client/SrcDist.hs @@ -69,7 +69,7 @@ sdist flags exflags = do -- Run 'setup sdist --output-directory=tmpDir' (or -- '--list-source'/'--output-directory=someOtherDir') in case we were passed -- those options. - setupWrapper verbosity setupOpts (Just pkg) sdistCommand (const flags') [] + setupWrapper verbosity setupOpts (Just pkg) sdistCommand (const flags') (const []) -- Unless we were given --list-sources or --output-directory ourselves, -- create an archive. @@ -176,7 +176,7 @@ allPackageSourceFiles verbosity setupOpts0 packageDir = do doListSources :: IO [FilePath] doListSources = do - setupWrapper verbosity setupOpts (Just pkg) sdistCommand (const flags) [] + setupWrapper verbosity setupOpts (Just pkg) sdistCommand (const flags) (const []) fmap lines . readFile $ file onFailedListSources :: IOException -> IO ()