I think this could be implemented as a regular old code generator plugin
that directly produces the deps files. No need to integrate with the C++
plugin nor output an intermediate representation.

Note that `capnp compile` supports passing multiple `-o` flags to run
multiple plugins, so you can run both your C++ generator and your deps
generator in one pass.

-Kenton

On Thu, Aug 5, 2021 at 1:04 PM Ian Denhardt <i...@zenhack.net> wrote:

> 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
> .
>

-- 
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/CAJouXQmwiQ%3D_ARkgb%2B71bW4RN6ZP7PZAUTgLz-dLgWDX1N28LA%40mail.gmail.com.

Reply via email to