UU-ComputerScience / uuagc

3 stars 9 forks source link

The update-src-generated.sh is outdated #6

Closed noughtmare closed 3 years ago

noughtmare commented 3 years ago

It doesn't work anymore with the new cabal commands. The generated files are no longer stored in dist/build/. And, now, the LINE pragmas include the full file path which is not portable.

Maybe cabal has some options to get the relative file path back and to find the location of the generated .hs files.

EDIT: I actually think the old paths in half of the LINE pragmas were wrong anyway, so maybe those lines should just be filtered out or maybe they shouldn't be generated in the first place?

EDIT: So, half of the pragmas are not wrong (but they do point to the old location from before the files were moved into src-generated). They point back to the current file for errors that happen in portions of the code that were not based on lines in the original .ag file. We could rewrite these paths with a simple regex. Something like this should work:

$ find src-generated -type f -name "*.hs" -exec sed -i \
   's/^{-# LINE \([0-9]\+\) ".*\/build\/\(.*\.hs\)" #-}$/{-# LINE \1 "src-generated\/\2" #-}/' {} \;
noughtmare commented 3 years ago

Cool solution. It can cause problems if your GHC or UUAGC version changes (the old files will remain in their own directory), but that can be easily fixed by running cabal v2-clean.

jbransen commented 3 years ago

I drop the whole dist-newstyle directory, which is essentially the same as cabal v2-clean I guess.