Skip to content
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

Mafia option to build a single sub-component of a project. #193

Open
tmcgilchrist opened this issue Dec 7, 2017 · 4 comments
Open

Mafia option to build a single sub-component of a project. #193

tmcgilchrist opened this issue Dec 7, 2017 · 4 comments

Comments

@tmcgilchrist
Copy link
Member

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
@ggranberry
Copy link
Contributor

I wouldn't mind taking a stab at this feature. Has anyone started looking into it yet?

@markhibberd
Copy link
Contributor

@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.

@erikd
Copy link
Contributor

erikd commented Jun 10, 2018

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.

@ggranberry
Copy link
Contributor

@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.

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

No branches or pull requests

4 participants