Repository navigation
Closed
Labels
Description
Using parseGenericPackageDescription, on a cabal file, it seems that common stanzas are not "seen" by the parser. By that I mean they are not expanded in the PackageDescription result.
Example:
Cabal file (truncated)
cabal-version: 3.0
name: libsodium-bindings
version: 0.0.1.1
license: BSD-3-Clause
build-type: Simple
tested-with:
GHC ==8.10.7 || ==9.0.2 || ==9.2.8 || ==9.4.8 || ==9.6.3
extra-source-files:
LICENSE
README.md
extra-doc-files: CHANGELOG.md
flag use-pkg-config
description: Use pkg-config to find Libsodium. Used by default on macOS.
default: False
manual: True
common common
build-depends: base >=4.14 && <5
if (os(osx) || flag(use-pkg-config))
pkgconfig-depends: libsodium ==1.0.18
extra-libraries: sodium
default-language: Haskell2010
common common-rts-options
ghc-options: -rtsopts -threaded -with-rtsopts=-N
library
import: common
hs-source-dirs: srcResult
PackageDescription
{ specVersion = CabalSpecV3_0
, package = PackageIdentifier{pkgName = PackageName "libsodium-bindings", pkgVersion = mkVersion [0, 0, 1, 1]}
, licenseRaw = Left (License (ELicense (ELicenseId BSD_3_Clause) Nothing))
, licenseFiles = []
, copyright = ""
, maintainer = "The Haskell Cryptography contributors"
, author = "H\233cate Moonlight, Koz Ross"
, stability = ""
, testedWith =
[
( GHC
, UnionVersionRanges
(ThisVersion (mkVersion [8, 10, 7]))
( UnionVersionRanges
(ThisVersion (mkVersion [9, 0, 2]))
( UnionVersionRanges
(ThisVersion (mkVersion [9, 2, 8]))
(UnionVersionRanges (ThisVersion (mkVersion [9, 4, 8])) (ThisVersion (mkVersion [9, 6, 3])))
)
)
)
]
, homepage = "https://github.com/haskell-cryptography/libsodium-bindings"
, pkgUrl = ""
, bugReports = "https://github.com/haskell-cryptography/libsodium-bindings/issues"
, sourceRepos =
[ SourceRepo
{ repoKind = RepoHead
, repoType = Just (KnownRepoType Git)
, repoLocation = Just "https://github.com/haskell-cryptography/libsodium-bindings"
, repoModule = Nothing
, repoBranch = Nothing
, repoTag = Nothing
, repoSubdir = Nothing
}
]
, synopsis = "FFI bindings to libsodium"
, description =
"This library embeds FFI bindings to the stable version of libsodium 1.0.18.\nThe interface exposed by this library is kept close to the C library."
, category = "Cryptography"
, customFieldsPD = []
, buildTypeRaw = Just Simple
, setupBuildInfo = Nothing
, library = Nothing
, subLibraries = []
, executables = []
, foreignLibs = []
, testSuites = []
, benchmarks = []
, dataFiles = []
, dataDir = "."
, extraSrcFiles = ["LICENSE", "README.md"]
, extraTmpFiles = []
, extraDocFiles = ["CHANGELOG.md"]
}We can see that there is no information whatsoever that is contained in the common stanza.
My question is the following: Which function do I need to call to take common stanzas into account in my PackageDescription?
Activity
jasagredo commentedon Jan 16, 2024
Could this be a degenerate case because there are no source files at all in the library?
Have you tried moving the common stanzas before the flags? Does cabal complain in verbose mode about "ignoring section blah"?
Kleidukos commentedon Jan 16, 2024
Apologies, I elided the files to make the example more concise, the actual cabal file has modules: https://github.com/haskell-cryptography/libsodium-bindings/blob/98fa256e355e1037337f1d9a0aa439dca5e48ffd/libsodium-bindings/libsodium-bindings.cabal
I will try this, thank you.
Kleidukos commentedon Jan 16, 2024
Update:
With the following file:
libsodium-bindings.cabal
I get the following result
Package Description
jasagredo commentedon Jan 16, 2024
What is the issue you are facing later on? The common stanzas might be expanded later on in the process (I think this is the case), so is there a specific problem you are facing?
fgaz commentedon Jan 16, 2024
How did you turn the GenericPackageDescription into a PackageDescription?
Kleidukos commentedon Jan 16, 2024
@jasagredo
There is no "later on" for me, I use the PackageDescription and I don't know how to get the stanzas (expanded or not).
@fgaz I'm just accessing the field
packageDescription: https://hackage.haskell.org/package/Cabal-syntax-3.10.2.0/docs/Distribution-Types-GenericPackageDescription.html#t:GenericPackageDescriptionfgaz commentedon Jan 16, 2024
The packageDescription field of GenericPackageDescription is only partially filled. The rest is in the CondTrees, still unresolved. To get a filled PackageDescription you have to use finalizePD or flattenPackageDescription. I think there's a comment about it where PackageDescription or finalizePD is defined.
Kleidukos commentedon Jan 16, 2024
Ah, indeed
finalizePD(andflattenPackageDescription) are not mentioned in https://hackage.haskell.org/package/Cabal-syntax-3.10.2.0/docs/Distribution-Types-GenericPackageDescription.html and https://hackage.haskell.org/package/Cabal-syntax-3.10.2.0/docs/Distribution-Types-PackageDescription.html#t:PackageDescription.I will try this, thank you!
Kleidukos commentedon Jan 16, 2024
Okay, indeed it was all in the generic package description:
GenericPackageDescription
fgaz commentedon Jan 16, 2024
Great :)