haskell / haskell/cabal

Concept: There are two sorts of auto-generated files

Open
#7,488 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

Hi,

I, too, ran into the requirement to have a compiled Haskell binary print the Git hash it was derived from. There's a package for that (gitrev), which is [currently broken](https://github.com/acfoltzer/gitrev/issues/23) when using `cabal v2-install` (which seems to be the `cabal install` of the future).

And rightly so, `cabal v2-install` points out the dependency on `.git`, which should(?) not be there.

Finding a [workaround](https://github.com/s5k6/versionInfo) led me to recognize a **wider concept**. I now think that Cabal should discern two sorts of generated files:

1. **Early generated** files, that are not stored in the source repository but have to be present in a source distribution created by `cabal sdist`.

2. **Late generated** files, that are also not in the source distribution but are created during compilation.

If that was possible, then the git hash problem would reduce to a special case of the first sort.

I've elaborated on this part a bit, and provide my current attempt to include a git hash into a binary at

https://github.com/s5k6/versionInfo

This also demonstrates that all direct dependencies on `base` (which [not everybody](https://www.fpcomplete.com/haskell/library/rio/) may like) come from `Paths_…`, because its creation is out of my control. Generalising the idea of late generated code might encompass the generation of the `Paths_…` module. Giving control over its generation to the developer would *remove* [that complexity](https://github.com/haskell/cabal/blob/master/Cabal/src/Distribution/Simple/Build/Macros/Z.hs) from Cabal. This could be done via a simple developer-provided template that is used by Cabal to create the module. One could use Template Haskell, but I think even a blunt text-based approach would do, in less than 100 SLOC.

I do understand that there are others with a much deeper understanding of the build process and the implications of my approach. So here I'm asking whether this idea makes sense at all, and how to organise these two phases (if it makes sense).

Cheers
Stefan

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.