Skip to content

Commit b694664

Browse files
[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 brave/brave-browser#46201
1 parent 5ca27b9 commit b694664

File tree

11 files changed

+89
-98
lines changed

11 files changed

+89
-98
lines changed

docs/rust.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,27 @@
33
When integrating Rust code into brave-core, keep the following points in mind:
44

55
- Chromium’s networking stack must be used
6-
- 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)
6+
- The deps being added (and the deps recursively being added) must be approved
7+
via an issue posted at [brave/reviews](https://github.com/brave/reviews/issues/new/choose)
78
- The new code does not duplicate things already done in Chromium
8-
- https://chromium.googlesource.com/chromium/src/+/main/docs/adding_to_third_party.md#rust also applies generally to all Rust code in brave-core
9-
- 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
9+
- https://chromium.googlesource.com/chromium/src/+/main/docs/adding_to_third_party.md#rust
10+
also applies generally to all Rust code in brave-core
11+
- Look at existing deps in `third_party/rust` and try to match up versions
12+
whenever possible. We are trying to avoid having multiple copies of the same third party libs
13+
14+
### Patching crates
15+
16+
There can be cases where patching crates is necessary. To create a patch file,
17+
make changes to a crate and create a patch with:
18+
19+
```sh
20+
git format-patch \
21+
--start-number=101 \
22+
--src-prefix=a/brave/ \
23+
--dst-prefix=b/brave/ \
24+
--output-directory \
25+
third_party/rust/chromium_crates_io/patches/some-crate/ \
26+
HEAD^
27+
```
28+
29+
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).

