diff -Nru cabal-install-head-2.5+git20190106.1.b96c601/debian/changelog cabal-install-head-2.5+git20190112.1.6a24235/debian/changelog --- cabal-install-head-2.5+git20190106.1.b96c601/debian/changelog 2019-01-06 23:45:41.000000000 +0000 +++ cabal-install-head-2.5+git20190112.1.6a24235/debian/changelog 2019-01-12 16:03:19.000000000 +0000 @@ -1,5 +1,5 @@ -cabal-install-head (2.5+git20190106.1.b96c601-6~18.10) cosmic; urgency=medium +cabal-install-head (2.5+git20190112.1.6a24235-6~18.10) cosmic; urgency=medium * Initial release - -- Herbert Valerio Riedel Mon, 07 Jan 2019 00:45:41 +0100 + -- Herbert Valerio Riedel Sat, 12 Jan 2019 17:03:19 +0100 diff -Nru cabal-install-head-2.5+git20190106.1.b96c601/src/Cabal-2.5.0.0/Distribution/Simple/Build.hs cabal-install-head-2.5+git20190112.1.6a24235/src/Cabal-2.5.0.0/Distribution/Simple/Build.hs --- cabal-install-head-2.5+git20190106.1.b96c601/src/Cabal-2.5.0.0/Distribution/Simple/Build.hs 2019-01-06 23:43:57.000000000 +0000 +++ cabal-install-head-2.5+git20190112.1.6a24235/src/Cabal-2.5.0.0/Distribution/Simple/Build.hs 2019-01-12 16:01:30.000000000 +0000 @@ -306,15 +306,15 @@ buildComponent verbosity numJobs pkg_descr lbi suffixes comp@(CBench bm@Benchmark { benchmarkInterface = BenchmarkExeV10 {} }) - clbi _ = do - let (exe, exeClbi) = benchmarkExeV10asExe bm clbi + clbi _distPref = do + let exe = benchmarkExeV10asExe bm preprocessComponent pkg_descr comp lbi clbi False verbosity suffixes extras <- preprocessExtras verbosity comp lbi setupMessage' verbosity "Building" (packageId pkg_descr) (componentLocalName clbi) (maybeComponentInstantiatedWith clbi) let ebi = buildInfo exe exe' = exe { buildInfo = addExtraCSources ebi extras } - buildExe verbosity numJobs pkg_descr lbi exe' exeClbi + buildExe verbosity numJobs pkg_descr lbi exe' clbi return Nothing @@ -406,13 +406,13 @@ replComponent replFlags verbosity pkg_descr lbi suffixes comp@(CBench bm@Benchmark { benchmarkInterface = BenchmarkExeV10 {} }) - clbi _ = do - let (exe, exeClbi) = benchmarkExeV10asExe bm clbi + clbi _distPref = do + let exe = benchmarkExeV10asExe bm preprocessComponent pkg_descr comp lbi clbi False verbosity suffixes extras <- preprocessExtras verbosity comp lbi let ebi = buildInfo exe exe' = exe { buildInfo = ebi { cSources = cSources ebi ++ extras } } - replExe replFlags verbosity pkg_descr lbi exe' exeClbi + replExe replFlags verbosity pkg_descr lbi exe' clbi replComponent _ verbosity _ _ _ @@ -435,6 +435,17 @@ } testSuiteExeV10AsExe TestSuite{} = error "testSuiteExeV10AsExe: wrong kind" +-- | Translate a exe-style 'Benchmark' component into an exe for building +benchmarkExeV10asExe :: Benchmark -> Executable +benchmarkExeV10asExe bm@Benchmark { benchmarkInterface = BenchmarkExeV10 _ mainFile } = + Executable { + exeName = benchmarkName bm, + modulePath = mainFile, + exeScope = ExecutablePublic, + buildInfo = benchmarkBuildInfo bm + } +benchmarkExeV10asExe Benchmark{} = error "benchmarkExeV10asExe: wrong kind" + -- | Translate a lib-style 'TestSuite' component into a lib + exe for building testSuiteLibV09AsLibAndExe :: PackageDescription -> TestSuite @@ -527,30 +538,6 @@ testSuiteLibV09AsLibAndExe _ TestSuite{} _ _ _ _ = error "testSuiteLibV09AsLibAndExe: wrong kind" --- | Translate a exe-style 'Benchmark' component into an exe for building -benchmarkExeV10asExe :: Benchmark -> ComponentLocalBuildInfo - -> (Executable, ComponentLocalBuildInfo) -benchmarkExeV10asExe bm@Benchmark { benchmarkInterface = BenchmarkExeV10 _ f } - clbi = - (exe, exeClbi) - where - exe = Executable { - exeName = benchmarkName bm, - modulePath = f, - exeScope = ExecutablePublic, - buildInfo = benchmarkBuildInfo bm - } - exeClbi = ExeComponentLocalBuildInfo { - componentUnitId = componentUnitId clbi, - componentComponentId = componentComponentId clbi, - componentLocalName = CExeName (benchmarkName bm), - componentInternalDeps = componentInternalDeps clbi, - componentExeDeps = componentExeDeps clbi, - componentPackageDeps = componentPackageDeps clbi, - componentIncludes = componentIncludes clbi - } -benchmarkExeV10asExe Benchmark{} _ = error "benchmarkExeV10asExe: wrong kind" - -- | Initialize a new package db file for libraries defined -- internally to the package. createInternalPackageDB :: Verbosity -> LocalBuildInfo -> FilePath diff -Nru cabal-install-head-2.5+git20190106.1.b96c601/src/Cabal-2.5.0.0/Distribution/Simple/GHCJS.hs cabal-install-head-2.5+git20190112.1.6a24235/src/Cabal-2.5.0.0/Distribution/Simple/GHCJS.hs --- cabal-install-head-2.5+git20190106.1.b96c601/src/Cabal-2.5.0.0/Distribution/Simple/GHCJS.hs 2019-01-06 23:43:57.000000000 +0000 +++ cabal-install-head-2.5+git20190112.1.6a24235/src/Cabal-2.5.0.0/Distribution/Simple/GHCJS.hs 2019-01-12 16:01:30.000000000 +0000 @@ -563,8 +563,11 @@ let isGhcjsDynamic = isDynamic comp dynamicTooSupported = supportsDynamicToo comp buildRunner = case clbi of - ExeComponentLocalBuildInfo {} -> False - _ -> True + LibComponentLocalBuildInfo {} -> False + FLibComponentLocalBuildInfo {} -> False + ExeComponentLocalBuildInfo {} -> True + TestComponentLocalBuildInfo {} -> True + BenchComponentLocalBuildInfo {} -> True isHaskellMain = elem (takeExtension srcMainFile) [".hs", ".lhs"] jsSrcs = jsSources exeBi cSrcs = cSources exeBi ++ [srcMainFile | not isHaskellMain] diff -Nru cabal-install-head-2.5+git20190106.1.b96c601/src/Cabal-2.5.0.0/Distribution/Simple/LocalBuildInfo.hs cabal-install-head-2.5+git20190112.1.6a24235/src/Cabal-2.5.0.0/Distribution/Simple/LocalBuildInfo.hs --- cabal-install-head-2.5+git20190106.1.b96c601/src/Cabal-2.5.0.0/Distribution/Simple/LocalBuildInfo.hs 2019-01-06 23:43:57.000000000 +0000 +++ cabal-install-head-2.5+git20190112.1.6a24235/src/Cabal-2.5.0.0/Distribution/Simple/LocalBuildInfo.hs 2019-01-12 16:01:30.000000000 +0000 @@ -161,7 +161,7 @@ withBenchLBI :: PackageDescription -> LocalBuildInfo -> (Benchmark -> ComponentLocalBuildInfo -> IO ()) -> IO () withBenchLBI pkg lbi f = - sequence_ [ f test clbi | (test, clbi) <- enabledBenchLBIs pkg lbi ] + sequence_ [ f bench clbi | (bench, clbi) <- enabledBenchLBIs pkg lbi ] withTestLBI :: PackageDescription -> LocalBuildInfo -> (TestSuite -> ComponentLocalBuildInfo -> IO ()) -> IO () diff -Nru cabal-install-head-2.5+git20190106.1.b96c601/src/Cabal-2.5.0.0/Distribution/Simple/PreProcess.hs cabal-install-head-2.5+git20190112.1.6a24235/src/Cabal-2.5.0.0/Distribution/Simple/PreProcess.hs --- cabal-install-head-2.5+git20190106.1.b96c601/src/Cabal-2.5.0.0/Distribution/Simple/PreProcess.hs 2019-01-06 23:43:57.000000000 +0000 +++ cabal-install-head-2.5+git20190112.1.6a24235/src/Cabal-2.5.0.0/Distribution/Simple/PreProcess.hs 2019-01-12 16:01:30.000000000 +0000 @@ -123,6 +123,12 @@ -- preprocessor's output name format. type PreProcessorExtras = FilePath -> IO [FilePath] +-- | A newtype around 'PreProcessorExtras', useful for storing +-- 'PreProcessorExtras' inside of another type constructor (e.g., a list) +-- without impredicativity (recall that the 'IO' type, which is contained in +-- 'PreProcessorExtras', is a synonym for @'HasCallStack' => Prelude.IO@, which +-- is a polymorphic type). +newtype WrappedPreProcessorExtras = WrapPPE { unWrapPPE :: PreProcessorExtras } mkSimplePreProcessor :: (FilePath -> FilePath -> Verbosity -> IO ()) -> (FilePath, FilePath) @@ -697,8 +703,8 @@ ] -- |Standard preprocessors with possible extra C sources: c2hs, hsc2hs. -knownExtrasHandlers :: [ PreProcessorExtras ] -knownExtrasHandlers = [ ppC2hsExtras, ppHsc2hsExtras ] +knownExtrasHandlers :: [ WrappedPreProcessorExtras ] +knownExtrasHandlers = [ WrapPPE ppC2hsExtras, WrapPPE ppHsc2hsExtras ] -- | Find any extra C sources generated by preprocessing that need to -- be added to the component (addresses issue #238). @@ -735,7 +741,7 @@ pp :: FilePath -> IO [FilePath] pp dir = (map (dir ) . filter not_sub . concat) <$> for knownExtrasHandlers - (withLexicalCallStack (\f -> f dir)) + (withLexicalCallStack (\f -> f dir) . unWrapPPE) -- TODO: This is a terrible hack to work around #3545 while we don't -- reorganize the directory layout. Basically, for the main -- library, we might accidentally pick up autogenerated sources for diff -Nru cabal-install-head-2.5+git20190106.1.b96c601/src/cabal-install-2.5.0.0/Distribution/Client/CmdRun.hs cabal-install-head-2.5+git20190112.1.6a24235/src/cabal-install-2.5.0.0/Distribution/Client/CmdRun.hs --- cabal-install-head-2.5+git20190106.1.b96c601/src/cabal-install-2.5.0.0/Distribution/Client/CmdRun.hs 2019-01-06 23:44:01.000000000 +0000 +++ cabal-install-head-2.5+git20190112.1.6a24235/src/cabal-install-2.5.0.0/Distribution/Client/CmdRun.hs 2019-01-12 16:01:35.000000000 +0000 @@ -9,7 +9,7 @@ -- * The @run@ CLI and action runCommand, runAction, - handleShebang, + handleShebang, validScript, -- * Internals exposed for testing TargetProblem(..), @@ -104,7 +104,7 @@ import System.Directory ( getTemporaryDirectory, removeDirectoryRecursive, doesFileExist ) import System.FilePath - ( () ) + ( (), isValid, isPathSeparator ) runCommand :: CommandUI (ConfigFlags, ConfigExFlags, InstallFlags, HaddockFlags, TestFlags) @@ -298,9 +298,31 @@ installFlags haddockFlags testFlags globalConfigFlag = projectConfigConfigFile (projectConfigShared cliConfig) -handleShebang :: String -> IO () -handleShebang script = - runAction (commandDefaultFlags runCommand) [script] defaultGlobalFlags +-- | Used by the main CLI parser as heuristic to decide whether @cabal@ was +-- invoked as a script interpreter, i.e. via +-- +-- > #! /usr/bin/env cabal +-- +-- or +-- +-- > #! /usr/bin/cabal +-- +-- As the first argument passed to `cabal` will be a filepath to the +-- script to be interpreted. +-- +-- See also 'handleShebang' +validScript :: String -> IO Bool +validScript script + | isValid script && any isPathSeparator script = doesFileExist script + | otherwise = return False + +-- | Handle @cabal@ invoked as script interpreter, see also 'validScript' +-- +-- First argument is the 'FilePath' to the script to be executed; second +-- argument is a list of arguments to be passed to the script. +handleShebang :: FilePath -> [String] -> IO () +handleShebang script args = + runAction (commandDefaultFlags runCommand) (script:args) defaultGlobalFlags parseScriptBlock :: BS.ByteString -> ParseResult Executable parseScriptBlock str = @@ -366,14 +388,14 @@ -- We need to create a dummy package that lives in our dummy project. let sourcePackage = SourcePackage - { packageInfoId = pkgId - , SP.packageDescription = genericPackageDescription - , packageSource = LocalUnpackedPackage tempDir - , packageDescrOverride = Nothing + { packageInfoId = pkgId + , SP.packageDescription = genericPackageDescription + , packageSource = LocalUnpackedPackage tempDir + , packageDescrOverride = Nothing } - genericPackageDescription = emptyGenericPackageDescription + genericPackageDescription = emptyGenericPackageDescription { GPD.packageDescription = packageDescription - , condExecutables = [("script", CondNode executable' targetBuildDepends [])] + , condExecutables = [("script", CondNode executable' targetBuildDepends [])] } executable' = executable { modulePath = "Main.hs" diff -Nru cabal-install-head-2.5+git20190106.1.b96c601/src/cabal-install-2.5.0.0/main/Main.hs cabal-install-head-2.5+git20190112.1.6a24235/src/cabal-install-2.5.0.0/main/Main.hs --- cabal-install-head-2.5+git20190106.1.b96c601/src/cabal-install-2.5.0.0/main/Main.hs 2019-01-06 23:44:01.000000000 +0000 +++ cabal-install-head-2.5+git20190112.1.6a24235/src/cabal-install-2.5.0.0/main/Main.hs 2019-01-12 16:01:35.000000000 +0000 @@ -186,7 +186,7 @@ import System.Environment (getArgs, getProgName) import System.Exit (exitFailure, exitSuccess) import System.FilePath ( dropExtension, splitExtension - , takeExtension, (), (<.>)) + , takeExtension, (), (<.>) ) import System.IO ( BufferMode(LineBuffering), hSetBuffering , stderr, stdout ) import System.Directory (doesFileExist, getCurrentDirectory) @@ -234,10 +234,9 @@ mainWorker :: [String] -> IO () mainWorker args = do - validScript <- - if null args - then return False - else doesFileExist (last args) + hasScript <- if not (null args) + then CmdRun.validScript (head args) + else return False topHandler $ case commandsRun (globalCommand commands) commands args of @@ -253,7 +252,7 @@ CommandHelp help -> printCommandHelp help CommandList opts -> printOptionsList opts CommandErrors errs - | validScript -> CmdRun.handleShebang (last args) + | hasScript -> CmdRun.handleShebang (head args) (tail args) | otherwise -> printErrors errs CommandReadyToGo action -> do globalFlags' <- updateSandboxConfigFileFlag globalFlags