Skip to content

sdist ships (duplicate) generated modules in the source directories #7258

Open

Description

@andreasabel

Originating from #7251 (comment) :
cabal sdist includes useless, possibly generated modules in the package
Scenario:

  • Say I have in my modules in src/ a module M that is generated from M.x (alex lexer generator source file).
  • I run alex M.x in src, generating M.hs there.
  • Now module M is formally ambiguous, but cabal build will ignore the M.hs and use M.x.
  • However, sdist will include M.hs in the package.
  • I can even put arbitrary garbage into M.hs that will ignore in the build, but still be shipped with sdist.

Enhancement request:

  • If a module resolves to several source files, only sdist those that will actually be used by build.

To Reproduce
Steps to reproduce the behavior (uses BNFC and PR #7251):
[Without PR #7251, you might have to fix up the generated .cabal file.]

bnfc --version || cabal install BNFC
mkdir -p myparser
cd myparser
echo "Foo. Bar ::= Integer" > Foo.cf
bnfc -o src -d -m Foo.cf
make -C src
mv src/Foo/Test.hs Main.hs
cabal init --libandexe --application-dir=.
cabal sdist
find . -name "*.tar.gz" -exec tar tf {} \;

Notice the content of the generated archive with the redundant .hs files:

myparser-0.1.0.0/src/Foo/Lex.hs
myparser-0.1.0.0/src/Foo/Lex.x
myparser-0.1.0.0/src/Foo/Par.hs
myparser-0.1.0.0/src/Foo/Par.y

System information

  • cabal 3.5.0.0
  • ghc 8.10.3

Activity

  1. andreasabel commented on Dec 5, 2023

    @andreasabel
    MemberAuthor

    In the wild: cabal install java-adt-0.2018.11.4 fails.
    The tarball contains a generated Lexer.hs and Parser.hs adjacent to Lexer.x and Parser.y: https://hackage.haskell.org/package/java-adt-0.2018.11.4/src/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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