I've vaguely wanted this in the past, glad someone is interested and
motivated enough to get their hands dirty :)

Assuming you're interested in doing this only for C++, you'd want to make
the changes in the capnpc-c++ code generator plugin. Maybe Kenton can
provide more specific guidance than this, since I'm not familiar with
that part of the codebase. But at a high level, the main schema compiler
is going to feed that program a CodeGeneratorRequest as defined in
schema.capnp. RequestedFile.imports should have the information you need
to generate dependencies.

A possible alternative wuold be to write a (separate) schema compiler
plugin that just dumps the input to a file (say foo.capnp.cgr) and also
generates Makefile stubs for that file; you could then feed in the
generated file to capnpc-c++ (or other plugins) manually, and add
rules like:

%.capnp.cgr: %.capnp
        # ...
%.capnp.h %.capnp.c++: %.capnp.cgr
        # ...

This would be more general, and might be a little easier.

Note that one thing that's a little sad about gcc's -M is that it will
fail if the file doesn't exist, so you can't use it to gather dependencies
for the *.capnp.{h,c++} files as easily as you can non-generated files.

-Ian

Quoting Dirk Jagdmann (2021-08-05 11:50:58)
>    Hello Cap'n'Proto experts,
> 
>    I would like to generate dependencies for Cap'n'Proto schema file
>    imports in the syntax understood by (GNU) make. Similar to the gcc
>    compiler's -M command line argument.
> 
>    I'm happy to look into the Cap'n'Proto source code and see if I can
>    implement this myself, but it would help if you can give me some guide
>    which data structures in which files would have the information that I
>    need (currently processed schema file, list of include directories,
>    ...)
> 
>    --
>    You received this message because you are subscribed to the Google
>    Groups "Cap'n Proto" group.
>    To unsubscribe from this group and stop receiving emails from it, send
>    an email to [1]capnproto+unsubscr...@googlegroups.com.
>    To view this discussion on the web visit
>    [2]https://groups.google.com/d/msgid/capnproto/b5ffcffe-5a2f-45d4-b248-
>    58118947c67dn%40googlegroups.com.
> 
> Verweise
> 
>    1. mailto:capnproto+unsubscr...@googlegroups.com
>    2. 
> https://groups.google.com/d/msgid/capnproto/b5ffcffe-5a2f-45d4-b248-58118947c67dn%40googlegroups.com?utm_medium=email&utm_source=footer

-- 
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to capnproto+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/capnproto/162818661944.3948.8788466351021373915%40localhost.localdomain.

Reply via email to