Skip to content

Commit

Permalink
refactor(build): build utils (#188)
Browse files Browse the repository at this point in the history
* feat: build utils

* build
  • Loading branch information
ratankaliani authored Oct 26, 2024
1 parent 70b7e8a commit 5dfe420
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 251 deletions.
15 changes: 11 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ op-succinct-prove = { path = "scripts/prove" }
op-succinct-witnessgen = { path = "scripts/witnessgen" }
op-succinct-client-utils = { path = "utils/client" }
op-succinct-host-utils = { path = "utils/host" }
op-succinct-build-utils = { path = "utils/build" }
op-succinct-proposer = { path = "proposer/succinct" }

# Alloy
Expand Down
3 changes: 1 addition & 2 deletions proposer/succinct/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,4 @@ base64.workspace = true
tower-http.workspace = true

[build-dependencies]
sp1-build = { workspace = true }
cargo_metadata.workspace = true
op-succinct-build-utils.workspace = true
82 changes: 2 additions & 80 deletions proposer/succinct/build.rs
Original file line number Diff line number Diff line change
@@ -1,83 +1,5 @@
use std::process::Command;

use sp1_build::{build_program_with_args, BuildArgs};

/// Build a native program.
fn build_native_program(program: &str) {
let status = Command::new("cargo")
.args([
"build",
"--workspace",
"--bin",
program,
"--profile",
"release-client-lto",
])
.status()
.expect("Failed to execute cargo build command");

if !status.success() {
panic!("Failed to build {}", program);
}

println!(
"cargo:warning={} built with release-client-lto profile",
program
);
}

/// Build the native host runner to a separate target directory to avoid build lockups.
fn build_native_host_runner() {
let metadata = cargo_metadata::MetadataCommand::new()
.exec()
.expect("Failed to get cargo metadata");
let target_dir = metadata.target_directory.join("native_host_runner");

let status = Command::new("cargo")
.args([
"build",
"--workspace",
"--bin",
"native_host_runner",
"--release",
"--target-dir",
target_dir.as_ref(),
])
.status()
.expect("Failed to execute cargo build command");
if !status.success() {
panic!("Failed to build native_host_runner");
}

println!("cargo:warning=native_host_runner built with release profile",);
}

/// Build a program for the zkVM.
#[allow(dead_code)]
fn build_zkvm_program(program: &str) {
build_program_with_args(
&format!("../../programs/{}", program),
BuildArgs {
elf_name: format!("{}-elf", program),
docker: true,
tag: "v3.0.0-rc4".to_string(),
..Default::default()
},
);
}
use op_succinct_build_utils::build_all;

fn main() {
let programs = vec!["fault-proof", "range"];

for program in programs {
// Note: Don't comment this out, because the Docker program depends on the native program
// for range being built.
build_native_program(program);
// build_zkvm_program(program);
}

// build_zkvm_program("aggregation");
// Note: Don't comment this out, because the Docker program depends on the native host runner
// being built.
build_native_host_runner();
build_all();
}
4 changes: 1 addition & 3 deletions scripts/prove/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,4 @@ op-alloy-genesis.workspace = true
sp1-sdk = { workspace = true }

[build-dependencies]
sp1-build = { workspace = true }
op-succinct-host-utils = { workspace = true }
cargo_metadata.workspace = true
op-succinct-build-utils.workspace = true
81 changes: 2 additions & 79 deletions scripts/prove/build.rs
Original file line number Diff line number Diff line change
@@ -1,82 +1,5 @@
use std::process::Command;

use sp1_build::{build_program_with_args, BuildArgs};

/// Build a native program.
fn build_native_program(program: &str) {
let status = Command::new("cargo")
.args([
"build",
"--workspace",
"--bin",
program,
"--profile",
"release-client-lto",
])
.status()
.expect("Failed to execute cargo build command");

if !status.success() {
panic!("Failed to build {}", program);
}

println!(
"cargo:warning={} built with release-client-lto profile",
program
);
}

/// Build the native host runner to a separate target directory to avoid build lockups.
fn build_native_host_runner() {
let metadata = cargo_metadata::MetadataCommand::new()
.exec()
.expect("Failed to get cargo metadata");
let target_dir = metadata.target_directory.join("native_host_runner");

let status = Command::new("cargo")
.args([
"build",
"--workspace",
"--bin",
"native_host_runner",
"--release",
"--target-dir",
target_dir.as_ref(),
])
.status()
.expect("Failed to execute cargo build command");
if !status.success() {
panic!("Failed to build native_host_runner");
}

println!("cargo:warning=native_host_runner built with release profile",);
}

/// Build a program for the zkVM.
#[allow(dead_code)]
fn build_zkvm_program(program: &str) {
build_program_with_args(
&format!("../../programs/{}", program),
BuildArgs {
elf_name: format!("{}-elf", program),
docker: true,
..Default::default()
},
);
}
use op_succinct_build_utils::build_all;

fn main() {
let programs = vec!["fault-proof", "range"];

for program in programs {
// Note: Don't comment this out, because the Docker program depends on the native program
// for range being built.
build_native_program(program);
// build_zkvm_program(program);
}

// build_zkvm_program("aggregation");
// Note: Don't comment this out, because the Docker program depends on the native host runner
// being built.
build_native_host_runner();
build_all();
}
4 changes: 1 addition & 3 deletions scripts/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,4 @@ op-succinct-client-utils.workspace = true
sp1-sdk = { workspace = true }

[build-dependencies]
sp1-build = { workspace = true }
op-succinct-host-utils = { workspace = true }
cargo_metadata.workspace = true
op-succinct-build-utils.workspace = true
82 changes: 2 additions & 80 deletions scripts/utils/build.rs
Original file line number Diff line number Diff line change
@@ -1,83 +1,5 @@
use std::process::Command;

use sp1_build::{build_program_with_args, BuildArgs};

/// Build a native program.
fn build_native_program(program: &str) {
let status = Command::new("cargo")
.args([
"build",
"--workspace",
"--bin",
program,
"--profile",
"release-client-lto",
])
.status()
.expect("Failed to execute cargo build command");

if !status.success() {
panic!("Failed to build {}", program);
}

println!(
"cargo:warning={} built with release-client-lto profile",
program
);
}

/// Build the native host runner to a separate target directory to avoid build lockups.
fn build_native_host_runner() {
let metadata = cargo_metadata::MetadataCommand::new()
.exec()
.expect("Failed to get cargo metadata");
let target_dir = metadata.target_directory.join("native_host_runner");

let status = Command::new("cargo")
.args([
"build",
"--workspace",
"--bin",
"native_host_runner",
"--release",
"--target-dir",
target_dir.as_ref(),
])
.status()
.expect("Failed to execute cargo build command");
if !status.success() {
panic!("Failed to build native_host_runner");
}

println!("cargo:warning=native_host_runner built with release profile",);
}

/// Build a program for the zkVM.
#[allow(dead_code)]
fn build_zkvm_program(program: &str) {
build_program_with_args(
&format!("../../programs/{}", program),
BuildArgs {
elf_name: format!("{}-elf", program),
docker: true,
tag: "v3.0.0-rc3".to_string(),
..Default::default()
},
);
}
use op_succinct_build_utils::build_all;

fn main() {
let programs = vec!["fault-proof", "range"];

for program in programs {
// Note: Don't comment this out, because the Docker program depends on the native program
// for range being built.
build_native_program(program);
// build_zkvm_program(program);
}

// build_zkvm_program("aggregation");
// Note: Don't comment this out, because the Docker program depends on the native host runner
// being built.
build_native_host_runner();
build_all();
}
9 changes: 9 additions & 0 deletions utils/build/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "op-succinct-build-utils"
version = "0.1.0"
license.workspace = true
edition.workspace = true

[dependencies]
sp1-build.workspace = true
cargo_metadata.workspace = true
Loading

0 comments on commit 5dfe420

Please sign in to comment.