Skip to content

Commit 80bc4ca

Browse files
committed
Extend the InstalledPackageInfo record with 2 fields for artifacts.
These 2 fields involve configuration flags that affect which build artifacts (dynamic and static files) are provided. (This record corresponds to the ‘.conf’ files in the package-db directories, and Cabal-syntax provides an interface to this record. Cabal-syntax is used as a dependency by ‘ghc-pkg’ and ‘cabal-install’, and old Cabal-syntax implementations may produce an ‘Unknown field’ warning when used with new ‘.conf’ files.) Add these IPI build artifact fields to enable tracking build artifacts in installed packages. The modular resolver could then use these new fields to filter out installed package options missing required build artifacts that would lead to a failing build plan.
1 parent 8aad429 commit 80bc4ca

File tree

10 files changed

+52
-8
lines changed

10 files changed

+52
-8
lines changed

Cabal-syntax/src/Distribution/Types/InstalledPackageInfo.hs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ data InstalledPackageInfo
9292
frameworks :: [String],
9393
haddockInterfaces :: [FilePath],
9494
haddockHTMLs :: [FilePath],
95-
pkgRoot :: Maybe FilePath
95+
pkgRoot :: Maybe FilePath,
96+
-- Artifacts included in this package:
97+
providesStaticArtifacts :: Bool,
98+
providesDynamicArtifacts :: Bool
9699
}
97100
deriving (Eq, Generic, Typeable, Read, Show)
98101

@@ -173,5 +176,7 @@ emptyInstalledPackageInfo
173176
haddockInterfaces = [],
174177
haddockHTMLs = [],
175178
pkgRoot = Nothing,
176-
libVisibility = LibraryVisibilityPrivate
179+
libVisibility = LibraryVisibilityPrivate,
180+
providesStaticArtifacts = True,
181+
providesDynamicArtifacts = True
177182
}

Cabal-syntax/src/Distribution/Types/InstalledPackageInfo/FieldGrammar.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ ipiFieldGrammar = mkInstalledPackageInfo
121121
<@> monoidalFieldAla "haddock-interfaces" (alaList' FSep FilePathNT) L.haddockInterfaces
122122
<@> monoidalFieldAla "haddock-html" (alaList' FSep FilePathNT) L.haddockHTMLs
123123
<@> optionalFieldAla "pkgroot" FilePathNT L.pkgRoot
124+
<@> booleanFieldDef "provides-static-artifacts" L.providesStaticArtifacts True
125+
<@> booleanFieldDef "provides-dynamic-artifacts" L.providesDynamicArtifacts True
124126
where
125127
mkInstalledPackageInfo _ Basic {..} = InstalledPackageInfo
126128
-- _basicPkgName is not used

Cabal-syntax/src/Distribution/Types/InstalledPackageInfo/Lens.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,11 @@ libVisibility :: Lens' InstalledPackageInfo LibraryVisibility
196196
libVisibility f s = fmap (\x -> s { T.libVisibility = x }) (f (T.libVisibility s))
197197
{-# INLINE libVisibility #-}
198198

199+
providesStaticArtifacts :: Lens' InstalledPackageInfo Bool
200+
providesStaticArtifacts f s = fmap (\x -> s { T.providesStaticArtifacts = x }) (f (T.providesStaticArtifacts s))
201+
{-# INLINE providesStaticArtifacts #-}
202+
203+
providesDynamicArtifacts :: Lens' InstalledPackageInfo Bool
204+
providesDynamicArtifacts f s = fmap (\x -> s { T.providesDynamicArtifacts = x }) (f (T.providesDynamicArtifacts s))
205+
{-# INLINE providesDynamicArtifacts #-}
206+

Cabal-tests/tests/ParserTests/ipi/Includes2.expr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,6 @@ InstalledPackageInfo {
8989
haddockHTMLs =
9090
[
9191
"/home/travis/build/haskell/cabal/cabal-testsuite/PackageTests/Backpack/Includes2/cabal-internal.dist/work/./dist/build/x86_64-linux/ghc-8.2.2/Includes2-0.1.0.0/l/mylib/Includes2-0.1.0.0-inplace-mylib+3gY9SyjX86dBypHcOaev1n/doc/html/Includes2"],
92-
pkgRoot = Nothing}
92+
pkgRoot = Nothing,
93+
providesStaticArtifacts = True,
94+
providesDynamicArtifacts = True}

Cabal-tests/tests/ParserTests/ipi/internal-preprocessor-test.expr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,6 @@ InstalledPackageInfo {
7373
"/home/ogre/Documents/other-haskell/cabal/cabal-testsuite/PackageTests/CustomPreProcess/setup.dist/work/dist/doc/html/internal-preprocessor-test"],
7474
pkgRoot =
7575
Just
76-
"/home/ogre/Documents/other-haskell/cabal/cabal-testsuite/PackageTests/CustomPreProcess/setup.dist/work/dist"}
76+
"/home/ogre/Documents/other-haskell/cabal/cabal-testsuite/PackageTests/CustomPreProcess/setup.dist/work/dist",
77+
providesStaticArtifacts = True,
78+
providesDynamicArtifacts = True}

Cabal-tests/tests/ParserTests/ipi/issue-2276-ghc-9885.expr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2181,4 +2181,6 @@ InstalledPackageInfo {
21812181
"/opt/ghc/8.2.2/share/doc/ghc-8.2.2/html/libraries/transformers-0.5.2.0/transformers.haddock"],
21822182
haddockHTMLs = [
21832183
"/opt/ghc/8.2.2/share/doc/ghc-8.2.2/html/libraries/transformers-0.5.2.0"],
2184-
pkgRoot = Nothing}
2184+
pkgRoot = Nothing,
2185+
providesStaticArtifacts = True,
2186+
providesDynamicArtifacts = True}

