[cr137-follow-up] Correct crate patches to point to brave/ (#29132)

This change corrects all crate patches, changing them to point to
`brave/`. This eliminates the need of patching `gnrt vendor` to address
this patch mismatch.

Patches should be created now with:

```sh
git format-patch \
    --start-number=101 \
    --src-prefix=a/brave/ \
    --dst-prefix=b/brave/ \
    --output-directory \
        third_party/rust/chromium_crates_io/patches/some-crate/ \
    HEAD^
```

Resolves https://github.com/brave/brave-browser/issues/46201
This commit is contained in:
cdesouza-chromium
2025-05-21 09:16:14 +01:00
committed by GitHub
parent 5ca27b9484
commit b694664f80
11 changed files with 89 additions and 98 deletions
+23 -3
View File
@@ -3,7 +3,27 @@
When integrating Rust code into brave-core, keep the following points in mind:
- Chromiums networking stack must be used
- The deps being added (and the deps recursively being added) must be approved via an issue posted at [brave/reviews](https://github.com/brave/reviews/issues/new/choose)
- The deps being added (and the deps recursively being added) must be approved
via an issue posted at [brave/reviews](https://github.com/brave/reviews/issues/new/choose)
- The new code does not duplicate things already done in Chromium
- https://chromium.googlesource.com/chromium/src/+/main/docs/adding_to_third_party.md#rust also applies generally to all Rust code in brave-core
- Look at existing deps in `third_party/rust` and try to match up versions whenever possible. We are trying to avoid having multiple copies of the same third party libs
- https://chromium.googlesource.com/chromium/src/+/main/docs/adding_to_third_party.md#rust
also applies generally to all Rust code in brave-core
- Look at existing deps in `third_party/rust` and try to match up versions
whenever possible. We are trying to avoid having multiple copies of the same third party libs
### Patching crates
There can be cases where patching crates is necessary. To create a patch file,
make changes to a crate and create a patch with:
```sh
git format-patch \
--start-number=101 \
--src-prefix=a/brave/ \
--dst-prefix=b/brave/ \
--output-directory \
third_party/rust/chromium_crates_io/patches/some-crate/ \
HEAD^
```
For general instructions on how this works in upstream Chromium, check [these instructions](https://chromium.googlesource.com/chromium/src/+/HEAD/third_party/rust/chromium_crates_io/patches/README.md#steps-for-creating-new-patches).
+1 -10
View File
@@ -1,5 +1,5 @@
diff --git a/tools/crates/gnrt/vendor.rs b/tools/crates/gnrt/vendor.rs
index 17c059a85880f1153ef99ac4a72e29e21d5cbf19..15a58925aab3077f0df09c69a4e998cb8b6e3a8d 100644
index 17c059a85880f1153ef99ac4a72e29e21d5cbf19..5eb30dc5371c765147ccc83baa57cc1d619a59f2 100644
--- a/tools/crates/gnrt/vendor.rs
+++ b/tools/crates/gnrt/vendor.rs
@@ -130,7 +130,7 @@ fn download_crates(args: &VendorCommandArgs, paths: &paths::ChromiumPaths) -> Re
@@ -20,12 +20,3 @@ index 17c059a85880f1153ef99ac4a72e29e21d5cbf19..15a58925aab3077f0df09c69a4e998cb
else {
// No patches for this crate.
return Ok(());
@@ -368,7 +368,7 @@ fn apply_patches(
let args = vec![
"apply".to_string(),
// We need to rebase from the old versioned directory to the new one.
- format!("-p{}", crate_dir.ancestors().count()),
+ format!("-p{}", crate_dir.ancestors().count()-1),
format!("--directory={}", crate_dir.display()),
];
let mut c = std::process::Command::new("git");
@@ -7,10 +7,10 @@ Subject: [PATCH] disable autocfg probe
.../rust/chromium_crates_io/vendor/lock_api-0.4.9/build.rs | 1 +
1 file changed, 1 insertion(+)
diff --git a/third_party/rust/chromium_crates_io/vendor/lock_api-0.4.9/build.rs b/third_party/rust/chromium_crates_io/vendor/lock_api-0.4.9/build.rs
diff --git a/brave/third_party/rust/chromium_crates_io/vendor/lock_api-0.4.9/build.rs b/brave/third_party/rust/chromium_crates_io/vendor/lock_api-0.4.9/build.rs
index 886a3454c30..f52f18e7b33 100644
--- a/third_party/rust/chromium_crates_io/vendor/lock_api-0.4.9/build.rs
+++ b/third_party/rust/chromium_crates_io/vendor/lock_api-0.4.9/build.rs
--- a/brave/third_party/rust/chromium_crates_io/vendor/lock_api-0.4.9/build.rs
+++ b/brave/third_party/rust/chromium_crates_io/vendor/lock_api-0.4.9/build.rs
@@ -1,4 +1,5 @@
fn main() {
+ return; #[allow(unused)]
@@ -7,10 +7,10 @@ Subject: [PATCH] disable autocfg probe
.../rust/chromium_crates_io/vendor/num-bigint-0.2.6/build.rs | 1 +
1 file changed, 1 insertion(+)
diff --git a/third_party/rust/chromium_crates_io/vendor/num-bigint-0.2.6/build.rs b/third_party/rust/chromium_crates_io/vendor/num-bigint-0.2.6/build.rs
diff --git a/brave/third_party/rust/chromium_crates_io/vendor/num-bigint-0.2.6/build.rs b/brave/third_party/rust/chromium_crates_io/vendor/num-bigint-0.2.6/build.rs
index e483c15fd7f..3ea385c1c4e 100644
--- a/third_party/rust/chromium_crates_io/vendor/num-bigint-0.2.6/build.rs
+++ b/third_party/rust/chromium_crates_io/vendor/num-bigint-0.2.6/build.rs
--- a/brave/third_party/rust/chromium_crates_io/vendor/num-bigint-0.2.6/build.rs
+++ b/brave/third_party/rust/chromium_crates_io/vendor/num-bigint-0.2.6/build.rs
@@ -3,6 +3,7 @@ extern crate autocfg;
use std::env;
@@ -7,10 +7,10 @@ Subject: [PATCH] disable autocfg probe
.../vendor/num-bigint-0.3.3/build.rs | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/third_party/rust/chromium_crates_io/vendor/num-bigint-0.3.3/build.rs b/third_party/rust/chromium_crates_io/vendor/num-bigint-0.3.3/build.rs
diff --git a/brave/third_party/rust/chromium_crates_io/vendor/num-bigint-0.3.3/build.rs b/brave/third_party/rust/chromium_crates_io/vendor/num-bigint-0.3.3/build.rs
index 3daed5e8d33..0ef8fea1b3b 100644
--- a/third_party/rust/chromium_crates_io/vendor/num-bigint-0.3.3/build.rs
+++ b/third_party/rust/chromium_crates_io/vendor/num-bigint-0.3.3/build.rs
--- a/brave/third_party/rust/chromium_crates_io/vendor/num-bigint-0.3.3/build.rs
+++ b/brave/third_party/rust/chromium_crates_io/vendor/num-bigint-0.3.3/build.rs
@@ -10,6 +10,7 @@ fn main() {
if u64_digit {
autocfg::emit("u64_digit");
@@ -1,46 +0,0 @@
From 9d6d3944b3c2b254b5381cd0bce6d09df72041bb Mon Sep 17 00:00:00 2001
From: bridiver <34129+bridiver@users.noreply.github.com>
Date: Thu, 7 Mar 2024 14:12:13 -0700
Subject: [PATCH] disable autocfg probe
---
.../vendor/num-bigint-0.4.3/build.rs | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/third_party/rust/chromium_crates_io/vendor/num-bigint-0.4.3/build.rs b/third_party/rust/chromium_crates_io/vendor/num-bigint-0.4.3/build.rs
index 3daed5e8d33..37bf985cb20 100644
--- a/third_party/rust/chromium_crates_io/vendor/num-bigint-0.4.3/build.rs
+++ b/third_party/rust/chromium_crates_io/vendor/num-bigint-0.4.3/build.rs
@@ -10,6 +10,7 @@ fn main() {
if u64_digit {
autocfg::emit("u64_digit");
}
+/*
let ac = autocfg::new();
let std = if ac.probe_sysroot_crate("std") {
"std"
@@ -17,17 +18,18 @@ fn main() {
"core"
};
if ac.probe_path(&format!("{}::convert::TryFrom", std)) {
+*/
autocfg::emit("has_try_from");
- }
-
+// }
if let Ok(target_arch) = env::var("CARGO_CFG_TARGET_ARCH") {
if target_arch == "x86_64" || target_arch == "x86" {
let digit = if u64_digit { "u64" } else { "u32" };
-
+/*
let addcarry = format!("{}::arch::{}::_addcarry_{}", std, target_arch, digit);
if ac.probe_path(&addcarry) {
+*/
autocfg::emit("use_addcarry");
- }
+// }
}
}
--
2.47.0
@@ -1,24 +0,0 @@
From 9d3f8aadccd6ca8ce086b9cfa0128831aca4ebf6 Mon Sep 17 00:00:00 2001
From: bridiver <34129+bridiver@users.noreply.github.com>
Date: Thu, 7 Mar 2024 13:45:11 -0700
Subject: [PATCH] disable autocfg probe
---
.../rust/chromium_crates_io/vendor/num-traits-0.2.15/build.rs | 1 +
1 file changed, 1 insertion(+)
diff --git a/third_party/rust/chromium_crates_io/vendor/num-traits-0.2.15/build.rs b/third_party/rust/chromium_crates_io/vendor/num-traits-0.2.15/build.rs
index c7bf364f1c4..21558be6541 100644
--- a/third_party/rust/chromium_crates_io/vendor/num-traits-0.2.15/build.rs
+++ b/third_party/rust/chromium_crates_io/vendor/num-traits-0.2.15/build.rs
@@ -3,6 +3,7 @@ extern crate autocfg;
use std::env;
fn main() {
+ return; #[allow(unused)]
let ac = autocfg::new();
// If the "i128" feature is explicity requested, don't bother probing for it.
--
2.38.1
@@ -7,10 +7,10 @@ Subject: [PATCH] Make ExtendedSpendingKey public
.../chromium_crates_io/vendor/orchard-0.8.0/src/zip32.rs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/third_party/rust/chromium_crates_io/vendor/orchard-0.8.0/src/zip32.rs b/third_party/rust/chromium_crates_io/vendor/orchard-0.8.0/src/zip32.rs
diff --git a/brave/third_party/rust/chromium_crates_io/vendor/orchard-0.8.0/src/zip32.rs b/brave/third_party/rust/chromium_crates_io/vendor/orchard-0.8.0/src/zip32.rs
index 31f318b111d..c37aeebf6ba 100644
--- a/third_party/rust/chromium_crates_io/vendor/orchard-0.8.0/src/zip32.rs
+++ b/third_party/rust/chromium_crates_io/vendor/orchard-0.8.0/src/zip32.rs
--- a/brave/third_party/rust/chromium_crates_io/vendor/orchard-0.8.0/src/zip32.rs
+++ b/brave/third_party/rust/chromium_crates_io/vendor/orchard-0.8.0/src/zip32.rs
@@ -122,7 +122,7 @@ impl KeyIndex {
///
/// [orchardextendedkeys]: https://zips.z.cash/zip-0032#orchard-extended-keys
@@ -7,10 +7,10 @@ Subject: [PATCH] disable autocfg probe
third_party/rust/chromium_crates_io/vendor/slab-0.4.8/build.rs | 1 +
1 file changed, 1 insertion(+)
diff --git a/third_party/rust/chromium_crates_io/vendor/slab-0.4.8/build.rs b/third_party/rust/chromium_crates_io/vendor/slab-0.4.8/build.rs
diff --git a/brave/third_party/rust/chromium_crates_io/vendor/slab-0.4.8/build.rs b/brave/third_party/rust/chromium_crates_io/vendor/slab-0.4.8/build.rs
index b60351aaf2a..6a56d349119 100644
--- a/third_party/rust/chromium_crates_io/vendor/slab-0.4.8/build.rs
+++ b/third_party/rust/chromium_crates_io/vendor/slab-0.4.8/build.rs
--- a/brave/third_party/rust/chromium_crates_io/vendor/slab-0.4.8/build.rs
+++ b/brave/third_party/rust/chromium_crates_io/vendor/slab-0.4.8/build.rs
@@ -1,4 +1,5 @@
fn main() {
+ return; #[allow(unused)]
@@ -0,0 +1,25 @@
Copyright (c) 2014 The Rust Project Developers
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,25 @@
Copyright (c) 2014 The Rust Project Developers
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.