kube-rs / k8s-pb

Playing with Kubernetes protobufs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use `codegenrs`?

kazk opened this issue · comments

codegenrs makes it easy to get rid of code-gen in build.rs, reducing build times for your crate and those that depend on it

This is done by:

  • Creating a child [[bin]] crate that does code-gen using codegenrs
  • Do one-time code-gen and commit it
  • Run the --check step in your CI to ensure your code-gen is neither out of
    date or been human edited.

https://github.com/crate-ci/codegenrs

Seems to support using rustfmt to format the generated code. https://github.com/crate-ci/imperative/blob/f7955ed1deda8abc8aeacc3a41aca23b3acc47d0/codegen/src/main.rs#L99

It's a pretty simple library. It's only one file, the rustfmt part is a simple shell hook, and the the generation part doesn't look like it can deal with appending to existing files easily - which we would need.

We could do this with a crate and a [[bin]] entry anyway though. But I think we can probably generate and run rustfmt as part of our build script here.