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

It should be easier to include standard files #186

Closed
Timmmm opened this issue Jun 3, 2020 · 2 comments
Closed

It should be easier to include standard files #186

Timmmm opened this issue Jun 3, 2020 · 2 comments

Comments

@Timmmm
Copy link
Contributor

Timmmm commented Jun 3, 2020

I'm using Rust, via ::capnpc::CompilerCommand. If I put this in my .capnp file:

using Rust = import "rust.capnp";

Then I get this error

error: Import failed: rust.capnp

I think the "proper" solution is to add include paths to the compile command that point to /usr/include/capnp or something like that. But that is rubbish. I shouldn't have to figure out where those files are (on every platform too!) when Capnp could just bundle them itself.

Note this comment:

To use the new feature, you need to import rust.capnp. Probably the easiest way to do that is to copy it and include it among your own schema files.

It's easier to just copy the files into your project than to do it the "proper" way.

I suggest adding the standard include path as a compile time constant to the compiler. Similar to how C++ compilers always include /usr/include without you having to explicitly ask for it.

An alternative possibly more robust approach would be to create some kind of virtual file system and embed the files in the binary during compilation. I think that is the best approach but it is a little more work.

@dwrensha
Copy link
Member

dwrensha commented Jun 4, 2020

add include paths to the compile command that point to /usr/include/capnp

The schema compiler already does that by default. (It can be disabled via --no-standard-import.) The problem is that rust.capnp is not a part of the main capnproto-c++ distribution. Maybe we should submit a pull request to https://github.com/capnproto/capnproto to add it, though I'm not super excited by the idea of needing to keep that in sync with this repo.

An alternative possibly more robust approach would be to create some kind of virtual file system and embed the files in the binary during compilation

It's not clear to me what you mean by "virtual file system". Anything I can think of along those lines would be platform-dependent and therefore involve a lot of work.

I still think the best solution would be to fix rust-lang/cargo#3544 and then include the file from the cargo dependency.

(Previous comment here: #173 (comment))

@Timmmm
Copy link
Contributor Author

Timmmm commented Jun 4, 2020

Ah ok if you have a better solution in mind I will close this.

@Timmmm Timmmm closed this as completed Jun 4, 2020
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

2 participants