Re: [cocci] spatch #include statements and include search path

Victor Gambier
2025-01-22T16:38:42Z

Hi Jani,

Could you give me a precise example of what you're trying to do? The
following works on my end (commit 8aa44ca):

.
├── A
│   ├── cocciincludemain.c
│   └── cocciincludemain.cocci
└── B
└── cocciinclude1.cocci

(...)/A $ spatch --sp-file ./cocciincludemain.cocci ./cocciincludemain.c

Absolute and relative includes in cocciincludemain.cocci both work:

#include
"/home/vgambier/Documents/git/coccinelle/playground/B/cocciinclude1.cocci"

#include "../B/cocciinclude1.cocci"

Thanks,
Victor

On 13/01/2025 17:59, Jani Nikula wrote:
> On Mon, 13 Jan 2025, Julia Lawall <julia.lawall@inria.fr> wrote:
>> On Mon, 13 Jan 2025, Jani Nikula wrote:
>>
>>> On Mon, 13 Jan 2025, Julia Lawall <julia.lawall@inria.fr> wrote:
>>>> I don't think there is any search path for .cocci files.
>>> Oh, so it's always relative to the current working directory? That's a
>>> bit of a bummer.
>> It's not a well developed feature. If an include path for it would be
>> useful, we can add that.
> It might be. Or do you have any other ideas for reusing match rules or,
> say, "iterator name" lists, without duplicating them into all .cocci
> files?
>
> So I guess I can try working around not having include search path by
> running spatch outside of my kernel repo. Does spatch otherwise handle
> that scenario well, or any caveats there?
>
>
> BR,
> Jani.
>
>