During my attempt to convert existing project to Shake I've encountered few
problems and the lack of Haskell knowledge doesn't allow me to go further.
a. Rebuilds when command line changes. There are few questions with the
same motif on Stackoverflow, but no real solution (that I can easily grok).
Allusion to defining new rule instance was made, but I'm at a loss as to how,
perhaps someone has an example?
[FWIW lack of this feature is what makes certain speed measurements made in
some Shake papers suspect. IOW comparing Shake to Ninja given that one does
something while the other doesn't, seems a bit unfair]
b. Getting the list of all the dependencies that lead to the target.
a needs [b,c], b needs [d,e,f], getting dep-sorted list ([a,b,c,d,e,f])
would have made life so much easier. For OCaml at least where modules
supplied to the linking stage must be in order.
c. Probably the easiest one:
Making the rule depend on the output of the external (shell) command (something
like git-describe(1) for instance)
P.S. I'm sure that this attempt of mine, while successful in the sense that it
works at all, probably is not the best utilization of Shake, so if someone
would take a look that would be highly appreciated:
http://repo.or.cz/w/llpp.git/shortlog/refs/heads/yabs http://repo.or.cz/w/llpp.git/blob_plain/7047bb9f320531a9e33e95f8b20aaca73663ffa9:/Build.hs
Thanks for Shake, integrating OCaml (with all it's quirks) has never been easier
(GNU Make, OMake, Ninja have all been tried and failed in one way or another)
Neil Mitchell <ndmit...@gmail.com> writes:
> Hi
>
>> a. Rebuilds when command line changes. There are few questions with the
>> same motif on Stackoverflow, but no real solution (that I can easily grok).
>> Allusion to defining new rule instance was made, but I'm at a loss as to how,
>> perhaps someone has an example?
>
> The sad answer, is that there is no good answer in general, but often
> for specific instances there are workable solutions that in practice
> do everything you need. If you change a lot of stuff, just change
> shakeVersion and everything will rebuild. If you have particular rules
> that are likely to have a lot of code changes which effect the result
> (e.g. a generator in Haskell) then a need on the source file of part
> of the build system works. If you are storing metadata about the build
> separate to the rules (either in a separate file or in the Haskell
> itself), then you can track the rules.
>
It feels like that if a rule is semi-pure (side effects are limited to
`cmd _') it should be doable (just produce the concatenation of all
strings passed to the cmds and compare that across runs), but at the
same time it also feels like that's probably an oversimplification on my
part.
>> c. Probably the easiest one:
>> Making the rule depend on the output of the external (shell)
>> command (something
>> like git-describe(1) for instance)
>
> This could mean one of two things:
>
> 1) You want a rule to capture the output of git-describe, in which
> case Stdout contents <- cmd "git describe" should work. I suspect you
> don't mean that, as you've already used that formulation in the code.
>
Correct, this is not what I mean.
> 2) You want to rebuild a certain file when git-describe changes, in
> which case alwaysRerun
> (https://hackage.haskell.org/package/shake-0.15.5/docs/Development-Shake.html#v:alwaysRerun)
> or oracles
> (https://hackage.haskell.org/package/shake-0.15.5/docs/Development-Shake.html#g:11)
> will both work. The alwaysRerun formulation tends to be a bit simpler.
>
I've tried, not very hard I suppose, to find some examples of oracle
usage to better familiarize myself the concept - but failed, perhaps
you've got some other links? (can't say that hackage was very
illuminating)
After getting fed up with my Linux distribution(the way it packages ghc/cabal/etc) decision was made that enough is enough it's time to migrate to another build system. And there it is in all it's glory: https://github.com/moosotc/llpp/blob/master/build.sh
This is not meant as a critique of Shake (I'm forever indebted to it for showing me that dependencies can(and should) be tracked properly), nor ghc/cabal (I'd venture a guess that OPAM/Cargo/Language-packager-du-jour all share the same set of problems), it's just that not being invested in haskell/ghc makes using Shake problematic to say the least (while I can probably understand what GeneralizedNewtypeDeriving does (despite Lennarts less than flattering description of it), the TypeFamilies is definitely outside of my reach.
Shake did one thing that aforementioned build.sh didn't do - parallel builds, then again I could never muster the courage to make Shake work on macOS... So there...
Lastly a bite - Don't you find it ironic that haskell is replaced by posix shell command language to build ocaml code and in the process ~a gigabyte of disk space is saved?