gear-foundation / cargo-program

Utility to simplify Gear programs development
GNU General Public License v3.0
1 stars 0 forks source link

Replace `gear-wasm-builder` with another solution #103

Open fluiderson opened 1 year ago

fluiderson commented 1 year ago

Problem to Solve

gear-wasm-builder is fine for a single contract, but it becomes a real problem for big workspaces like gear-foundation/dapps. And there's also a lot of other small issues that can be considered reasons to completely replace it with another solution.

  1. For each contract, Cargo builds a separate executable with a build script, and since gear-wasm-builder isn't very lightweight, almost every one of them turns out to be a couple dozen megabytes. In case of the dapps repo, they consume around 9 gigabytes of storage out of 16 gigabytes of the build cache after a clean repo clone & cargo c, and with code changes, they can take even more storage.
  2. gear-wasm-builder runs on each check & compiles only in the release mode. Thus, even on a change of one line of code, gear-wasm-builder forcibly recompiles a contract before letting Cargo do a check. Yes, we have the __GEAR_WASM_BUILDER_NO_BUILD environment variable, but because it disables all gear-wasm-builder's checks, this isn't a really good solution.
  3. gear-wasm-builder doesn't work well with rust-analyzer because it can't parse compilation errors from the build script output.
  4. For some reason, gear-wasm-builder doesn't use all CPU while performing a build.
  5. Build scripts aren't really convenient for a customization because the only way to pass some arguments to them is through environment variables or a code change & recompilation.
  6. .binpath files like any build artifacts shouldn't be placed anywhere except the target directory. I managed to move *.meta.txts to it, but .binpath is trickier since it's used by gtest.

So, in overall, the current solution for the contract building is very heavy & slow. I suppose some of these issues can be fixed pretty easily, but I really wish there'd be a more elegant

Possible Solution

like cargo-contract. Actually @shamilsan worked on a similar tool: cargo-program - but it was abandoned. I propose to revive this project & try to fix all the issues above by not repeating them in it & switching to it.

Notes

No response

shamilsan commented 1 year ago

Agree!

Moved gear-program to the Gear Foundation organization: https://github.com/gear-foundation/cargo-program