Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for cross-crate schema imports #233

Open
dwrensha opened this issue Sep 19, 2021 · 2 comments
Open

add support for cross-crate schema imports #233

dwrensha opened this issue Sep 19, 2021 · 2 comments

Comments

@dwrensha
Copy link
Member

dwrensha commented Sep 19, 2021

See https://groups.google.com/g/sandstorm-dev/c/hdTrPu6gndY/m/heRh-ns1AgAJ

Currently, if someone wants to define schema files that depend on the sandstorm schema files, then they cannot take advantage of the sandstorm-rust crate. To make that work, we need:

  1. a way for the downstream crate to find the .capnp files of the upstream crate. Here's an cargo issue I opened about that: DEP_FOO_KEY-like system that can work without "links" rust-lang/cargo#3544
  2. a way for capnpc-rust to know the crate name to associate with a given schema. One way to do that might be to add new annotation in rust.capnp: https://github.com/capnproto/capnproto-rust/blob/0f7abd17ba653ea2130185ca20ebb953dc729c5e/capnpc/rust.capnp
@zenhack
Copy link

zenhack commented Sep 19, 2021

Re: (1), it looks like there's a consensus on the solution and this is just waiting on someone to do the work.

Re: (2), the go implementation does something similar, and it's worked out adequately.

@griff
Copy link
Contributor

griff commented Oct 12, 2021

I have gotten around the problem by having a checked out version of sandstorm-rust for calling capnpc so the schema files could be found.

And the crate problem can be solved with use. If my crate uses util.capnp it just needs use sandstorm::util_capnp; at the top level to work.

I actually did some work on DEP_FOO_KEY in cargo and got something hacked together but when the cargo tests failed for some reason I but it down and haven't looked at it since.

dzfranklin added a commit to dzfranklin/capnproto-rust that referenced this issue Jun 12, 2023
Relates to capnproto#411 and capnproto#233

This api is quite awkward but I'm intending it as a stopgap until cargo
supports non-linking DEP environment variables. But it allows people to
use generated code in external crates without us needing to add an
annotation to the external `.capnp` file. This is important because
without the change to cargo it would be awkward to require users use a
modified `json.capnp`.
dzfranklin added a commit to dzfranklin/capnproto-rust that referenced this issue Jun 12, 2023
Relates to capnproto#411 and capnproto#233

This api is quite awkward but I'm intending it as a stopgap until cargo
supports non-linking DEP environment variables. But it allows people to
use generated code in external crates without us needing to add an
annotation to the external `.capnp` file. This is important because
without the change to cargo it would be awkward to require users use a
modified `json.capnp`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants