Skip to content

Commit

Permalink
Add a flag to allow depending on private libraries
Browse files Browse the repository at this point in the history
This is intended to be used by tools like cabal-install so they can add
multilibs-compatibility even to older ghcs
  • Loading branch information
fgaz committed Jun 8, 2019
1 parent f14d4a2 commit 88ecdd7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
7 changes: 6 additions & 1 deletion Cabal/Distribution/Simple/Configure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ configure (pkg_descr0, pbi) cfg = do
(dependencySatisfiable
use_external_internal_deps
(fromFlagOrDefault False (configExactConfiguration cfg))
(fromFlagOrDefault False (configAllowDependingOnPrivateLibs cfg))
(packageName pkg_descr0)
installedPackageSet
internalPackageSet
Expand Down Expand Up @@ -882,6 +883,7 @@ getInternalPackages pkg_descr0 =
dependencySatisfiable
:: Bool -- ^ use external internal deps?
-> Bool -- ^ exact configuration?
-> Bool -- ^ allow depending on private libs?
-> PackageName
-> InstalledPackageIndex -- ^ installed set
-> Map PackageName (Maybe UnqualComponentName) -- ^ internal set
Expand All @@ -890,7 +892,9 @@ dependencySatisfiable
-> (Dependency -> Bool)
dependencySatisfiable
use_external_internal_deps
exact_config pn installedPackageSet internalPackageSet requiredDepsMap
exact_config
allow_private_deps
pn installedPackageSet internalPackageSet requiredDepsMap
(Dependency depName vr sublibs)

| exact_config
Expand All @@ -915,6 +919,7 @@ dependencySatisfiable
requiredDepsMap)

|| all visible sublibs
|| allow_private_deps

| isInternalDep
= if use_external_internal_deps
Expand Down
13 changes: 12 additions & 1 deletion Cabal/Distribution/Simple/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,13 @@ data ConfigFlags = ConfigFlags {
-- ^Halt and show an error message indicating an error in flag assignment
configRelocatable :: Flag Bool, -- ^ Enable relocatable package built
configDebugInfo :: Flag DebugInfoLevel, -- ^ Emit debug info.
configUseResponseFiles :: Flag Bool
configUseResponseFiles :: Flag Bool,
-- ^ Whether to use response files at all. They're used for such tools
-- as haddock, or or ld.
configAllowDependingOnPrivateLibs :: Flag Bool
-- ^ Allow depending on private sublibraries. This is used by external
-- tools (like cabal-install) so they can add multiple-public-libraries
-- compatibility to older ghcs by checking visibility externally.
}
deriving (Generic, Read, Show)

Expand Down Expand Up @@ -703,6 +707,13 @@ configureOptions showOrParseArgs =
configUseResponseFiles
(\v flags -> flags { configUseResponseFiles = v })
(boolOpt' ([], ["disable-response-files"]) ([], []))

,option "" ["allow-depending-on-private-libs"]
( "Allow depending on private libraries. "
++ "If set, the library visibility check MUST be done externally." )
configAllowDependingOnPrivateLibs
(\v flags -> flags { configAllowDependingOnPrivateLibs = v })
trueArg
]
where
liftInstallDirs =
Expand Down
3 changes: 2 additions & 1 deletion cabal-install/Distribution/Client/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ instance Semigroup SavedConfig where
configExactConfiguration = combine configExactConfiguration,
configFlagError = combine configFlagError,
configRelocatable = combine configRelocatable,
configUseResponseFiles = combine configUseResponseFiles
configUseResponseFiles = combine configUseResponseFiles,
configAllowDependingOnPrivateLibs = combine configAllowDependingOnPrivateLibs
}
where
combine = combine' savedConfigureFlags
Expand Down
6 changes: 4 additions & 2 deletions cabal-install/Distribution/Client/ProjectConfig/Legacy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,8 @@ convertToLegacyAllPackageConfig
configFlagError = mempty, --TODO: ???
configRelocatable = mempty,
configDebugInfo = mempty,
configUseResponseFiles = mempty
configUseResponseFiles = mempty,
configAllowDependingOnPrivateLibs = mempty
}

haddockFlags = mempty {
Expand Down Expand Up @@ -757,7 +758,8 @@ convertToLegacyPerPackageConfig PackageConfig {..} =
configFlagError = mempty, --TODO: ???
configRelocatable = packageConfigRelocatable,
configDebugInfo = packageConfigDebugInfo,
configUseResponseFiles = mempty
configUseResponseFiles = mempty,
configAllowDependingOnPrivateLibs = mempty
}

installFlags = mempty {
Expand Down
3 changes: 3 additions & 0 deletions cabal-install/Distribution/Client/ProjectPlanning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3390,6 +3390,9 @@ setupHsConfigureFlags (ReadyPackage elab@ElaboratedConfiguredPackage{..})
configUserInstall = mempty -- don't rely on defaults
configPrograms_ = mempty -- never use, shouldn't exist
configUseResponseFiles = mempty
-- TODO set to true when the solver can prevent private-library-deps by itself
-- (issue #6039)
configAllowDependingOnPrivateLibs = mempty

setupHsConfigureArgs :: ElaboratedConfiguredPackage
-> [String]
Expand Down

0 comments on commit 88ecdd7

Please sign in to comment.