Skip to content

Commit

Permalink
feat(zkstack_cli): Build dependencies at zkstack build time (#3157)
Browse files Browse the repository at this point in the history
## What ❔

<!-- What are the changes this PR brings about? -->
<!-- Example: This PR adds a PR template to the repo. -->
<!-- (For bigger PRs adding more context is appreciated) -->
Build dependencies (e.g., `yarn install`) at `zkstack` build time.

## Why ❔

<!-- Why are these changes done? What goal do they contribute to? What
are the principles behind them? -->
<!-- Example: PR templates ensure PR reviewers, observers, and future
iterators are in context about the evolution of repos. -->

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [x] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [x] Tests for the changes have been added / updated.
- [x] Documentation comments have been added / updated.
- [x] Code has been formatted via `zkstack dev fmt` and `zkstack dev
lint`.
  • Loading branch information
manuelmauro authored Oct 23, 2024
1 parent 0aecae1 commit 724d9a9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions zkstack_cli/crates/zkstack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ anyhow.workspace = true
clap_complete.workspace = true
dirs.workspace = true
ethers.workspace = true
xshell.workspace = true
zksync_protobuf_build.workspace = true
17 changes: 17 additions & 0 deletions zkstack_cli/crates/zkstack/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::path::{Path, PathBuf};

use anyhow::{anyhow, Context};
use ethers::contract::Abigen;
use xshell::{cmd, Shell};

const COMPLETION_DIR: &str = "completion";

Expand All @@ -14,6 +15,11 @@ fn main() -> anyhow::Result<()> {
.write_to_file(outdir.join("consensus_registry_abi.rs"))
.context("Failed to write ABI to file")?;

if let Err(e) = build_dependencies() {
println!("cargo:error=It was not possible to install projects dependencies");
println!("cargo:error={}", e);
}

if let Err(e) = configure_shell_autocompletion() {
println!("cargo:warning=It was not possible to install autocomplete scripts. Please generate them manually with `zkstack autocomplete`");
println!("cargo:error={}", e);
Expand Down Expand Up @@ -130,3 +136,14 @@ impl ShellAutocomplete for clap_complete::Shell {
Ok(())
}
}

fn build_dependencies() -> anyhow::Result<()> {
let shell = Shell::new()?;
let code_dir = Path::new("../");

let _dir_guard = shell.push_dir(code_dir);

cmd!(shell, "yarn install")
.run()
.context("Failed to install dependencies")
}

0 comments on commit 724d9a9

Please sign in to comment.