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

Allow cabal to execute packager-defined commands #1354

Open
Jookia opened this issue Jun 1, 2013 · 5 comments
Open

Allow cabal to execute packager-defined commands #1354

Jookia opened this issue Jun 1, 2013 · 5 comments

Comments

@Jookia
Copy link
Contributor

Jookia commented Jun 1, 2013

With other build systems like Make you can add custom targets to do different tasks. An example is a 'lang' target to build language files. It'd be nice if custom targets could be added to Cabal.

@byorgey
Copy link
Member

byorgey commented Jun 2, 2013

I don't think I understand what you're asking for. (I'm not familiar with custom targets in make). Can you give some more specific examples of the kind of thing you would like to be able to do?

@Jookia
Copy link
Contributor Author

Jookia commented Jun 2, 2013

I'd like the ability to add a 'command' to my project somehow, then run 'cabal my_command' which would do what I want.

For instance, say I have a custom command for my project which uses Gettext to create catalogs from my source, then move them to a build directory.

In a hypothetical situation where Cabal has this feature, I'd add the command 'langfiles' to my project.cabal file, which has a name and description for the hypothetical project-specific command section of 'cabal help', and a command 'runhaskell scripts/langfiles.hs' that it'd run when the command is issued.
Then my Haskell file would read the PackageDescription stuff, go through my executables and libraries, scrape the strings from the source file and use Gettext to translate and put them in the appropriate folders in dist/.

Another hypothetical situation would be to have this in my .cabal file:

Custom-Command lint Help: Runs hlint on source code. Task: hlint source

Which would run hlint on my source file, and come up in 'cabal help' like so:

Commands:
install Installs a list of packages.
update Updates list of known packages
list List packages matching a search string.
...

Project Comands:
lint Runs hlint on source code.

I'm aware that Cabal is meant to build packages, but it's the only build system around that's easy to use, and I think it shows evidence that it does non-package-related stuff already with executable documentation, code coverage, tests and benchmarks. This kind of stuff would allow easy extendibility.

@23Skidoo
Copy link
Member

23Skidoo commented Jun 3, 2013

Note than you can combine Makefiles with Cabal. The Make build type allows you to delegate the work of actually building the package to make.

@Jookia
Copy link
Contributor Author

Jookia commented Jun 3, 2013

Yes, you can also override Setup.hs and 'hijack' getArgs to do some of your own stuff, but considering Distribution.Simple already has its own command infrastructure it'd be nice to expose this?

@ttuegel ttuegel changed the title No support for adding custom commands to Cabal. Allow cabal to execute packager-defined commands Apr 23, 2015
@ttuegel
Copy link
Member

ttuegel commented Apr 23, 2015

I renamed this to reflect the similarity to the recent #2349.

@ttuegel ttuegel added this to the Cabal-1.24 milestone Apr 23, 2015
@23Skidoo 23Skidoo modified the milestones: Cabal 1.24, Cabal 1.26 Feb 21, 2016
@ezyang ezyang modified the milestone: Cabal 2.0 Sep 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants