How to forward option?

11 views
Skip to first unread message

Sergey Bushnyak

unread,
Jul 25, 2019, 4:47:16 AM7/25/19
to Shake build system
Hi, 
I want to always forward `--prune` option by default to shake builder in my code but it keeps getting skipped. Have this code so far:

```
shakeArgsRaw <- getArgs

let shakeArgs = (L.intercalate " --" shakeArgsRaw) ++ " --prune" -- add prune option by default
      shOpts    = shakeOptions { shakeVerbosity      = Chatty
                               , shakeCommandOptions = [ Stdin shakeArgs]
                               }
...
shakeArgsPruneWith shOpts ...
```

Maybe there is another way to do it? 


Neil Mitchell

unread,
Jul 29, 2019, 4:31:52 AM7/29/19
to Sergey Bushnyak, Shake build system
Hi Sergey,

What the code does below is pipe --prune to the standard input (stdin) of the commands you run using cmd. My guess is you want to make it as though Shake was called using --prune? The easiest way to manipulate command line arguments like that it with getArgs and withArgs. That way you are doing it entirely outside Shake. 

Unfortunately you can't set prune programmatically without doing the slightly unpleasant arg hacking. However, if that was generally desired, such an operation could be exposed. 

Thanks, Neil 


--
You received this message because you are subscribed to the Google Groups "Shake build system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shake-build-sys...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/shake-build-system/0f8abe57-64c0-4bd9-ba66-1b97bb21b537%40googlegroups.com.

Sergey Bushnyak

unread,
Jul 29, 2019, 5:01:36 AM7/29/19
to Neil Mitchell, Shake build system
He, Neil.

Yes, that's exactly what I'm trying to do. I want behavior as if `--prune` provided always, this is very useful feature for the `Slick` package https://github.com/ChrisPenner/Slick I'm working on now. In my example above, I'm trying to do exactly as you suggested and missed `withArgs` function somehow that can help me.

If you in favor of such change - exposing operation, I can submit PR to Shake codebase. I'm already quite familiar with `Development.Shake.Util` module and some other internals. If you can describe briefly how you would approach it that will be helpful.

Thanks!
--

Sergey Bushnyak
CTO, Kelecorix Inc.

Neil Mitchell

unread,
Jul 29, 2019, 4:35:47 PM7/29/19
to Sergey Bushnyak, Shake build system
Hi Sergey,

If it's useful I'd certainly accept a patch - I think the withArgs
trick is effective, but quite hacky.

Unfortunately I can't think of a good API, but perhaps:

shakeArgsPruneAlways :: ShakeOptions -> ([FilePath] -> IO ()) ->
[OptDescr (Either String a)] -> ([a] -> [String] -> IO (Maybe (Rules
()))) -> IO ()

Which is like shakeArgsPruneWith, but doesn't add the new flag, just
always assumes its set.

I also note that following Development.Shake.Database at
https://hackage.haskell.org/package/shake-0.18.3/docs/Development-Shake-Database.html
the prune stuff could now be implemented without temporary files using
shakeLiveFilesDatabase, but that might be a much bigger refactoring.

Thanks, Neil
Reply all
Reply to author
Forward
0 new messages