Merge "cargo_embargo: dedup output modules" am: 32be457c7a
Original change: https://android-review.googlesource.com/c/platform/development/+/2583718 Change-Id: Ic3fe6b120fa34e1be3b41ca09fa5200591b84b45 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -16,13 +16,14 @@ use anyhow::Result;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
/// Build module.
|
||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct BpModule {
|
||||
module_type: String,
|
||||
pub props: BpProperties,
|
||||
}
|
||||
|
||||
/// Properties of a build module, or of a nested object value.
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct BpProperties {
|
||||
map: BTreeMap<String, BpValue>,
|
||||
/// A raw block of text to append after the last key-value pair, but before the closing brace.
|
||||
@@ -43,7 +44,7 @@ pub struct BpProperties {
|
||||
pub raw_block: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub enum BpValue {
|
||||
Object(BpProperties),
|
||||
Bool(bool),
|
||||
|
||||
@@ -373,6 +373,12 @@ fn write_android_bp(
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// In some cases there are nearly identical rustc invocations that that get processed into
|
||||
// identical BP modules. So far, dedup'ing them is a good enough fix. At some point we might
|
||||
// need something more complex, maybe like cargo2android's logic for merging crates.
|
||||
modules.sort();
|
||||
modules.dedup();
|
||||
|
||||
modules.sort_by_key(|m| m.props.get_string("name").to_string());
|
||||
for m in modules {
|
||||
m.write(&mut bp_contents)?;
|
||||
|
||||
Reference in New Issue
Block a user