Skipping unnecessary rebuild of snap stages

I’ve got a Rust snap that is snapping fine, but is somewhat painful to rebuild, as any change to any file in the repository requires a full recompile. Is there any way to alleviate this? The two things I can think of would be:

  • Some way of telling snapcraft that changes to e.g. /docs/ doesn’t affect the Rust code at all.
    • This would have to be a manual process, since something like build.rs can read arbitrary files at compile time
  • The ability to do an incremental recompile
    • I haven’t really dived into how the Rust plugin works, but I’m surprised this doesn’t happen already, given that snapcraft reuses the VM or container between builds.

There have been some improvements for incremental builds when using base: core20, if that’s an option in your case. If so, could you give it a spin and let us know if it’s a friendlier workflow for you?

Looks like that worked. Rebuilding after changes is now much faster. Thanks!

1 Like