patches/tools-crates-gnrt-vendor.rs.patch

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/tools/crates/gnrt/vendor.rs b/tools/crates/gnrt/vendor.rs
2-
index 17c059a85880f1153ef99ac4a72e29e21d5cbf19..15a58925aab3077f0df09c69a4e998cb8b6e3a8d 100644
2+
index 17c059a85880f1153ef99ac4a72e29e21d5cbf19..5eb30dc5371c765147ccc83baa57cc1d619a59f2 100644
33
--- a/tools/crates/gnrt/vendor.rs
44
+++ b/tools/crates/gnrt/vendor.rs
55
@@ -130,7 +130,7 @@ fn download_crates(args: &VendorCommandArgs, paths: &paths::ChromiumPaths) -> Re
@@ -20,12 +20,3 @@ index 17c059a85880f1153ef99ac4a72e29e21d5cbf19..15a58925aab3077f0df09c69a4e998cb
2020
else {
2121
// No patches for this crate.
2222
return Ok(());
23-
@@ -368,7 +368,7 @@ fn apply_patches(
24-
let args = vec![
25-
"apply".to_string(),
26-
// We need to rebase from the old versioned directory to the new one.
27-
- format!("-p{}", crate_dir.ancestors().count()),
28-
+ format!("-p{}", crate_dir.ancestors().count()-1),
29-
format!("--directory={}", crate_dir.display()),
30-
];
31-
let mut c = std::process::Command::new("git");

third_party/rust/chromium_crates_io/patches/lock_api-0.4.9/0001-disable-autocfg-probe.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ Subject: [PATCH] disable autocfg probe
77
.../rust/chromium_crates_io/vendor/lock_api-0.4.9/build.rs | 1 +
88
1 file changed, 1 insertion(+)
99

10-
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
10+
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
1111
index 886a3454c30..f52f18e7b33 100644
12-
--- a/third_party/rust/chromium_crates_io/vendor/lock_api-0.4.9/build.rs
13-
+++ b/third_party/rust/chromium_crates_io/vendor/lock_api-0.4.9/build.rs
12+
--- a/brave/third_party/rust/chromium_crates_io/vendor/lock_api-0.4.9/build.rs
13+
+++ b/brave/third_party/rust/chromium_crates_io/vendor/lock_api-0.4.9/build.rs
1414
@@ -1,4 +1,5 @@
1515
fn main() {
1616
+ return; #[allow(unused)]

third_party/rust/chromium_crates_io/patches/num-bigint-0.2.6/0001-disable-autocfg-probe.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ Subject: [PATCH] disable autocfg probe
77
.../rust/chromium_crates_io/vendor/num-bigint-0.2.6/build.rs | 1 +
88
1 file changed, 1 insertion(+)
99

10-
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
10+
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
1111
index e483c15fd7f..3ea385c1c4e 100644
12-
--- a/third_party/rust/chromium_crates_io/vendor/num-bigint-0.2.6/build.rs
13-
+++ b/third_party/rust/chromium_crates_io/vendor/num-bigint-0.2.6/build.rs
12+
--- a/brave/third_party/rust/chromium_crates_io/vendor/num-bigint-0.2.6/build.rs
13+
+++ b/brave/third_party/rust/chromium_crates_io/vendor/num-bigint-0.2.6/build.rs
1414
@@ -3,6 +3,7 @@ extern crate autocfg;
1515
use std::env;
1616

third_party/rust/chromium_crates_io/patches/num-bigint-0.3.3/0001-disable-autocfg-probe.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ Subject: [PATCH] disable autocfg probe
77
.../vendor/num-bigint-0.3.3/build.rs | 13 ++++++++-----
88
1 file changed, 8 insertions(+), 5 deletions(-)
99

10-
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
10+
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
1111
index 3daed5e8d33..0ef8fea1b3b 100644
12-
--- a/third_party/rust/chromium_crates_io/vendor/num-bigint-0.3.3/build.rs
13-
+++ b/third_party/rust/chromium_crates_io/vendor/num-bigint-0.3.3/build.rs
12+
--- a/brave/third_party/rust/chromium_crates_io/vendor/num-bigint-0.3.3/build.rs
13+
+++ b/brave/third_party/rust/chromium_crates_io/vendor/num-bigint-0.3.3/build.rs
1414
@@ -10,6 +10,7 @@ fn main() {
1515
if u64_digit {
1616
autocfg::emit("u64_digit");

third_party/rust/chromium_crates_io/patches/num-bigint-0.4.3/0001-disable-autocfg-probe.patch

Lines changed: 0 additions & 46 deletions
This file was deleted.

third_party/rust/chromium_crates_io/patches/num-traits-0.2.15/0001-disable-autocfg-probe.patch

Lines changed: 0 additions & 24 deletions
This file was deleted.

third_party/rust/chromium_crates_io/patches/orchard-0.8.0/0001-Make-ExtendedSpendingKey-public.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ Subject: [PATCH] Make ExtendedSpendingKey public
77
.../chromium_crates_io/vendor/orchard-0.8.0/src/zip32.rs | 6 +++---
88
1 file changed, 3 insertions(+), 3 deletions(-)
99

10-
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
10+
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
1111
index 31f318b111d..c37aeebf6ba 100644
12-
--- a/third_party/rust/chromium_crates_io/vendor/orchard-0.8.0/src/zip32.rs
13-
+++ b/third_party/rust/chromium_crates_io/vendor/orchard-0.8.0/src/zip32.rs
12+
--- a/brave/third_party/rust/chromium_crates_io/vendor/orchard-0.8.0/src/zip32.rs
13+
+++ b/brave/third_party/rust/chromium_crates_io/vendor/orchard-0.8.0/src/zip32.rs
1414
@@ -122,7 +122,7 @@ impl KeyIndex {
1515
///
1616
/// [orchardextendedkeys]: https://zips.z.cash/zip-0032#orchard-extended-keys

third_party/rust/chromium_crates_io/patches/slab-0.4.8/0001-disable-autocfg-probe.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ Subject: [PATCH] disable autocfg probe
77
third_party/rust/chromium_crates_io/vendor/slab-0.4.8/build.rs | 1 +
88
1 file changed, 1 insertion(+)
99

10-
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
10+
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
1111
index b60351aaf2a..6a56d349119 100644
12-
--- a/third_party/rust/chromium_crates_io/vendor/slab-0.4.8/build.rs
13-
+++ b/third_party/rust/chromium_crates_io/vendor/slab-0.4.8/build.rs
12+
--- a/brave/third_party/rust/chromium_crates_io/vendor/slab-0.4.8/build.rs
13+
+++ b/brave/third_party/rust/chromium_crates_io/vendor/slab-0.4.8/build.rs
1414
@@ -1,4 +1,5 @@
1515
fn main() {
1616
+ return; #[allow(unused)]
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright (c) 2014 The Rust Project Developers
2+
3+
Permission is hereby granted, free of charge, to any
4+
person obtaining a copy of this software and associated
5+
documentation files (the "Software"), to deal in the
6+
Software without restriction, including without
7+
limitation the rights to use, copy, modify, merge,
8+
publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software
10+
is furnished to do so, subject to the following
11+
conditions:
12+
13+
The above copyright notice and this permission notice
14+
shall be included in all copies or substantial portions
15+
of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
18+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
20+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
21+
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
24+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25+
DEALINGS IN THE SOFTWARE.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright (c) 2014 The Rust Project Developers
2+
3+
Permission is hereby granted, free of charge, to any
4+
person obtaining a copy of this software and associated
5+
documentation files (the "Software"), to deal in the
6+
Software without restriction, including without
7+
limitation the rights to use, copy, modify, merge,
8+
publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software
10+
is furnished to do so, subject to the following
11+
conditions:
12+
13+
The above copyright notice and this permission notice
14+
shall be included in all copies or substantial portions
15+
of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
18+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
20+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
21+
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
24+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25+
DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)