Cabal-tests/tests/ParserTests/ipi/transformers.expr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,6 @@ InstalledPackageInfo {
181181
haddockHTMLs = [
182182
"/opt/ghc/8.2.2/share/doc/ghc-8.2.2/html/libraries/transformers-0.5.2.0"],
183183
pkgRoot = Just
184-
"/opt/ghc/8.2.2/lib/ghc-8.2.2"}
184+
"/opt/ghc/8.2.2/lib/ghc-8.2.2",
185+
providesStaticArtifacts = True,
186+
providesDynamicArtifacts = True}

Cabal-tests/tests/UnitTests/Distribution/Utils/Structured.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ tests = testGroup "Distribution.Utils.Structured"
2929
, testCase "GenericPackageDescription" $
3030
md5Check (Proxy :: Proxy GenericPackageDescription) 0xa3e9433662ecf0c7a3c26f6d75a53ba1
3131
, testCase "LocalBuildInfo" $
32-
md5Check (Proxy :: Proxy LocalBuildInfo) 0x91ffcd61bbd83525e8edba877435a031
32+
md5Check (Proxy :: Proxy LocalBuildInfo) 0x89eabee921ae834a5222e4a10ce68439
3333
#endif
3434
]
3535

Cabal/src/Distribution/Simple/Register.hs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,9 @@ generalInstalledPackageInfo adjustRelIncDirs pkg abi_hash lib lbi clbi installDi
448448
IPI.haddockInterfaces = [haddockdir installDirs </> haddockName pkg],
449449
IPI.haddockHTMLs = [htmldir installDirs],
450450
IPI.pkgRoot = Nothing,
451-
IPI.libVisibility = libVisibility lib
451+
IPI.libVisibility = libVisibility lib,
452+
IPI.providesStaticArtifacts = providesStaticArtifacts,
453+
IPI.providesDynamicArtifacts = providesDynamicArtifacts
452454
}
453455
where
454456
ghc84 = case compilerId $ compiler lbi of
@@ -492,6 +494,15 @@ generalInstalledPackageInfo adjustRelIncDirs pkg abi_hash lib lbi clbi installDi
492494
= (libdir installDirs : dynlibdir installDirs : extraLibDirs bi, [])
493495
-- the compiler doesn't understand the dynamic-library-dirs field so we
494496
-- add the dyn directory to the "normal" list in the library-dirs field
497+
(providesStaticArtifacts, providesDynamicArtifacts) = case compilerFlavor comp of
498+
GHC ->
499+
let
500+
none f t = all (not . f) t
501+
libDefaults = none ($ lbi) [withVanillaLib, withSharedLib] && hasLibrary
502+
statics = libDefaults || any ($ lbi) [withVanillaLib]
503+
dynamics = any ($ lbi) [withSharedLib]
504+
in (statics, dynamics)
505+
_ -> (True, True) -- Assume nothing is missing.
495506

496507
-- | Construct 'InstalledPackageInfo' for a library that is in place in the
497508
-- build tree.

changelog.d/pr-8692

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
synopsis: Extend the InstalledPackageInfo record with fields for artifacts.
2+
packages: Cabal-syntax Cabal Cabal-tests
3+
prs: #8692
4+
description: {
5+
Extend the InstalledPackageInfo record with new fields involving build
6+
artifact configuration. The moduler resolver could then (in a separate set
7+
of changes) use these new fields to avoid selecting installed package
8+
options missing required artifacts and producing build plans that would
9+
fail, even if alternatives would succeed.
10+
}

0 commit comments

Comments
 (0)