Mafia option to build a single sub-component of a project.
Motivation: I have a project which has a library component and a pre-processor which generates some code, in this case it dumps out the generated code for a bunch of lenses. The generator needs to get built independently of the library.
Solution: Have an option to do an equivalent tocabal build generate which only builds the generate target in the cabal file.
For now my work around is to use a combination of
mafia lock # Generate the build env / sandbox
cabal build generate
# nasty shell manipulation to copy generated code into library src
mafia build # Build the actual library
I wouldn't mind taking a stab at this feature. Has anyone started looking into it yet?
@ggranberry Sorry, have done this a couple of times, your questions seem to make me see issues I have missed.
@tmcgilchrist @ggranberry Isn't this what mafia already does, it is just a layer of cabal build. You can always call mafia build <component with same syntax of cabal, i.e. mafia build lib:foo , mafia build exe:foo when there is a name clash, or mafia build foo when there isn't.
Currently mafia needs to be run in a directory with a cabal file. If that cabal file contains multiple targets (eg a library, one or more test suites, a benchmark and a number of executables) then it is possible to run mafia build <exe> or mafia build bench` and have mafia build whatever is needed for that target.
However, if I have say a git repo containing directories foo-core, foo-io and foo-cli, each with their own cabal file, then from the top level (which does not have a cabal file) mafia cannot do anything. I think @tmcgilchrist and @ggranberry are showing their exposure to stack (or maybe cabal new-build) here. With this directory structure and a top level stack.yaml file, it would be possible to run the command stack build foo-io:<component>.
So the question is, do we hack mafia to support this now and I don't think we should. Instead, I think we should wait just a bit until support for cabal.project files in the cabal new-build stuff is a little more fully baked. Once that stuff is done (and mafia supports cabal 2.2) then mafia could act as it does now when if finds a regular cabal file and act more like stack when it finds a cabal.project file.
I'm actually hacking a bit on https://github.com/erikd/jenga this weekend and hoping to get it reading stack.yaml files and writing cabal.project files.
@erikd Yeah, I've been using cabal-new for all my projects. I agree that waiting for cabal 2.2 support is probably the best action. I'll leave this one alone for now.