Skip to content

Commit

Permalink
Merge pull request #52 from itmettkeDE/build-rs-support
Browse files Browse the repository at this point in the history
Adding support for build.rs scripts
  • Loading branch information
mettke authored Jul 30, 2023
2 parents 1161b1b + b56a7fc commit 1bb841f
Show file tree
Hide file tree
Showing 5 changed files with 720 additions and 621 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Simply run:
cargo install cargo-patch
```

This is not necessary when patching via `build.rs` file

## Usage

To patch a dependency one has to add the following
Expand Down Expand Up @@ -42,6 +44,25 @@ version one has to override the dependency using
serde = { path = './target/patch/serde-1.0.110' }
```

Instead of running `cargo patch` its also possible to add a `build.rs` file like this:

```rust
fn main() {
println!("cargo:rerun-if-changed=Cargo.toml");
println!("cargo:rerun-if-changed=patches/");
cargo_patch::patch().expect("Failed while patching");
}
```

To make it work, add the cargo-patch library to the `build-dependencies`

```tomlusing the
[build-dependencies]
cargo-patch = "0.3"
```

Note, however, that all your patches should be in a single folder called `patches` or something similar. This is to make sure that the build script is executed again when something changes.

## Patch format

You can either use [diff](http://man7.org/linux/man-pages/man1/diff.1.html) or
Expand Down
Loading

0 comments on commit 1bb841f

Please sign in to comment.