mandrean / cw-optimizoor

A blazingly fast compiling & optimization tool for CosmWasm smart contracts.
MIT License
49 stars 6 forks source link

chore: Compile only the package's libraries #25

Closed nicolaslara closed 1 year ago

nicolaslara commented 1 year ago

https://github.com/CosmWasm/rust-optimizer/pull/91/files introduces the required --lib argument when optimizing with rust-optimizer/workspace-optimizer. This enables the schema generation to live under src/bin instead of examples/.

This PR applies the same change to cw-optimizoor

webmaster128 commented 1 year ago

The reason behind this is the following. In contrast to examples, the bin targets are built as part of the default cargo build. But CosmWasm contracts do not contains any bin which is compiled to Wasm. It is all happening in the lib part. So no matter what schema generators do, using --lib makes sense and is safe for old and new contracts. Recently my collegues concluded we prefer using a bin target instead of an examples target for the new schemas best practice. This turns this previously optional --lib argument into a required one.

webmaster128 commented 1 year ago

Even more context here: https://medium.com/cosmwasm/dev-note-1-moving-schema-rs-from-examples-to-bin-7c1b8cde7fc8

mandrean commented 1 year ago

Thanks for the PR @nicolaslara and the shout-out @webmaster128!

webmaster128 commented 1 year ago

My pleasure.

The more I think about it, the more I like this project. I now understand that it is fundamentally different to rust-optimizer and both projects have their place. More on that soon as part of https://github.com/CosmWasm/rust-optimizer/issues/101. Cheers!