diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 258f02efb..fe247e0ce 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,7 +6,8 @@ Scarb is actively developed and open for contributions! Grab any unassigned issue labeled with [`help-wanted`](https://github.com/software-mansion/scarb/labels/help%20wanted)! *Looking for some easy warmup tasks?* -Check out issues labeled with [`good-first-issue`](https://github.com/software-mansion/scarb/labels/good%20first%20issue)! +Check out issues labeled with [ +`good-first-issue`](https://github.com/software-mansion/scarb/labels/good%20first%20issue)! *Need some guidance?* Reach out to other developers on [Telegram](https://t.me/+1pMLtrNj5NthZWJk)! @@ -17,7 +18,8 @@ Latest stable Rust is the only thing you really need. It is recommended to use [rustup](https://rustup.rs/) for getting it. If you wish to work on Scarb's website, you will need [Node.js](https://nodejs.org/). -We recommend to install it using [asdf](https://asdf-vm.com/) (via [nodejs](https://github.com/asdf-vm/asdf-nodejs) plugin). +We recommend to install it using [asdf](https://asdf-vm.com/) (via [nodejs](https://github.com/asdf-vm/asdf-nodejs) +plugin). ## Contributing @@ -56,13 +58,31 @@ Each commit should pass lints and tests. Then, set up a stack of pull requests, separate PR for each commit, and pointing to the previous one. While your PR is being reviewed on, you can push merge commits and -use [`git commit --fixup`](https://git-scm.com/docs/git-commit/2.32.0#Documentation/git-commit.txt---fixupamendrewordltcommitgt) +use [ +`git commit --fixup`](https://git-scm.com/docs/git-commit/2.32.0#Documentation/git-commit.txt---fixupamendrewordltcommitgt) to push further changes to your commits. ### Typos + Our policy is to not accept PRs that only fix typos in the documentation and code. We appreciate your effort, but we encourage you to focus on bugs and features instead. +## Tips + +### Testing custom Cairo compiler changes + +Sometimes you may happen to work on a feature to the Cairo compiler, and you would like to test how it works in Scarb +(for example, if you are working on Starknet Foundry). + +We have a script that edits the `Cargo.toml` file to use a local checkout of the Cairo compiler. +To use this tool, run: + +```shell +cargo xtask set-cairo-version --path ../path/to/cairo +``` + +And then you can `cargo build` Scarb with your custom Cairo compiler changes. + --- Thanks! ❤️ ❤️ ❤️ diff --git a/xtask/src/set_cairo_version.rs b/xtask/src/set_cairo_version.rs index e690427dc..f9ba13ab3 100644 --- a/xtask/src/set_cairo_version.rs +++ b/xtask/src/set_cairo_version.rs @@ -1,6 +1,7 @@ use anyhow::Result; use clap::Parser; use semver::Version; +use std::path::PathBuf; use toml_edit::{DocumentMut, InlineTable, Value}; use xshell::{cmd, Shell}; @@ -22,6 +23,8 @@ struct Spec { rev: Option, #[arg(short, long)] branch: Option, + #[arg(short, long, conflicts_with_all = ["rev", "branch"])] + path: Option, } pub fn main(args: Args) -> Result<()> { @@ -32,10 +35,11 @@ pub fn main(args: Args) -> Result<()> { .as_table_mut() .unwrap(); - for (_, dep) in deps + for (dep_name, dep) in deps .iter_mut() .filter(|(key, _)| key.get().starts_with("cairo-lang-")) { + let dep_name = dep_name.get(); let dep = dep.as_value_mut().unwrap(); // Start with expanded form: { version = "X" } @@ -45,7 +49,7 @@ pub fn main(args: Args) -> Result<()> { new_dep.insert("version", version.to_string().into()); } - // Add Git branch/revision reference if requested. + // Add a Git branch or revision reference if requested. if args.spec.rev.is_some() || args.spec.branch.is_some() { new_dep.insert("git", "https://github.com/starkware-libs/cairo".into()); } @@ -58,6 +62,20 @@ pub fn main(args: Args) -> Result<()> { new_dep.insert("rev", rev.as_str().into()); } + // Add local path reference if requested. + // For local path sources, Cargo is not looking for crates recursively therefore, + // we need to manually provide full paths to Cairo workspace member crates. + if let Some(path) = &args.spec.path { + new_dep.insert( + "path", + path.join("crates") + .join(dep_name) + .to_string_lossy() + .into_owned() + .into(), + ); + } + // Sometimes we might specify extra features. Let's preserve these. if let Some(dep) = dep.as_inline_table() { if let Some(features) = dep.get("features") {