racer icon indicating copy to clipboard operation
racer copied to clipboard

include!() support

Open MarkSwanson opened this issue 9 years ago • 11 comments

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

MarkSwanson avatar Apr 09 '15 00:04 MarkSwanson

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

phildawes avatar Apr 09 '15 06:04 phildawes

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"));

MarkSwanson avatar Apr 09 '15 11:04 MarkSwanson

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

ToucheSir avatar Mar 13 '16 22:03 ToucheSir

Probably related to #693

Have the same problem with vulkan_rs

karroffel avatar Apr 20 '17 22:04 karroffel

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"));

Dushistov avatar Jul 20 '18 10:07 Dushistov

I don't think supporting include! itself is difficult. 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.

kngwyu avatar Jul 20 '18 10:07 kngwyu

@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"));

Dushistov avatar Jul 20 '18 11:07 Dushistov

@Dushistov OK, I'll try it.

kngwyu avatar Jul 20 '18 11:07 kngwyu

@kngwyu

Great! Thank you.

Dushistov avatar Jul 20 '18 12:07 Dushistov

any update? thanks.

hekinami avatar Jan 09 '19 05:01 hekinami

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.

carmel4a avatar Apr 04 '20 00:04 carmel4a