cabal-cargs icon indicating copy to clipboard operation
cabal-cargs copied to clipboard

Support builds that use `cabal new-build`

Open emilaxelsson opened this issue 7 years ago • 3 comments

It would be nice to be able to get paths in the dist-newstyle directory when that is being used. I noticed that cabal-lenses has a function findNewDistDir, but that won't work out of the box since dist-newstyle has a different structure than dist. For example, the build directory is found in something like:

dist-newstyle/build/x86_64-linux/ghc-8.4.3/my-package-0.1/build/

Do you think there's a way to make this work?

emilaxelsson avatar Aug 24 '18 19:08 emilaxelsson

What kind of paths do you need? I've added support for new-build to cabal-bounds by reading the plan.json file from the dist-newstyle directory. But you need something else, right?

dan-t avatar Aug 24 '18 22:08 dan-t

For example, running cabal-cargs in its own repository gives you this:

-ilib -iexe -itests -W -optP-DCABAL -package=base -package=cmdargs -package=lens -package=directory -package=transformers -package=text -package=system-filepath -package=system-fileio -package=unordered-containers -package=cabal-lenses -package=Cabal -package=bytestring -package=cabal-cargs -package=tasty -package=tasty-golden -package=filepath -idist/build/autogen -Idist/build/autogen -optP-include -optPcabal_macros.h

But the path dist/build/autogen should be dist-newstyle/build/x86_64-linux/ghc-8.4.3/cabal-cargs-1.0.0/build/autogen.

That seems a bit tricky to get right, given that the path depends on OS and GHC version.

emilaxelsson avatar Aug 25 '18 08:08 emilaxelsson

Ah, it seems the info can be obtained from plan.json:

       {
            "type":"configured",
            "id":"cabal-cargs-1.0.0-inplace",
            "pkg-name":"cabal-cargs",
            "pkg-version":"1.0.0",
            "flags":{},
            "style":"local",
            "dist-dir":"/home/emax/repos/cabal-cargs/dist-newstyle/build/x86_64-linux/ghc-8.4.3/cabal-cargs-1.0.0",
            ...

emilaxelsson avatar Aug 25 '18 08:08 emilaxelsson