Skip to content

Commit

Permalink
Can't add Lex/Par to autogen-modules in BNFC.cabal
Browse files Browse the repository at this point in the history
These modules should not be shipped but be generated by `alex` and
`happy` **on the target system**.

However, if we add them to `autogen-modules` even the `Lex.x/Par.y` will
not be shipped with `cabal sdist`.

Solution is to make sure that there is no `Lex/Par.hs` along `Lex.x/Par.y`
when invoking `cabal sdist`.  This is embodied in new goal `make sdist`.
  • Loading branch information
andreasabel committed May 30, 2024
1 parent bfb34ee commit bd539f4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions source/BNFC.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ library
-- BNFC.Lex
-- -- Generated by happy
-- BNFC.Par
-- 2023-11-03 We cannot add BNFC.{Lex,Par} as then the Lex.x and Par.y files
-- are not bundled by cabal dist.
-- Just make sure that there is no src/BNFC/{Lex,Par}.hs before running cabal sdist,
-- otherwise we will end up with both Lex.hs and Lex.x (resp. Par.{hs,y})
-- which will cause alex/happy to not be run, leading to build failures.
autogen-modules:
-- Generated by cabal
Paths_BNFC
other-modules:
-- Generated by cabal
Paths_BNFC
Expand Down
9 changes: 9 additions & 0 deletions source/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ TAGS :
# Binary package (tgz, for linux)
bdist: dist/${BDIST_TAG}.tar.gz

# Source package
# Andreas, 2023-11-03, PR #466: need to remove BNFC/{Lex,Par}.hs,
# otherwise they will be shipped in the sdist package
# and cause compilation to fail.
sdist:
make -C src clean
cabal sdist

# OLD goal
dist/%.tar.gz:
cabal v1-clean
cabal v1-install ${CABAL_OPTS} --only-dependencies
Expand Down
4 changes: 4 additions & 0 deletions source/src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,8 @@ fake-cabal :
rm-fake-cabal :
rm inferior-haskell-find-project-root.cabal

.PHONY: clean
clean :
rm BNFC/Lex.hs BNFC/Par.hs BNFC/*.bak

#EOF

0 comments on commit bd539f4

Please sign in to comment.