UU-ComputerScience / uuagc

3 stars 9 forks source link

UUAGC cabal plugin fails with source-repository-package #8

Closed noughtmare closed 3 years ago

noughtmare commented 3 years ago

To reproduce:

  1. make a fresh cabal package
  2. add llvm-pretty-referential to the build-depends
  3. make a cabal-project file with these contents:
    
    packages: .

source-repository-package type: git location: https://github.com/noughtmare/llvm-pretty-referential.git tag: b927f1a81e90920dedbdd1d3645164a39473eb3d

4. Run `cabal build`

This results in:

[UUAGC] processing: src/Text/LLVM/AG.ag generating: dist/build/Text/LLVM/AG.hs Warning: No options found for src/Text/LLVM/AG.ag src/Text/LLVM/AG.ag:5:1: error: parser expecting EXTENDS or INCLUDE or a statement or end of file



It seems like the `uuagc_options` file is not being picked up when building the package in this way.
noughtmare commented 3 years ago

A workaround is to use x-agmodule instead of the uuagc_options file: https://github.com/noughtmare/llvm-pretty-referential/commit/0a45e9f4085525138bfb86964cb3659ad0159ac2

jbransen commented 3 years ago

The cabal plugin is quite fragile, and to be honest I am surprised we can even use it today. The proper solution would probably be to use Template Haskell for the AG definitions instead of preprocessing via cabal, but that would be a significant change, for which I unfortunately do not have the time.

noughtmare commented 3 years ago

Actually, this was a silly mistake by me. The problem is that I didn't add the uuagc_options file to the extra-source-files in the cabal file of llvm-pretty-referential. Here is an alternative simple fix that also works: https://github.com/noughtmare/llvm-pretty-referential/commit/ee0287cb94ed1274bde3cd7848560c180858b3ac.

Looking back on all the ideas in #10, I think that would still require a lot of work and I am starting to question if it really would be much more stable. In fact, I think Template Haskell changes much more often than a Custom cabal setup. So, maybe we should just slightly improve the Custom setup rather than porting the whole thing over to Template Haskell? I think it should be possible to add errors or warnings for things like the uuagc_options file missing from the extra-source-files field. And a little bit of documentation would go a long way.