From 06d69f8d60d6275385ba82300c87e162e62192d9 Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Fri, 3 Nov 2023 14:09:25 +0100 Subject: [PATCH] Can't add `Lex/Par` to `autogen-modules` in `BNFC.cabal` 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`. --- source/BNFC.cabal | 8 ++++++++ source/Makefile | 9 +++++++++ source/src/Makefile | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/source/BNFC.cabal b/source/BNFC.cabal index a072d3d3..e2bca22a 100644 --- a/source/BNFC.cabal +++ b/source/BNFC.cabal @@ -153,6 +153,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 diff --git a/source/Makefile b/source/Makefile index 6849b7b1..36db959b 100644 --- a/source/Makefile +++ b/source/Makefile @@ -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 diff --git a/source/src/Makefile b/source/src/Makefile index 043c2427..0ffaa63d 100644 --- a/source/src/Makefile +++ b/source/src/Makefile @@ -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