Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply command line flags to install packages (#8637) #8779

Merged
merged 2 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

}