mystor / rust-cpp

Embed C++ directly inside your rust code!
Apache License 2.0
807 stars 44 forks source link

compile error when changing code inside `cpp!` macro #84

Closed lammermann closed 4 years ago

lammermann commented 4 years ago

Hi, I get the following error when changing the code inside my cpp! macro:

error: This cpp! macro is not found in the library's rust-cpp metadata.
NOTE: Only cpp! macros found directly in the program source will be parsed -
NOTE: They cannot be generated by macro expansion.

Strangely I only get this when I change my code (no matter what I change) but the first time when I compile it it works fine. My current workaround is to delete the caches of my crate every time I change the contents inside a cpp macro.

I have no idea what causes this as I don't know macros that much but it seems to have something to do with caches.

Any help is highly appreciated. Greetings, Benjamin

ogoffart commented 4 years ago

It sounds like the build script is not re-run when the file change.

lammermann commented 4 years ago

Ah I see, I've recently added some println!("cargo:rerun-if-changed=my_source_file.cc"); lines to the end of my build script. Maybe they override the re-run settings for my rust sources.

Is there any way I can make sure my cpp sources are appended to my re-run configuration while also keeping my build script run once the rust sources change?

ogoffart commented 4 years ago

Yes, that's why. By default the build script is run for every change, but if there is a rerun-if-changed, then it doesn't

Is there any way I can make sure my cpp sources are appended to my re-run configuration while also keeping my build script run once the rust sources change?

That could be an interesting feature. Right know you will have to do that manually.

lammermann commented 4 years ago

Ok thanks.

So I'm closing this now. However shall I open a feature request for supporting additional cargo:rerun-if-changed statements?