Re: [PATCH] Makefile: detect errors in running spatch
- Date: Fri, 10 Mar 2017 13:12:20 -0500
- From: Jeff King <peff@xxxxxxxx>
- Subject: Re: [PATCH] Makefile: detect errors in running spatch
On Fri, Mar 10, 2017 at 06:03:47PM +0100, René Scharfe wrote:
> > This shell code is getting a bit unwieldy to stick inside the Makefile,
> > with all the line continuation and $-escaping. It might be worth moving
> > it into a helper script.
> There is one for the kernel (https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/scripts/coccicheck).
> It's quite big, though.
Yeah, there's a lot going on there that I don't think we care about
(though I am new to coccinelle, so maybe I would grow to appreciate the
I was thinking of just moving the current Makefile snippet into a
script. That lets us avoid the irritating quoting. And we can use things
like functions, which would make the $?-handling in the loop less
tedious (because we can return straight out of the loop).
> > I don't know if that would make the patches harder to apply. The results
> > aren't full patches, so I assume you usually do some kind of munging on
> > them?
> They work with patch -p0.
Hrm, you're right. I tried it earlier based on the commit message from
the original "coccicheck" commit, but I got "only garbage was found".
But now it works. I must have screwed it up (perhaps tab-completion
stopped at "copy.cocci" instead of "copy.cocci.patch").
> > make coccicheck SPATCH='spatch --in-place'
> Using SPATCH_FLAGS for adding an option in such case would be a bit simpler.
That too. :)
> We can get rid of the loop by using the spatch options --use-gitgrep and
> --dir. I can't find the former one in the docs, though, so I'm not sure if
> it only works with certain versions or what exactly it is even doing. It
> seems to have the side effect of producing git-style patches (applicable
> with patch -p1) at least.
I have no objections to pursuing that. But I think with my patch, it's
workable for now, so there's no rush.