Skip to content

What could make this Setup.hs use case less heavyweight? #6795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gergoerdi opened this issue May 13, 2020 · 1 comment
Open

What could make this Setup.hs use case less heavyweight? #6795

gergoerdi opened this issue May 13, 2020 · 1 comment

Comments

@gergoerdi
Copy link

I was asked on #haskell to report this use case of a custom Setup.hs because apparently the Cabal developers would like to minimize such cases. My personal opinion is that my use case is so ad-hoc that there isn't much to solve in general -- but I am not an expert in Cabal at all.

I have written extensively about my use case at https://unsafeperform.io/blog/2020-05-07-integrating_verilator_and_clash_via_cabal/. Basically, depending on the value of some custom x- fields in the various Cabal components, I need to run some Haskell code (Clash's defaultMain), in a context where all Cabal dependencies are already available, in order to generate an .hsc file and an .a static library. The hsc file is then compiled the standard way, and the .a file is linked statically into the resulting exe or library.

There are at least two parts of this process that aren't directly supported by Cabal:

  • Generating multiple artifacts (a static library and an .hsc file) by one code generator / preprocessor
  • Multi-phase code generator pipeline: my tool generates an .hsc file, which then needs to be further processed by hsc2hs to get the final .hs file suitable for consumption by GHC.
@sheaf
Copy link
Collaborator

sheaf commented May 8, 2024

There are at least two parts of this process that aren't directly supported by Cabal:

  • Generating multiple artifacts (a static library and an .hsc file) by one code generator / preprocessor

  • Multi-phase code generator pipeline: my tool generates an .hsc file, which then needs to be further processed by hsc2hs to get the final .hs file suitable for consumption by GHC.

You should be able to do this now with build-type: Hooks. Both of those limitations are lifted by the notion of pre-build rules provided by build-type: Hooks. In fact, this would be a very nice illustration of the feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants