Skip to content

Commit b9b3080

Browse files
committed
Add licenseFiles to InstalledPackageInfo
1 parent 0ab5571 commit b9b3080

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

Cabal-syntax/src/Distribution/PackageDescription/FieldGrammar.hs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,11 @@ packageDescriptionFieldGrammar =
152152
<$> uniqueField "name" L.pkgName
153153
<*> uniqueField "version" L.pkgVersion
154154

155-
licenseFilesGrammar =
156-
(++)
157-
-- TODO: neither field is deprecated
158-
-- should we pretty print license-file if there's single license file
159-
-- and license-files when more
160-
<$> monoidalFieldAla "license-file" CompatLicenseFile L.licenseFiles
155+
licenseFilesGrammar = (++)
156+
-- Always pretty print license-files
157+
<$> (monoidalFieldAla "license-file" CompatLicenseFile L.licenseFiles
158+
^^^ hiddenField)
161159
<*> monoidalFieldAla "license-files" (alaList FSep) L.licenseFiles
162-
^^^ hiddenField
163160

164161
-------------------------------------------------------------------------------
165162
-- Library

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ data InstalledPackageInfo = InstalledPackageInfo
5252
instantiatedWith :: [(ModuleName, OpenModule)]
5353
, compatPackageKey :: String
5454
, license :: Either SPDX.License License
55+
, licenseFiles :: [FilePath]
5556
, copyright :: !ShortText
5657
, maintainer :: !ShortText
5758
, author :: !ShortText
@@ -138,6 +139,7 @@ emptyInstalledPackageInfo =
138139
, instantiatedWith = []
139140
, compatPackageKey = ""
140141
, license = Left SPDX.NONE
142+
, licenseFiles = []
141143
, copyright = ""
142144
, maintainer = ""
143145
, author = ""

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ ipiFieldGrammar =
8888
<@> optionalFieldDefAla "instantiated-with" InstWith L.instantiatedWith []
8989
<@> optionalFieldDefAla "key" CompatPackageKey L.compatPackageKey ""
9090
<@> optionalFieldDefAla "license" SpecLicenseLenient L.license (Left SPDX.NONE)
91+
<@> monoidalFieldAla "license-files" (alaList' FSep FilePathNT) L.licenseFiles
9192
<@> freeTextFieldDefST "copyright" L.copyright
9293
<@> freeTextFieldDefST "maintainer" L.maintainer
9394
<@> freeTextFieldDefST "author" L.author

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ license :: Lens' InstalledPackageInfo (Either SPDX.License License)
4747
license f s = fmap (\x -> s{T.license = x}) (f (T.license s))
4848
{-# INLINE license #-}
4949

50+
licenseFiles :: Lens' InstalledPackageInfo [FilePath]
51+
licenseFiles f s = fmap (\x -> s{T.licenseFiles = x}) (f (T.licenseFiles s))
52+
{-# INLINE licenseFiles #-}
53+
5054
copyright :: Lens' InstalledPackageInfo ShortText
5155
copyright f s = fmap (\x -> s{T.copyright = x}) (f (T.copyright s))
5256
{-# INLINE copyright #-}

Cabal/src/Distribution/Simple/Register.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ import Distribution.Simple.Setup.Register
7979
import Distribution.Simple.Utils
8080
import Distribution.System
8181
import Distribution.Utils.MapAccum
82+
import Distribution.Utils.Path
8283
import Distribution.Verbosity as Verbosity
8384
import Distribution.Version
8485

@@ -511,6 +512,9 @@ generalInstalledPackageInfo adjustRelIncDirs pkg abi_hash lib lbi clbi installDi
511512
if ghc84
512513
then Left $ either id licenseToSPDX $ licenseRaw pkg
513514
else Right $ either licenseFromSPDX id $ licenseRaw pkg
515+
, IPI.licenseFiles =
516+
let doc = docdir installDirs
517+
in map ((doc </>) . getSymbolicPath) $ licenseFiles pkg
514518
, IPI.copyright = copyright pkg
515519
, IPI.maintainer = maintainer pkg
516520
, IPI.author = author pkg

0 commit comments

Comments
 (0)