Skip to content

Commit

Permalink
docs, examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ratankaliani committed Aug 6, 2024
1 parent 2b8abec commit 747df35
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions book/writing-programs/compiling.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ f9afb8caaef10de9a8aad484c4dd3bfa54ba7218f3fc245a20e8a03ed40b38c617e175328515968a

## Build Script

If you want your program crate to be built automatically whenever you build/run your script crate, you can add a `build.rs` file inside of `script/` (at the same level as `Cargo.toml` of your script crate) that utilizes the `sp1-helper` crate:
If you want your program crate to be built automatically whenever you build/run your script crate, you can add a `build.rs` file inside of `script/` (at the same level as `Cargo.toml` of your script crate) that utilizes the `sp1-build` crate:

```rust,noplayground
{{#include ../../examples/fibonacci/script/build.rs}}
```

The path passed in to `build_program` should point to the directory containing the `Cargo.toml` file for your program. Make sure to also add `sp1-helper` as a build dependency in `script/Cargo.toml`:
The path passed in to `build_program` should point to the directory containing the `Cargo.toml` file for your program. Make sure to also add `sp1-build` as a build dependency in `script/Cargo.toml`:

```toml
[build-dependencies]
sp1-helper = "1.1.0"
sp1-build = "1.2.0"
```

You will see output like the following from the build script if the program has changed, indicating that the program was rebuilt:
Expand All @@ -82,12 +82,12 @@ The above output was generated by running `RUST_LOG=info cargo run --release -vv

### Advanced build options

To configure the build process when using the `sp1-helper` crate, you can pass a [`BuildArgs`](https://docs.rs/sp1-helper/1.1.0/sp1_helper/struct.BuildArgs.html) struct to to the [`build_program_with_args`](https://docs.rs/sp1-helper/1.1.0/sp1_helper/fn.build_program_with_args.html) function. The build arguments are the same as the ones available from the `cargo prove build` command.
To configure the build process when using the `sp1-build` crate, you can pass a [`BuildArgs`](https://docs.rs/sp1-build/1.2.0/sp1_build/struct.BuildArgs.html) struct to to the [`build_program_with_args`](https://docs.rs/sp1-build/1.2.0/sp1_build/fn.build_program_with_args.html) function. The build arguments are the same as the ones available from the `cargo prove build` command.

As an example, you could use the following code to build the Fibonacci example with the `docker` flag set to `true` and a custom output directory for the generated ELF:

```rust,noplayground
use sp1_helper::{build_program_with_args, BuildArgs};
use sp1_build::{build_program_with_args, BuildArgs};
fn main() {
let args = BuildArgs {
Expand Down
2 changes: 1 addition & 1 deletion build/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# sp1-build
Lightweight crate used to build SP1 programs. Internal crate that is exposed to users via `sp1-cli` and `sp1-helper`.
Lightweight crate used to build SP1 programs. Internal crate that is exposed to users via `sp1-cli`.

Exposes `build_program`, which builds an SP1 program in the local environment or in a docker container with the specified parameters from `BuildArgs`.

Expand Down
1 change: 0 additions & 1 deletion examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ sp1-derive = { path = "../derive" }
sp1-core = { path = "../core" }
sp1-cli = { path = "../cli", default-features = false }
sp1-eval = { path = "../eval", default-features = false }
sp1-helper = { path = "../helper", default-features = false }
sp1-primitives = { path = "../primitives" }
sp1-prover = { path = "../prover" }
sp1-recursion-compiler = { path = "../recursion/compiler" }
Expand Down
2 changes: 1 addition & 1 deletion examples/aggregation/script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ sp1-sdk = { workspace = true }
tracing = "0.1.40"

[build-dependencies]
sp1-helper = { workspace = true }
sp1-build = { workspace = true }
2 changes: 1 addition & 1 deletion examples/chess/script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ publish = false
sp1-sdk = { workspace = true }

[build-dependencies]
sp1-helper = { workspace = true }
sp1-build = { workspace = true }
2 changes: 1 addition & 1 deletion examples/cycle-tracking/script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ publish = false
sp1-sdk = { workspace = true }

[build-dependencies]
sp1-helper = { workspace = true }
sp1-build = { workspace = true }
2 changes: 1 addition & 1 deletion examples/fibonacci/script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ sp1-sdk = { workspace = true }
sha2 = "0.10.8"

[build-dependencies]
sp1-helper = { workspace = true }
sp1-build = { workspace = true }

[[bin]]
name = "plonk_bn254"
Expand Down
2 changes: 1 addition & 1 deletion examples/io/script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ serde = { version = "1.0.196", features = ["derive"] }
sp1-sdk = { workspace = true }

[build-dependencies]
sp1-helper = { workspace = true }
sp1-build = { workspace = true }
2 changes: 1 addition & 1 deletion examples/json/script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ sp1-sdk = { workspace = true }
lib = { path = "../lib" }

[build-dependencies]
sp1-helper = { workspace = true }
sp1-build = { workspace = true }
2 changes: 1 addition & 1 deletion examples/patch-testing/script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ sp1-core = { workspace = true, features = ["neon"] }
sp1-sdk = { workspace = true }

[build-dependencies]
sp1-helper = { workspace = true }
sp1-build = { workspace = true }
3 changes: 2 additions & 1 deletion examples/regex/script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ publish = false
sp1-sdk = { workspace = true }

[build-dependencies]
sp1-helper = { workspace = true }
sp1-build = { workspace = true }

2 changes: 1 addition & 1 deletion examples/rsa/script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ rsa = "0.6"
sp1-sdk = { workspace = true }

[build-dependencies]
sp1-helper = { workspace = true }
sp1-build = { workspace = true }
2 changes: 1 addition & 1 deletion examples/ssz-withdrawals/script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ publish = false
sp1-sdk = { workspace = true }

[build-dependencies]
sp1-helper = { workspace = true }
sp1-build = { workspace = true }
2 changes: 1 addition & 1 deletion examples/tendermint/script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ serde_cbor = "0.11.2"
sha2 = "0.10.8"

[build-dependencies]
sp1-helper = { workspace = true }
sp1-build = { workspace = true }

0 comments on commit 747df35

Please sign in to comment.