Skip to content

Commit

Permalink
Apply command line flags to install packages (haskell#8637) (haskell#…
Browse files Browse the repository at this point in the history
…8779)

* Apply command line flags to install packages (haskell#8637)

* remove expectBroken on NonIgnoredConfigs test

---------

Co-authored-by: gbaz <[email protected]>
  • Loading branch information
patrickdoc and gbaz authored Feb 24, 2023
1 parent 0eb638f commit 76670eb
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
23 changes: 18 additions & 5 deletions cabal-install/src/Distribution/Client/CmdInstall.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import Distribution.Client.Types
, SourcePackageDb(..) )
import qualified Distribution.Client.InstallPlan as InstallPlan
import Distribution.Package
( Package(..), PackageName, unPackageName )
( Package(..), PackageName, mkPackageName, unPackageName )
import Distribution.Types.PackageId
( PackageIdentifier(..) )
import Distribution.Client.ProjectConfig
Expand All @@ -53,6 +53,7 @@ import Distribution.Client.ProjectFlags (ProjectFlags (..))
import Distribution.Client.ProjectConfig.Types
( ProjectConfig(..), ProjectConfigShared(..)
, ProjectConfigBuildOnly(..), PackageConfig(..)
, MapMappend(..)
, getMapLast, getMapMappend, projectConfigLogsDir
, projectConfigStoreDir, projectConfigBuildOnly
, projectConfigConfigFile )
Expand Down Expand Up @@ -430,12 +431,24 @@ installAction flags@NixStyleFlags { extraFlags = clientInstallFlags', .. } targe
configFlags' = disableTestsBenchsByDefault configFlags
verbosity = fromFlagOrDefault normal (configVerbosity configFlags')
ignoreProject = flagIgnoreProject projectFlags
cliConfig = commandLineFlagsToProjectConfig
globalFlags
flags { configFlags = configFlags' }
clientInstallFlags'
baseCliConfig = commandLineFlagsToProjectConfig
globalFlags
flags { configFlags = configFlags' }
clientInstallFlags'
cliConfig = addLocalConfigToTargets baseCliConfig targetStrings
globalConfigFlag = projectConfigConfigFile (projectConfigShared cliConfig)

-- | Treat all direct targets of install command as local packages: #8637
addLocalConfigToTargets :: ProjectConfig -> [String] -> ProjectConfig
addLocalConfigToTargets config targetStrings
= config {
projectConfigSpecificPackage = projectConfigSpecificPackage config
<> MapMappend (Map.fromList targetPackageConfigs)
}
where
localConfig = projectConfigLocalPackages config
targetPackageConfigs = map (\x -> (mkPackageName x, localConfig)) targetStrings

-- | Verify that invalid config options were not passed to the install command.
--
-- If an invalid configuration is found the command will @die'@.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ linkConfigFlags Dynamic =
lrun :: [Linking]
lrun = [Static, Dynamic, Static, Dynamic]

main = cabalTest . expectBroken 8744 $ do
main = cabalTest $ do
-- Skip if on Windows, since my default Chocolatey Windows setup (and the CI
-- server setup at the time, presumably) lacks support for dynamic builds
-- since the base package appears to be static only, lacking e.g. ‘.dyn_o’
Expand Down
13 changes: 13 additions & 0 deletions changelog.d/issue-8637
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
synopsis: Apply command line flags to install packages
packages: cabal-install
prs: #8779
issues: #8637

description: {

- Command line flags usually only apply to "local" packages (packages specified
in the cabal.project). This change causes the v2-install command to ignore
that distinction to better match the expected behavior for packages specified
directly in the command.

}

0 comments on commit 76670eb

Please sign in to comment.