-
Notifications
You must be signed in to change notification settings - Fork 893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
move rust crates to chromium_crate_io #21759
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
diff --git a/tools/crates/gnrt/gen.rs b/tools/crates/gnrt/gen.rs | ||
index c056a69e03a96a762718f4dd5cd8e23accf5e455..8229e46a96c8581e35e9b5e44c699f73031c94e9 100644 | ||
--- a/tools/crates/gnrt/gen.rs | ||
+++ b/tools/crates/gnrt/gen.rs | ||
@@ -266,6 +266,7 @@ fn generate_for_third_party(args: GenCommandArgs, paths: &paths::ChromiumPaths) | ||
// Remove any excluded dep entries. | ||
dependencies | ||
.retain(|dep| !config.resolve.remove_crates.iter().any(|r| **r == dep.package_name)); | ||
+ dependencies.retain(|dep| !dep.is_local ); | ||
|
||
// Remove dev dependencies since tests aren't run. | ||
dependencies.retain(|dep| { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
diff --git a/tools/crates/gnrt/lib/gn.rs b/tools/crates/gnrt/lib/gn.rs | ||
index 8961d575419f079369685ba7721788676ac67c91..1f3a8acfae8ab844639dfb33246c540202e399df 100644 | ||
--- a/tools/crates/gnrt/lib/gn.rs | ||
+++ b/tools/crates/gnrt/lib/gn.rs | ||
@@ -199,8 +199,9 @@ pub fn build_rule_from_std_dep( | ||
let mut aliases = Vec::new(); | ||
for dep in &normal_deps { | ||
let target_name = NormalizedName::from_crate_name(&dep.package_name).to_string(); | ||
+ let epoch = Epoch::from_version(&dep.version).to_string(); | ||
if target_name != dep.use_name { | ||
- aliases.push((dep.use_name.clone(), format!(":{target_name}"))); | ||
+ aliases.push((dep.use_name.clone(), format!("{target_name}/{epoch}"))); | ||
} | ||
} | ||
aliases.sort_unstable(); | ||
@@ -536,6 +537,7 @@ static TRIPLE_TO_GN_CONDITION: &[(&str, &str)] = &[ | ||
static TARGET_OS_TO_GN_CONDITION: &[(&str, &str)] = &[ | ||
("android", "is_android"), | ||
("darwin", "is_mac"), | ||
+ ("macos", "is_mac"), | ||
("fuchsia", "is_fuchsia"), | ||
("ios", "is_ios"), | ||
("linux", "is_linux || is_chromeos"), |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
diff --git a/tools/crates/gnrt/lib/paths.rs b/tools/crates/gnrt/lib/paths.rs | ||
index 3c1ea93728fc624701d6c7755dbeb9fcc6765ef3..80d09707ad6667892d38fd39f3959892cefe95ab 100644 | ||
--- a/tools/crates/gnrt/lib/paths.rs | ||
+++ b/tools/crates/gnrt/lib/paths.rs | ||
@@ -110,7 +110,7 @@ pub fn normalize_unix_path_separator(path: &Path) -> String { | ||
.join("/") | ||
} | ||
|
||
-static RUST_THIRD_PARTY_DIR: &str = "third_party/rust"; | ||
+static RUST_THIRD_PARTY_DIR: &str = "brave/third_party/rust"; | ||
static RUST_SRC_LIBRARY_SUBDIR: &str = "library"; | ||
static RUST_SRC_VENDOR_SUBDIR: &str = "vendor"; | ||
static RUST_SRC_INSTALLED_DIR: &str = "third_party/rust-toolchain/lib/rustlib/src/rust"; | ||
@@ -121,8 +121,8 @@ static STD_FAKE_ROOT: &str = "build/rust/std/fake_root"; | ||
static STD_FAKE_ROOT_CONFIG_TEMPLATE: &str = "build/rust/std/fake_root/.cargo/config.toml.template"; | ||
static STD_FAKE_ROOT_CARGO_TEMPLATE: &str = "build/rust/std/fake_root/Cargo.toml.template"; | ||
|
||
-static THIRD_PARTY_CARGO_ROOT: &str = "third_party/rust/chromium_crates_io"; | ||
-static THIRD_PARTY_CONFIG_FILE: &str = "third_party/rust/chromium_crates_io/gnrt_config.toml"; | ||
+static THIRD_PARTY_CARGO_ROOT: &str = "brave/third_party/rust/chromium_crates_io"; | ||
+static THIRD_PARTY_CONFIG_FILE: &str = "brave/third_party/rust/chromium_crates_io/gnrt_config.toml"; | ||
|
||
static VET_CONFIG_FILE: &str = "third_party/rust/chromium_crates_io/supply-chain/config.toml"; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/tools/crates/gnrt/lib/platforms.rs b/tools/crates/gnrt/lib/platforms.rs | ||
index 2e710ad94da6053174d1fbb464c808d8d0862e40..dfec666b5d60d0290bb14b303c22663520c96d3f 100644 | ||
--- a/tools/crates/gnrt/lib/platforms.rs | ||
+++ b/tools/crates/gnrt/lib/platforms.rs | ||
@@ -234,7 +234,7 @@ fn supported_os_cfgs() -> &'static [Cfg] { | ||
CFG_SET.get_or_init(|| { | ||
[ | ||
// Set of supported OSes for `cfg(target_os = ...)`. | ||
- "android", "darwin", "fuchsia", "ios", "linux", "windows", | ||
+ "android", "macos", "darwin", "fuchsia", "ios", "linux", "windows", | ||
] | ||
.into_iter() | ||
.map(|os| Cfg::KeyPair("target_os".to_string(), os.to_string())) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
diff --git a/tools/crates/gnrt/lib/readme.rs b/tools/crates/gnrt/lib/readme.rs | ||
index 8532dd95edf5ed2f83731f257589531049eb9255..d4b7890a663c4b8e7df7a0fc14f4970103004f9f 100644 | ||
--- a/tools/crates/gnrt/lib/readme.rs | ||
+++ b/tools/crates/gnrt/lib/readme.rs | ||
@@ -193,7 +193,7 @@ pub fn readme_file_from_package<'a>( | ||
|
||
// Allowed licenses, in the format they are specified in Cargo.toml files from | ||
// crates.io, and the format to write to README.chromium. | ||
-static ALLOWED_LICENSES: [(&str, &str); 20] = [ | ||
+static ALLOWED_LICENSES: [(&str, &str); 24] = [ | ||
// ("Cargo.toml string", "License for README.chromium") | ||
("Apache-2.0", "Apache 2.0"), | ||
("MIT OR Apache-2.0", "Apache 2.0"), | ||
@@ -218,6 +218,10 @@ static ALLOWED_LICENSES: [(&str, &str); 20] = [ | ||
"Apache 2.0 AND Unicode License Agreement - Data Files and Software (2016)", | ||
), | ||
("Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT", "Apache 2.0"), | ||
+ ("CC0-1.0 OR MIT-0 OR Apache-2.0", "Apache 2.0"), | ||
+ ("MIT OR Apache-2.0 OR BSD-1-Clause", "Apache 2.0"), | ||
+ ("BSD-2-Clause", "BSD 2-Clause"), | ||
+ ("MPL-2.0", "Mozilla Public License 2.0"), | ||
]; | ||
|
||
static EXPECTED_LICENSE_FILE: [(&str, &str); 15] = [ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
diff --git a/tools/crates/gnrt/vendor.rs b/tools/crates/gnrt/vendor.rs | ||
index be4dbf2dba2a67804e684d743d815fc7fdace87e..3b10471f6535679fe4a56bea80fa653d929c5291 100644 | ||
--- a/tools/crates/gnrt/vendor.rs | ||
+++ b/tools/crates/gnrt/vendor.rs | ||
@@ -96,7 +96,7 @@ fn vendor_impl(args: VendorCommandArgs, paths: &paths::ChromiumPaths) -> Result< | ||
if config.resolve.remove_crates.contains(&p.name) { | ||
println!("Generating placeholder for removed crate {}-{}", p.name, p.version); | ||
placeholder_crate(p, &nodes, paths, &config)?; | ||
- } else if !dirs.contains(&crate_dir) { | ||
+ } else if !dirs.contains(&crate_dir) && p.source.is_some() { | ||
println!("Downloading {}-{}", p.name, p.version); | ||
download_crate(&p.name, &p.version, paths)?; | ||
let skip_patches = match &args.no_patches { | ||
@@ -266,7 +266,7 @@ fn apply_patches( | ||
let crate_dir = vendor_dir.join(format!("{name}-{version}")); | ||
|
||
let mut patches = Vec::new(); | ||
- let Ok(patch_dir) = std::fs::read_dir(paths.third_party_cargo_root.join("patches").join(name)) | ||
+ let Ok(patch_dir) = std::fs::read_dir(paths.third_party_cargo_root.join("patches").join(format!("{name}-{version}"))) | ||
else { | ||
// No patches for this crate. | ||
return Ok(()); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,11 @@ def AddBraveCredits(root, prune_paths, special_cases, prune_dirs, | |
os.path.join('brave', 'vendor', 'brave-ios'), | ||
os.path.join('brave', 'vendor', 'brave_base'), | ||
|
||
# These have auto-generated license files and | ||
# GetThirdPartyDepsFromGNDepsOutput causes strange license errors | ||
# unless the this entire directory is excluded. | ||
os.path.join('brave', 'third_party', 'rust'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this can just exclude There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please see the comment explaining why the entire directory is excluded There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I read the comment, but I couldn't reproduce the errors. I suppose it doesn't matter much, but the narrower scope seemed a safer hack. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can try it again, but it failed with a very strange error before |
||
|
||
# No third-party code directly under android_deps. It's all under | ||
# android_deps/libs instead and it's special-cased further down. | ||
os.path.join('brave', 'third_party', 'android_deps'), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at least some of these patches can go to upstream, we'll figure out the details in a follow-up