vrom911
vrom911

Reputation: 694

How to pass custom command line arguments to Setup.hs

I have stack project. I want to be able to pass my own arguments to Setup.hs so that I could customize building process. How can I do that?

Upvotes: 2

Views: 143

Answers (2)

vrom911
vrom911

Reputation: 694

Apparently I haven't found better solution than using custom environment variable. And in Setup.hs you can call lookupEnv function to check the desired environment variable.

Also, there is Shake build tool which is designed to customize building process and should be preferred to Setup.hs configurations.

Upvotes: 1

wbj
wbj

Reputation: 21

It may depends on what's your customized build process. Setup.hs has a main function, so you can parse arguments by getArgs and do specific things; or if you'd like to pass the arguments along then you can use UserHooks, such as:

defaultMainWithHooks (simpleUserHooks {preBuild = xxx, postClean = yyy, ... } )

Each hook accepts Args.

Upvotes: 0

Related Questions