Commit eb789dca authored by Duncan Coutts's avatar Duncan Coutts

Use the --extra-prog-path flag in cabal-install

We have to pass it properly in the setupWrapper. For the external build
method we just set the $PATH rather than passing the flag. This way it
works when talking to Setup.hs built with an older Cabal lib.
parent 046c0866
......@@ -20,6 +20,7 @@ module Distribution.Simple.Program.Run (
runProgramInvocation,
getProgramInvocationOutput,
getEffectiveEnvironment,
) where
import Distribution.Simple.Program.Types
......
......@@ -240,16 +240,19 @@ configureOptions = commandOptions configureCommand
filterConfigureFlags :: ConfigFlags -> Version -> ConfigFlags
filterConfigureFlags flags cabalLibVersion
| cabalLibVersion >= Version [1,14,0] [] = flags
| cabalLibVersion >= Version [1,17,0] [] = flags
| cabalLibVersion < Version [1,3,10] [] = flags_1_3_10
| cabalLibVersion < Version [1,10,0] [] = flags_1_10_0
| cabalLibVersion < Version [1,14,0] [] = flags_1_14_0
| cabalLibVersion < Version [1,17,0] [] = flags_1_17_0
-- A no-op that silences the "pattern match is non-exhaustive" warning.
| otherwise = flags
where
-- Cabal < 1.17.0 doesn't know about --extra-prog-path.
flags_1_17_0 = flags { configProgramPathExtra = [] }
-- Cabal < 1.14.0 doesn't know about --disable-benchmarks.
flags_1_14_0 = flags { configBenchmarks = NoFlag }
flags_1_14_0 = flags_1_17_0 { configBenchmarks = NoFlag }
-- Cabal < 1.10.0 doesn't know about --disable-tests.
flags_1_10_0 = flags_1_14_0 { configTests = NoFlag }
-- Cabal < 1.3.10 does not grok the constraints flag.
......
......@@ -46,7 +46,11 @@ import Distribution.Simple.Compiler
, PackageDB(..), PackageDBStack )
import Distribution.Simple.Program
( ProgramConfiguration, emptyProgramConfiguration
, getDbProgramOutput, runDbProgram, ghcProgram )
, getProgramSearchPath, getDbProgramOutput, runDbProgram, ghcProgram )
import Distribution.Simple.Program.Find
( programSearchPathAsPATHVar )
import Distribution.Simple.Program.Run
( getEffectiveEnvironment )
import Distribution.Simple.BuildPaths
( defaultDistPref, exeExtension )
import Distribution.Simple.Command
......@@ -217,7 +221,7 @@ externalSetupMethod verbosity options pkg bt mkargs = do
-- types?
Simple -> getCachedSetupExecutable options' cabalLibVersion setupHs
_ -> compileSetupExecutable options' cabalLibVersion setupHs False
invokeSetupScript path (mkargs cabalLibVersion)
invokeSetupScript options' path (mkargs cabalLibVersion)
where
workingDir = case fromMaybe "" (useWorkingDir options) of
......@@ -422,8 +426,8 @@ externalSetupMethod verbosity options pkg bt mkargs = do
where
setupProgFile = setupDir </> "setup" <.> exeExtension
invokeSetupScript :: FilePath -> [String] -> IO ()
invokeSetupScript path args = do
invokeSetupScript :: SetupScriptOptions -> FilePath -> [String] -> IO ()
invokeSetupScript options' path args = do
info verbosity $ unwords (path : args)
case useLoggingHandle options of
Nothing -> return ()
......@@ -436,8 +440,12 @@ externalSetupMethod verbosity options pkg bt mkargs = do
-- working directory.
path' <- tryCanonicalizePath path
searchpath <- programSearchPathAsPATHVar
(getProgramSearchPath (useProgramConfig options'))
env <- getEffectiveEnvironment [("PATH", Just searchpath)]
process <- runProcess path' args
(useWorkingDir options) Nothing
(useWorkingDir options) env
Nothing (useLoggingHandle options) (useLoggingHandle options)
exitCode <- waitForProcess process
unless (exitCode == ExitSuccess) $ exitWith exitCode
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment