Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Automatic WASM discovery and optimization #164

Merged
merged 19 commits into from
Jul 31, 2024

Conversation

koxu1996
Copy link
Contributor

@koxu1996 koxu1996 commented Jul 25, 2024

This PR introduces automatic session code discovery (and optimization), based on project structure - fix for #163. See how it works now:

cd ./kairos-session-code && cargo build --release && cd ..
cargo build -p kairos-cli

No need to set PATH_TO_SESSION_BINARIES or run wasm-opt 😌.

In case user didn't compiled session code, he will be instructed to do it:

error: failed to run custom build command for `kairos-cli v0.1.0 (/home/andrew/Projects/casper/kairos/kairos-cli)`

Caused by:
  process didn't exit successfully: `/home/andrew/Projects/casper/kairos/target/debug/build/kairos-cli-cdc69376860e1954/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at kairos-cli/build.rs:32:9:
  WASM directory does not exist: /home/andrew/Projects/casper/kairos/kairos-cli/../kairos-session-code/target/wasm32-unknown-unknown/release/. Please build session code at `./kairos-session-code` with `cargo build --release`; or set `PATH_TO_SESSION_BINARIES` env variable.

NOTE: PATH_TO_SESSION_BINARIES still can be set.

It will be used for automatic WASM optimization.
`PATH_TO_SESSION_BINARIES` no longer needs to be set :).
@koxu1996 koxu1996 self-assigned this Jul 25, 2024
kairos-cli/build.rs Outdated Show resolved Hide resolved
@koxu1996 koxu1996 marked this pull request as ready for review July 26, 2024 10:21
@Avi-D-coder
Copy link
Contributor

we could build the session code for the user instead of telling them how too.

if the env is not set print the rerun if changed directive on the session code dir and then run the cargo build. make sure to use https://doc.rust-lang.org/cargo/reference/build-scripts.html#rerun-if-env-changed on the env too

@koxu1996
Copy link
Contributor Author

@Avi-D-coder Done in d5fd874.

@marijanp marijanp merged commit 4ac6aee into main Jul 31, 2024
4 checks passed
@marijanp marijanp deleted the feature/cli-wasm-discovery branch July 31, 2024 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants