Commit 898b284e authored by Francesco Gazzetta's avatar Francesco Gazzetta

Move CLibName and CSubLibName to a separate type

This gives us more type safety when dealing with libraries only
parent c15a8d6c
......@@ -343,6 +343,7 @@ library
Distribution.Types.ModuleReexport
Distribution.Types.ModuleRenaming
Distribution.Types.ComponentName
Distribution.Types.LibraryName
Distribution.Types.MungedPackageName
Distribution.Types.PackageName
Distribution.Types.PkgconfigName
......
......@@ -66,8 +66,8 @@ mkComponentsGraph enabled pkg_descr =
(CExeName <$> getAllInternalToolDependencies pkg_descr bi)
++ [ if pkgname == packageName pkg_descr
then CLibName
else CSubLibName toolname
then CLibName LMainLibName
else CLibName (LSubLibName toolname)
| Dependency pkgname _ <- targetBuildDepends bi
, let toolname = packageNameToUnqualComponentName pkgname
, toolname `elem` internalPkgDeps ]
......
......@@ -150,7 +150,7 @@ mkConfiguredComponent pkg_descr this_cid lib_deps exe_deps component = do
bi = componentBuildInfo component
deps_map = Map.fromList [ ((packageName dep, ann_cname dep), dep)
| dep <- lib_deps ]
is_public = componentName component == CLibName
is_public = componentName component == CLibName LMainLibName
type ConfiguredComponentMap =
Map PackageName (Map ComponentName (AnnotatedId ComponentId))
......@@ -192,7 +192,7 @@ toConfiguredComponent pkg_descr this_cid lib_dep_map exe_dep_map component = do
| (pn, comp_map) <- Map.toList lib_dep_map
, pn /= packageName pkg_descr
, (cn, e) <- Map.toList comp_map
, cn == CLibName ]
, cn == CLibName LMainLibName ]
-- We have to nub here, because 'getAllToolDependencies' may return
-- duplicates (see #4986). (NB: This is not needed for lib_deps,
-- since those elaborate into includes, for which there explicitly
......@@ -296,8 +296,8 @@ newPackageDepsBehaviour pkg =
fixFakePkgName :: PackageDescription -> PackageName -> (PackageName, ComponentName)
fixFakePkgName pkg_descr pn =
if subLibName `elem` internalLibraries
then (packageName pkg_descr, CSubLibName subLibName)
else (pn, CLibName)
then (packageName pkg_descr, CLibName (LSubLibName subLibName))
else (pn, CLibName LMainLibName )
where
subLibName = packageNameToUnqualComponentName pn
internalLibraries = mapMaybe libName (allLibraries pkg_descr)
......@@ -23,6 +23,7 @@ import Distribution.ModuleName
import Distribution.Types.IncludeRenaming
import Distribution.Types.PackageName
import Distribution.Types.ComponentName
import Distribution.Types.LibraryName
import Distribution.Backpack
import Distribution.Backpack.ModSubst
......@@ -113,8 +114,8 @@ dispComponent pn cn =
-- should be clear enough. To do source syntax, we'd
-- need to know what the package we're linking is.
case cn of
CLibName -> disp pn
CSubLibName ucn -> disp pn <<>> colon <<>> disp ucn
CLibName LMainLibName -> disp pn
CLibName (LSubLibName ucn) -> disp pn <<>> colon <<>> disp ucn
-- Case below shouldn't happen
_ -> disp pn <+> parens (disp cn)
......
......@@ -25,6 +25,7 @@ import Distribution.Types.Component
import Distribution.Types.ComponentInclude
import Distribution.Types.ComponentId
import Distribution.Types.ComponentName
import Distribution.Types.LibraryName
import Distribution.Types.PackageId
import Distribution.Types.UnitId
import Distribution.Compat.Graph (IsNode(..))
......@@ -139,8 +140,8 @@ rc_depends rc = ordNub $
computeCompatPackageId
(ci_pkgid ci)
(case ci_cname ci of
CLibName -> Nothing
CSubLibName uqn -> Just uqn
CLibName LMainLibName -> Nothing
CLibName (LSubLibName uqn) -> Just uqn
_ -> error $ display (rc_cid rc) ++
" depends on non-library " ++ display (ci_id ci))
......
......@@ -441,8 +441,8 @@ ci_msg ci
pn = pkgName (ci_pkgid ci)
pp_pn =
case ci_cname ci of
CLibName -> disp pn
CSubLibName cn -> disp pn <<>> colon <<>> disp cn
CLibName LMainLibName -> disp pn
CLibName (LSubLibName cn) -> disp pn <<>> colon <<>> disp cn
-- Shouldn't happen
cn -> disp pn <+> parens (disp cn)
......
......@@ -54,6 +54,7 @@ import Distribution.ModuleName
import Distribution.Package hiding (installedPackageId, installedUnitId)
import Distribution.ParseUtils
import Distribution.Types.ComponentName
import Distribution.Types.LibraryName
import Distribution.Utils.Generic (toUTF8BS)
import qualified Data.Map as Map
......@@ -104,8 +105,8 @@ installedPackageId = installedUnitId
sourceComponentName :: InstalledPackageInfo -> ComponentName
sourceComponentName ipi =
case sourceLibName ipi of
Nothing -> CLibName
Just qn -> CSubLibName qn
Nothing -> CLibName LMainLibName
Just qn -> CLibName $ LSubLibName qn
-- -----------------------------------------------------------------------------
-- Parsing
......
......@@ -86,6 +86,7 @@ module Distribution.PackageDescription (
allBuildDepends,
enabledBuildDepends,
ComponentName(..),
LibraryName(..),
defaultLibName,
HookedBuildInfo,
emptyHookedBuildInfo,
......@@ -135,5 +136,6 @@ import Distribution.Types.CondTree
import Distribution.Types.Condition
import Distribution.Types.PackageDescription
import Distribution.Types.ComponentName
import Distribution.Types.LibraryName
import Distribution.Types.HookedBuildInfo
import Distribution.Types.SourceRepo
......@@ -344,12 +344,14 @@ overallDependencies enabled (TargetSet targets) = mconcat depss
-- UGH. The embedded componentName in the 'Component's here is
-- BLANK. I don't know whose fault this is but I'll use the tag
-- instead. -- ezyang
removeDisabledSections (Lib _) = componentNameRequested enabled CLibName
removeDisabledSections (Lib _) = componentNameRequested
enabled
(CLibName LMainLibName)
removeDisabledSections (SubComp t c)
-- Do NOT use componentName
= componentNameRequested enabled
$ case c of
CLib _ -> CSubLibName t
CLib _ -> CLibName (LSubLibName t)
CFLib _ -> CFLibName t
CExe _ -> CExeName t
CTest _ -> CTestName t
......
......@@ -470,7 +470,7 @@ testSuiteLibV09AsLibAndExe pkg_descr
, componentInternalDeps = componentInternalDeps clbi
, componentIsIndefinite_ = False
, componentExeDeps = componentExeDeps clbi
, componentLocalName = CSubLibName (testName test)
, componentLocalName = CLibName $ LSubLibName $ testName test
, componentIsPublic = False
, componentIncludes = componentIncludes clbi
, componentUnitId = componentUnitId clbi
......
......@@ -502,8 +502,8 @@ pkgComponentInfo pkg =
, let bi = componentBuildInfo c ]
componentStringName :: Package pkg => pkg -> ComponentName -> ComponentStringName
componentStringName pkg CLibName = prettyShow (packageName pkg)
componentStringName _ (CSubLibName name) = unUnqualComponentName name
componentStringName pkg (CLibName LMainLibName ) = prettyShow (packageName pkg)
componentStringName _ (CLibName (LSubLibName name)) = unUnqualComponentName name
componentStringName _ (CFLibName name) = unUnqualComponentName name
componentStringName _ (CExeName name) = unUnqualComponentName name
componentStringName _ (CTestName name) = unUnqualComponentName name
......@@ -555,8 +555,7 @@ data ComponentKind = LibKind | FLibKind | ExeKind | TestKind | BenchKind
deriving (Eq, Ord, Show)
componentKind :: ComponentName -> ComponentKind
componentKind CLibName = LibKind
componentKind (CSubLibName _) = LibKind
componentKind (CLibName _) = LibKind
componentKind (CFLibName _) = FLibKind
componentKind (CExeName _) = ExeKind
componentKind (CTestName _) = TestKind
......
......@@ -889,7 +889,7 @@ dependencySatisfiable
-- Except for internal deps, when we're NOT per-component mode;
-- those are just True.
then True
else (depName, CLibName) `Map.member` requiredDepsMap
else (depName, CLibName LMainLibName) `Map.member` requiredDepsMap
| isInternalDep
= if use_external_internal_deps
......@@ -1227,7 +1227,7 @@ selectDependency pkgid internalIndex installedIndex requiredDepsMap
-- We have to look it up externally
do_external is_internal = do
ipi <- case Map.lookup (dep_pkgname, CLibName) requiredDepsMap of
ipi <- case Map.lookup (dep_pkgname, CLibName LMainLibName) requiredDepsMap of
-- If we know the exact pkg to use, then use it.
Just pkginstance -> Right pkginstance
-- Otherwise we just pick an arbitrary instance of the latest version.
......@@ -1410,8 +1410,8 @@ combinedConstraints constraints dependencies installedPackages = do
dependenciesPkgInfo :: [(PackageName, ComponentName, ComponentId,
Maybe InstalledPackageInfo)]
dependenciesPkgInfo =
[ (pkgname, cname, cid, mpkg)
| GivenComponent pkgname cname cid <- dependencies
[ (pkgname, CLibName lname, cid, mpkg)
| GivenComponent pkgname lname cid <- dependencies
, let mpkg = PackageIndex.lookupComponentId
installedPackages cid
]
......@@ -1427,8 +1427,8 @@ combinedConstraints constraints dependencies installedPackages = do
hsep [ text "--dependency="
<<>> quotes
(pretty pkgname
<<>> case cname of CLibName -> ""
CSubLibName n -> ":" <<>> pretty n
<<>> case cname of CLibName LMainLibName -> ""
CLibName (LSubLibName n) -> ":" <<>> pretty n
_ -> ":" <<>> pretty cname
<<>> char '='
<<>> pretty cid)
......
......@@ -29,6 +29,7 @@ module Distribution.Simple.LocalBuildInfo (
-- * Buildable package components
Component(..),
ComponentName(..),
LibraryName(..),
defaultLibName,
showComponentName,
componentNameString,
......@@ -108,11 +109,11 @@ componentBuildDir :: LocalBuildInfo -> ComponentLocalBuildInfo -> FilePath
componentBuildDir lbi clbi
= buildDir lbi </>
case componentLocalName clbi of
CLibName ->
CLibName LMainLibName ->
if prettyShow (componentUnitId clbi) == prettyShow (componentComponentId clbi)
then ""
else prettyShow (componentUnitId clbi)
CSubLibName s ->
CLibName (LSubLibName s) ->
if prettyShow (componentUnitId clbi) == prettyShow (componentComponentId clbi)
then unUnqualComponentName s
else prettyShow (componentUnitId clbi)
......
......@@ -652,9 +652,8 @@ configureOptions showOrParseArgs =
(parsecToReadE (const "dependency expected") ((\x -> [x]) `fmap` parsecGivenComponent))
(map (\(GivenComponent pn cn cid) ->
prettyShow pn
++ case cn of CLibName -> ""
CSubLibName n -> ":" ++ prettyShow n
_ -> ":" ++ prettyShow cn
++ case cn of LMainLibName -> ""
LSubLibName n -> ":" ++ prettyShow n
++ "=" ++ prettyShow cid)))
,option "" ["instantiate-with"]
......@@ -740,15 +739,15 @@ showProfDetailLevelFlag (Flag dl) = [showProfDetailLevel dl]
parsecGivenComponent :: ParsecParser GivenComponent
parsecGivenComponent = do
pn <- parsec
cn <- P.option CLibName $ do
ln <- P.option LMainLibName $ do
_ <- P.char ':'
ucn <- parsec
return $ if unUnqualComponentName ucn == unPackageName pn
then CLibName
else CSubLibName ucn
then LMainLibName
else LSubLibName ucn
_ <- P.char '='
cid <- parsec
return $ GivenComponent pn cn cid
return $ GivenComponent pn ln cid
installDirsOptions :: [OptionField (InstallDirs (Flag PathTemplate))]
installDirsOptions =
......
......@@ -3,7 +3,6 @@
module Distribution.Types.ComponentName (
ComponentName(..),
defaultLibName,
libraryComponentName,
showComponentName,
componentNameStanza,
......@@ -16,14 +15,14 @@ import Distribution.Compat.Prelude
import qualified Distribution.Compat.ReadP as Parse
import Distribution.Compat.ReadP ((<++))
import Distribution.Types.UnqualComponentName
import Distribution.Types.LibraryName
import Distribution.Pretty
import Distribution.Text
import Text.PrettyPrint as Disp
-- Libraries live in a separate namespace, so must distinguish
data ComponentName = CLibName
| CSubLibName UnqualComponentName
data ComponentName = CLibName LibraryName
| CFLibName UnqualComponentName
| CExeName UnqualComponentName
| CTestName UnqualComponentName
......@@ -34,39 +33,32 @@ instance Binary ComponentName
-- Build-target-ish syntax
instance Pretty ComponentName where
pretty CLibName = Disp.text "lib"
pretty (CSubLibName str) = Disp.text "lib:" <<>> pretty str
pretty (CLibName lib) = pretty lib
pretty (CFLibName str) = Disp.text "flib:" <<>> pretty str
pretty (CExeName str) = Disp.text "exe:" <<>> pretty str
pretty (CTestName str) = Disp.text "test:" <<>> pretty str
pretty (CBenchName str) = Disp.text "bench:" <<>> pretty str
instance Text ComponentName where
parse = parseComposite <++ parseSingle
parse = parseComposite <++ parseLib
where
parseSingle = Parse.string "lib" >> return CLibName
parseLib = CLibName <$> parse
parseComposite = do
ctor <- Parse.choice [ Parse.string "lib:" >> return CSubLibName
, Parse.string "flib:" >> return CFLibName
ctor <- Parse.choice [ Parse.string "flib:" >> return CFLibName
, Parse.string "exe:" >> return CExeName
, Parse.string "bench:" >> return CBenchName
, Parse.string "test:" >> return CTestName ]
ctor <$> parse
defaultLibName :: ComponentName
defaultLibName = CLibName
showComponentName :: ComponentName -> String
showComponentName CLibName = "library"
showComponentName (CSubLibName name) = "library '" ++ display name ++ "'"
showComponentName (CLibName lib) = showLibraryName lib
showComponentName (CFLibName name) = "foreign library '" ++ display name ++ "'"
showComponentName (CExeName name) = "executable '" ++ display name ++ "'"
showComponentName (CTestName name) = "test suite '" ++ display name ++ "'"
showComponentName (CBenchName name) = "benchmark '" ++ display name ++ "'"
componentNameStanza :: ComponentName -> String
componentNameStanza CLibName = "library"
componentNameStanza (CSubLibName name) = "library " ++ display name
componentNameStanza (CLibName lib) = libraryNameStanza lib
componentNameStanza (CFLibName name) = "foreign-library " ++ display name
componentNameStanza (CExeName name) = "executable " ++ display name
componentNameStanza (CTestName name) = "test-suite " ++ display name
......@@ -77,8 +69,7 @@ componentNameStanza (CBenchName name) = "benchmark " ++ display name
-- @Nothing@ if the 'ComponentName' was for the public
-- library.
componentNameString :: ComponentName -> Maybe UnqualComponentName
componentNameString CLibName = Nothing
componentNameString (CSubLibName n) = Just n
componentNameString (CLibName lib) = libraryNameString lib
componentNameString (CFLibName n) = Just n
componentNameString (CExeName n) = Just n
componentNameString (CTestName n) = Just n
......@@ -87,5 +78,5 @@ componentNameString (CBenchName n) = Just n
-- | Convert the 'UnqualComponentName' of a library into a
-- 'ComponentName'.
libraryComponentName :: Maybe UnqualComponentName -> ComponentName
libraryComponentName Nothing = CLibName
libraryComponentName (Just n) = CSubLibName n
libraryComponentName Nothing = CLibName LMainLibName
libraryComponentName (Just n) = CLibName $ LSubLibName n
......@@ -7,19 +7,20 @@ module Distribution.Types.GivenComponent (
import Distribution.Compat.Prelude
import Distribution.Types.ComponentId
import Distribution.Types.ComponentName
import Distribution.Types.LibraryName
import Distribution.Types.PackageName
-- | A 'GivenComponent' represents a component depended on and explicitly
-- | A 'GivenComponent' represents a library depended on and explicitly
-- specified by the user/client with @--dependency@
--
-- It enables Cabal to know which 'ComponentId' to associate with a component
-- It enables Cabal to know which 'ComponentId' to associate with a library
--
-- @since 2.3.0.0
data GivenComponent =
GivenComponent
{ givenComponentPackage :: PackageName
, givenComponentName :: ComponentName
, givenComponentName :: LibraryName -- --dependency is for libraries
-- only, not for any component
, givenComponentId :: ComponentId }
deriving (Generic, Read, Show, Eq, Typeable)
......
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
module Distribution.Types.LibraryName (
LibraryName(..),
defaultLibName,
maybeToLibraryName,
showLibraryName,
libraryNameStanza,
libraryNameString,
) where
import Prelude ()
import Distribution.Compat.Prelude
import qualified Distribution.Compat.ReadP as Parse
import Distribution.Compat.ReadP ((<++))
import Distribution.Types.UnqualComponentName
import Distribution.Pretty
import Distribution.Text
import Text.PrettyPrint as Disp
data LibraryName = LMainLibName
| LSubLibName UnqualComponentName
deriving (Eq, Generic, Ord, Read, Show, Typeable)
instance Binary LibraryName
-- Build-target-ish syntax
instance Pretty LibraryName where
pretty LMainLibName = Disp.text "lib"
pretty (LSubLibName str) = Disp.text "lib:" <<>> pretty str
instance Text LibraryName where
parse = parseComposite <++ parseSingle
where
parseSingle = Parse.string "lib" >> return LMainLibName
parseComposite = do
ctor <- Parse.string "lib:" >> return LSubLibName
ctor <$> parse
defaultLibName :: LibraryName
defaultLibName = LMainLibName
showLibraryName :: LibraryName -> String
showLibraryName LMainLibName = "library"
showLibraryName (LSubLibName name) = "library '" ++ display name ++ "'"
libraryNameStanza :: LibraryName -> String
libraryNameStanza LMainLibName = "library"
libraryNameStanza (LSubLibName name) = "library " ++ display name
libraryNameString :: LibraryName -> Maybe UnqualComponentName
libraryNameString LMainLibName = Nothing
libraryNameString (LSubLibName n) = Just n
-- | Convert the 'UnqualComponentName' of a library into a
-- 'LibraryName'.
maybeToLibraryName :: Maybe UnqualComponentName -> LibraryName
maybeToLibraryName Nothing = LMainLibName
maybeToLibraryName (Just n) = LSubLibName n
......@@ -176,7 +176,7 @@ instance Binary LocalBuildInfo
-- on the package ID.
localComponentId :: LocalBuildInfo -> ComponentId
localComponentId lbi =
case componentNameCLBIs lbi CLibName of
case componentNameCLBIs lbi (CLibName LMainLibName) of
[LibComponentLocalBuildInfo { componentComponentId = cid }]
-> cid
_ -> mkComponentId (display (localPackage lbi))
......@@ -191,7 +191,7 @@ localPackage lbi = package (localPkgDescr lbi)
-- the package ID.
localUnitId :: LocalBuildInfo -> UnitId
localUnitId lbi =
case componentNameCLBIs lbi CLibName of
case componentNameCLBIs lbi (CLibName LMainLibName) of
[LibComponentLocalBuildInfo { componentUnitId = uid }]
-> uid
_ -> mkLegacyUnitId $ localPackage lbi
......@@ -201,7 +201,7 @@ localUnitId lbi =
-- on the package ID.
localCompatPackageKey :: LocalBuildInfo -> String
localCompatPackageKey lbi =
case componentNameCLBIs lbi CLibName of
case componentNameCLBIs lbi (CLibName LMainLibName) of
[LibComponentLocalBuildInfo { componentCompatPackageKey = pk }]
-> pk
_ -> display (localPackage lbi)
......
......@@ -77,6 +77,7 @@ import Distribution.Types.ComponentRequestedSpec
import Distribution.Types.Dependency
import Distribution.Types.PackageId
import Distribution.Types.ComponentName
import Distribution.Types.LibraryName
import Distribution.Types.PackageName
import Distribution.Types.UnqualComponentName
import Distribution.Types.SetupBuildInfo
......@@ -449,8 +450,8 @@ enabledComponents :: PackageDescription -> ComponentRequestedSpec -> [Component]
enabledComponents pkg enabled = filter (componentEnabled enabled) $ pkgBuildableComponents pkg
lookupComponent :: PackageDescription -> ComponentName -> Maybe Component
lookupComponent pkg CLibName = fmap CLib (library pkg)
lookupComponent pkg (CSubLibName name) =
lookupComponent pkg (CLibName LMainLibName) = fmap CLib (library pkg)
lookupComponent pkg (CLibName (LSubLibName name)) =
fmap CLib $ find ((Just name ==) . libName) (subLibraries pkg)
lookupComponent pkg (CFLibName name) =
fmap CFLib $ find ((name ==) . foreignLibName) (foreignLibs pkg)
......
......@@ -23,6 +23,7 @@ import Distribution.Types.ForeignLib (ForeignLib, foreignLibModules)
import Distribution.Types.ForeignLib.Lens (foreignLibName, foreignLibBuildInfo)
import Distribution.Types.Library (Library, explicitLibModules)
import Distribution.Types.Library.Lens (libName, libBuildInfo)
import Distribution.Types.LibraryName (LibraryName(..))
import Distribution.Types.PackageDescription (PackageDescription)
import Distribution.Types.PackageId (PackageIdentifier)
import Distribution.Types.SetupBuildInfo (SetupBuildInfo)
......@@ -158,8 +159,8 @@ extraDocFiles f s = fmap (\x -> s { T.extraDocFiles = x }) (f (T.extraDocFiles s
-- | @since 2.4
componentModules :: Monoid r => ComponentName -> Getting r PackageDescription [ModuleName]
componentModules cname = case cname of
CLibName -> library . traverse . getting explicitLibModules
CSubLibName name ->
CLibName LMainLibName -> library . traverse . getting explicitLibModules
CLibName (LSubLibName name) ->
componentModules' name subLibraries (libName . non "") explicitLibModules
CFLibName name ->
componentModules' name foreignLibs foreignLibName foreignLibModules
......@@ -194,9 +195,9 @@ componentModules cname = case cname of
-- | @since 2.4
componentBuildInfo :: ComponentName -> Traversal' PackageDescription BuildInfo
componentBuildInfo cname = case cname of
CLibName ->
CLibName LMainLibName ->
library . traverse . libBuildInfo
CSubLibName name ->
CLibName (LSubLibName name) ->
componentBuildInfo' name subLibraries (libName . non "") libBuildInfo
CFLibName name ->
componentBuildInfo' name foreignLibs foreignLibName foreignLibBuildInfo
......
......@@ -15,6 +15,8 @@ import Distribution.Package
( packageId, PackageName, packageName )
import Distribution.Types.ComponentName
( showComponentName )
import Distribution.Types.LibraryName
( LibraryName(..) )
import Distribution.Solver.Types.OptionalStanza
( OptionalStanza(..) )
import Distribution.Text
......@@ -165,8 +167,8 @@ targetSelectorFilter TargetComponent{} = Nothing
targetSelectorFilter TargetComponentUnknown{} = Nothing
renderComponentName :: PackageName -> ComponentName -> String
renderComponentName pkgname CLibName = "library " ++ display pkgname
renderComponentName _ (CSubLibName name) = "library " ++ display name
renderComponentName pkgname (CLibName LMainLibName) = "library " ++ display pkgname
renderComponentName _ (CLibName (LSubLibName name)) = "library " ++ display name
renderComponentName _ (CFLibName name) = "foreign library " ++ display name
renderComponentName _ (CExeName name) = "executable " ++ display name
renderComponentName _ (CTestName name) = "test suite " ++ display name
......
......@@ -651,10 +651,9 @@ entriesForLibraryComponents :: TargetsMap -> [GhcEnvironmentFileEntry]
entriesForLibraryComponents = Map.foldrWithKey' (\k v -> mappend (go k v)) []
where
hasLib :: (ComponentTarget, [TargetSelector]) -> Bool
hasLib (ComponentTarget CLibName _, _) = True
hasLib (ComponentTarget (CSubLibName _) _, _) = True
hasLib _ = False
hasLib (ComponentTarget (CLibName _) _, _) = True
hasLib _ = False
go :: UnitId -> [(ComponentTarget, [TargetSelector])] -> [GhcEnvironmentFileEntry]
go unitId targets
| any hasLib targets = [GhcEnvFilePackageId unitId]
......
......@@ -256,7 +256,8 @@ configureSetupScript packageDBs
-- Return the setup dependencies computed by the solver
ReadyPackage cpkg <- mpkg
return [ ( cid, srcid )
| ConfiguredId srcid (Just PkgDesc.CLibName) cid <- CD.setupDeps (confPkgDeps cpkg)
| ConfiguredId srcid (Just (PkgDesc.CLibName PkgDesc.LMainLibName)) cid
<- CD.setupDeps (confPkgDeps cpkg)
]
-- | Warn if any constraints or preferences name packages that are not in the
......@@ -403,9 +404,11 @@ configurePackage verbosity platform comp scriptOptions configFlags
-- deps. In the end only one set gets passed to Setup.hs configure,
-- depending on the Cabal version we are talking to.
configConstraints = [ thisPackageVersion srcid
| ConfiguredId srcid (Just PkgDesc.CLibName) _uid <- CD.nonSetupDeps deps ],
| ConfiguredId srcid (Just (PkgDesc.CLibName PkgDesc.LMainLibName)) _uid
<- CD.nonSetupDeps deps ],
configDependencies = [ GivenComponent (packageName srcid) cname uid
| ConfiguredId srcid (Just cname) uid <- CD.nonSetupDeps deps ],
| ConfiguredId srcid (Just (PkgDesc.CLibName cname)) uid
<- CD.nonSetupDeps deps ],
-- Use '--exact-configuration' if supported.
configExactConfiguration = toFlag True,
configVerbosity = toFlag verbosity,
......
......@@ -36,6 +36,7 @@ import Distribution.Text
import Distribution.Pretty
( prettyShow )
import Distribution.Types.ComponentName
import Distribution.Types.LibraryName
import Distribution.System
......@@ -199,8 +200,8 @@ defaultDistDirLayout projectRoot mdistDirectory =
display (distParamPackageId params) </>
(case distParamComponentName params of
Nothing -> ""
Just CLibName -> ""
Just (CSubLibName name) -> "l" </> display name
Just (CLibName LMainLibName) -> ""
Just (CLibName (LSubLibName name)) -> "l" </> display name
Just (CFLibName name) -> "f" </> display name
Just (CExeName name) -> "x" </> display name
Just (CTestName name) -> "t" </> display name
......@@ -282,4 +283,4 @@ mkCabalDirLayout cabalDir mstoreDir mlogDir =
cabalStoreDirLayout =
defaultStoreDirLayout (fromMaybe (cabalDir </> "store") mstoreDir)
cabalLogsDirectory = fromMaybe (cabalDir </> "logs") mlogDir
cabalWorldFile = cabalDir </> "world"
\ No newline at end of file