ethcontract-rs icon indicating copy to clipboard operation
ethcontract-rs copied to clipboard

Rebuild crate when artefact contents change

Open taminomara opened this issue 3 years ago • 7 comments

Changes in artefact .json files should trigger a rebuild.

taminomara avatar Jun 18 '21 15:06 taminomara

I thought this was already the case (because they are include!-ed) but it may have gotten broken in the past.

nlordell avatar Jun 21 '21 07:06 nlordell

I'm not sure if it works with build.rs, but with macros it certainly isn't the case.

taminomara avatar Jun 21 '21 08:06 taminomara

So it looks like we can't add dependency on actual JSON files unless we include! them 😕

taminomara avatar Jul 01 '21 10:07 taminomara

If we just include! them, but don't do anything with the file, does the optimizer remove the data from the output binary? If so, we can

let _ = include_bytes!("source/path.json");

nlordell avatar Jul 01 '21 13:07 nlordell

Yes, the optimizer will remove the data. However, the compiler will still read that data and include it into AST (at least HIR, not sure about MIR). This will potentially slow down compilation. Not sure if it's a real concern though.

taminomara avatar Jul 01 '21 14:07 taminomara

Yes, the optimizer will remove the data. However, the compiler will still read that data and include it into AST (at least HIR, not sure about MIR). This will potentially slow down compilation. Not sure if it's a real concern though.

Yeah, its a downside for sure - but personally I view not recompiling as a bigger issue than the slower compile time. Is there a macro to include the cargo fingerprints without reading it?

nlordell avatar Jul 01 '21 14:07 nlordell

Is there a macro to include the cargo fingerprints without reading it?

I'm not sure, probably no.

taminomara avatar Jul 01 '21 15:07 taminomara