haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.63k stars 696 forks source link

cabal: Error: Could not find module: "Added_prepossor_module_name" with any suffix #6124

Open mdgabriel opened 5 years ago

mdgabriel commented 5 years ago

Describe the bug % cabal v2-sdist cabal: Error: Could not find module: SciDbAFL with any suffix: ["gc","chs","hsc","x","y","ly","cpphs","hs","lhs","hsig","lhsig"]. If the module is autogenerated it should be added to 'autogen-modules'.

I have added the preprocessor bnfc to a custom Setup. The file SciDbAFL.cf is not found.

To Reproduce % cabal v2-sdist

Here is a snip of the custom Setup:

main :: IO () main = defaultMainWithHooks simpleUserHooks{hookedPreProcessors = ("cf",ppBnfc):knownSuffixHandlers}

The input file to bnfc is SciDbAFL.cf and the appropriate snip of my scidb-hquery.cabal is

other-modules: SciDbAFL AbsSciDbAFL ErrM LexSciDbAFL ParSciDbAFL PrintSciDbAFL

autogen-modules: AbsSciDbAFL ErrM LexSciDbAFL ParSciDbAFL PrintSciDbAFL

Where to find the problem In the file cabal-install-2.4.1.0/Distribution/Client/CmdSdist.hs, in the the function packageToSdist, the following line of code only uses knownSuffixHandlers:

listPackageSources verbosity (flattenPackageDescription $ packageDescription pkg) knownSuffixHandlers

For example, as a test, if I hard code

listPackageSources verbosity (flattenPackageDescription $ packageDescription pkg) (("cf",undefined):knownSuffixHandlers)

then my hacked cabal v2-sdist works.

Expected behavior I expect cabal v2-sdist to not only use the the knownSuffixHandlers but also those in hookedPreProcessors.

Work around I have an (ugly) work around. One just adds SciDbAFL to autogen-modules, which it is of course not, and one adds it also to

extra-source-files: src/SciDbAFL.cf

As I understand it, this respects what nix wishes to accomplish.

System informataion

Additional context The issue was discovered with a cabal package that I am creating that uses bnfc --haskell via the hookedPreProcessors record.

phadej commented 5 years ago

https://github.com/haskell/cabal/issues/5908 is partially related.

IIRC @typedrat and @hvr think that v2-sdist should be completely static, i.e. don't care about build-type: Custom (I cannot find a discussion atm). This is clearly a counterexample.

Mikolaj commented 3 years ago

@mdgabriel: We would love to limit the use of Custom scripts (and surely make cabal dist ignorant of anything of the sort). Since this ticket was raised, did you perchance discover a way forward without them? Or could something by added to cabal to make it possible?