Skip to content

The cabal parser does not see common stanzas #9617

Closed
@Kleidukos

Description

@Kleidukos

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:  src
Result
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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions