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

include!() support #191

Open
MarkSwanson opened this issue Apr 9, 2015 · 11 comments
Open

include!() support #191

MarkSwanson opened this issue Apr 9, 2015 · 11 comments
Assignees

Comments

@MarkSwanson
Copy link

Hello,

It would be great to have racer work with capn proto generated Rust code.
I think this is an include!() problem. You can test this for yourself like this:

  • git clone https://github.com/dwrensha/capnpc-rust
  • cd capnpc-rust
  • cargo build (probably requires nightly rustc)
  • cd example/addressbook
  • cargo build
  • vi addressbook.rs
  • try to 'gd' on line 39 address_book.init_people(2) -> not found (init_people)
  • try to type address_book. -> not found
@phildawes
Copy link
Collaborator

Does capnpc-rust write the addressbook generated source anywhere? Racer currently needs the source code to do completions / find definitions at the moment

@MarkSwanson
Copy link
Author

It does, and this may be the tricky part because it relies on an OUT_DIR env var supplied by rustc.

For example, on my system the source file winds up here:
target//debug/build/addressbook-20f8a45beadaa3ee/out/addressbook_capnp.rs

The include!() to find the file is:
include!(concat!(env!("OUT_DIR"), "/addressbook_capnp.rs"));

@ToucheSir
Copy link

This enhancement would also be great for working with gl-rs (which does something similar with OUT_DIR).

@karroffel
Copy link

Probably related to #693

Have the same problem with vulkan_rs

@Dushistov
Copy link

It would be great thing for those who use https://github.com/rust-lang-nursery/rust-bindgen and construction like:

include!(concat!(env!("OUT_DIR"), "/c_lib_include.rs"));

@kngwyu
Copy link
Collaborator

kngwyu commented Jul 20, 2018

I don't think supporting include! itself is difficult.
But other macros like concat! and cargo environment variables like OUT_DIR are major obstacles 😨
So... yeah I don't say we never support this, but we can't support this kind of feature immediately, sorry.

@Dushistov
Copy link

Dushistov commented Jul 20, 2018

@kngwyu

But other macros like concat! and cargo environment variables like OUT_DIR are major obstacles fearful
So... yeah I don't say we never support this, but we can't support this kind of feature immediately, sorry.

But what about this particular case:

include!(concat!(env!("OUT_DIR"), "/c_lib_include.rs"));

?

It is recommended way for code generation according to official cargo docs, is it hard to match such code with regexp and look for last modified file in: target/(debug|release)/build/${crate_name}-*/c_lib_include.rs ?

I suppose this heuristics will close 90% of code generation use cases.

I mean do not handle macroses at all just match string include!(concat!(env!("OUT_DIR"), "PATH"));

@kngwyu kngwyu self-assigned this Jul 20, 2018
@kngwyu
Copy link
Collaborator

kngwyu commented Jul 20, 2018

@Dushistov
OK, I'll try it.

@Dushistov
Copy link

@kngwyu

Great! Thank you.

@hekinami
Copy link

hekinami commented Jan 9, 2019

any update? thanks.

@carmel4a
Copy link

carmel4a commented Apr 4, 2020

Hi, is anyone working on this, because I don't want to duplicate effort.
EDIT: Ok, so If nobody is working on it I will try to fix, but it may took a while as I must take in the codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants