AccelerateHS/accelerate

[BUG] Cabal.extra-source-files lists many non-existing cbits files

Closed this issue · 5 comments

Description

The directory cbits/tracy is empty, but Cabal.extra-source-files lists many subdirectories and cpp and hpp files.

Steps to reproduce

accelerate-git$ cabal sdist
cabal: sdist of accelerate-1.3.0.0: filepath wildcard
'cbits/tracy/public/*.cpp' refers to the directory 'cbits/tracy/public', which
does not exist or is not a directory.
filepath wildcard 'cbits/tracy/public/*.cpp' does not match any files.

Your environment

  • Accelerate: GIT-HEAD, currently 5ceb2da

If I recall correctly, the situation here is that those files do exist if the tracy submodule is cloned, which happens if the -fdebug flag is set. And in this case, the C files are actually needed. However, cabal does not allow putting a flag conditional around extra-source-files (perhaps for good reason), so we're in a catch.

What do you need an sdist for?

Aha, it seems I must pull a submodule.

Ok, my original problem is, I want to fetch accelerate/GIT-HEAD in a cabal.project.local:

source-repository-package
   type: git
   location: https://github.com/AccelerateHS/accelerate/
   tag: 5ceb2da5d9ddc4ea0a5705d46bf4de9321ba17da

and this fails because of the missing submodule. I must Cabal teach somehow to also pull that submodule.

When I build this project, Cabal fetches the Git repository and then seems to package that working copy with cabal sdist.

I see! If this is all you need, then the answer is:

source-repository-package
    ...
    post-checkout-command: bash -c "git submodule update --init --recursive"

for cabal >= 3.8. For cabal < 3.8, you'll need to put ! before git, because it had a bug where it thought a unix status code of 1 meant "true".

Perfect, this solves my problem!

Thanks for asking, now there is something that people can find when searching for the error message :)

EDIT: for future visitors: if you have a good idea how to manage this extra-source-files field where the contents depends on whether a cabal flag is enabled, please let us know. For the time being, this is what it is.