Skip to content
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

Make build output reproducible #1561

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 51 additions & 18 deletions build/i2c/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct I2cController {
// a controller *and* a named bus), so the validation code should go to
// additional lengths to assure that these mistakes are caught in compilation.
//
#[derive(Clone, Debug, Deserialize)]
#[derive(Clone, Debug, Deserialize, PartialOrd, Ord, Eq, PartialEq)]
#[serde(rename_all = "kebab-case", deny_unknown_fields)]
#[allow(dead_code)]
struct I2cDevice {
Expand Down Expand Up @@ -166,7 +166,7 @@ struct I2cMux {
nreset: Option<I2cGpio>,
}

#[derive(Clone, Debug, Deserialize)]
#[derive(Clone, Debug, Deserialize, PartialOrd, PartialEq, Eq, Ord)]
#[allow(dead_code)]
#[serde(rename_all = "kebab-case", deny_unknown_fields)]
struct I2cPower {
Expand All @@ -193,7 +193,7 @@ impl I2cPower {
}
}

#[derive(Clone, Debug, Deserialize)]
#[derive(Clone, Debug, Deserialize, PartialOrd, PartialEq, Eq, Ord)]
#[serde(rename_all = "kebab-case", deny_unknown_fields)]
#[allow(dead_code)]
struct I2cSensors {
Expand Down Expand Up @@ -249,20 +249,20 @@ impl I2cSensors {
}
}

#[derive(Debug, PartialEq, Eq, Hash)]
#[derive(Debug, PartialEq, Eq, Hash, Ord, PartialOrd)]
struct DeviceKey {
device: String,
kind: Sensor,
}

#[derive(Debug, PartialEq, Eq, Hash)]
#[derive(Debug, PartialEq, Eq, Hash, Ord, PartialOrd)]
struct DeviceNameKey {
device: String,
name: String,
kind: Sensor,
}

#[derive(Debug, PartialEq, Eq, Hash)]
#[derive(Debug, PartialEq, Eq, Hash, Ord, PartialOrd)]
struct DeviceRefdesKey {
device: String,
refdes: String,
Expand Down Expand Up @@ -1013,10 +1013,15 @@ impl ConfigGenerator {
match index {{"##
)?;

for (controller, indices) in by_controller.iter_all() {
let s: Vec<String> =
let mut all: Vec<_> = by_controller.iter_all().collect();
all.sort();

for (controller, indices) in all {
let mut s: Vec<String> =
indices.iter().map(|f| format!("{}", f)).collect::<_>();

s.sort();

write!(
&mut self.output,
r##"
Expand Down Expand Up @@ -1044,10 +1049,15 @@ impl ConfigGenerator {
match index {{"##
)?;

for (port, indices) in by_port.iter_all() {
let s: Vec<String> =
let mut all: Vec<_> = by_port.iter_all().collect();
all.sort();

for (port, indices) in all {
let mut s: Vec<String> =
indices.iter().map(|f| format!("{}", f)).collect::<_>();

s.sort();

write!(
&mut self.output,
r##"
Expand All @@ -1066,7 +1076,10 @@ impl ConfigGenerator {
"##
)?;

for (device, devices) in by_device.iter_all() {
let mut all: Vec<_> = by_device.iter_all().collect();
all.sort();

for (device, devices) in all {
write!(
&mut self.output,
r##"
Expand All @@ -1090,7 +1103,10 @@ impl ConfigGenerator {
)?;
}

for ((device, bus), devices) in by_bus.iter_all() {
let mut all: Vec<_> = by_bus.iter_all().collect();
all.sort();

for ((device, bus), devices) in all {
write!(
&mut self.output,
r##"
Expand All @@ -1114,7 +1130,9 @@ impl ConfigGenerator {
)?;
}

for ((device, name), d) in &by_name {
let mut all: Vec<_> = by_name.iter().collect();
all.sort();
for ((device, name), d) in &all {
write!(
&mut self.output,
r##"
Expand All @@ -1134,7 +1152,10 @@ impl ConfigGenerator {
)?;
}

for ((device, name), d) in &by_refdes {
let mut all: Vec<_> = by_refdes.iter().collect();
all.sort();

for ((device, name), d) in &all {
write!(
&mut self.output,
r##"
Expand Down Expand Up @@ -1332,7 +1353,10 @@ impl ConfigGenerator {
}
)?;

for (rail, (device, index)) in &byrail {
let mut all: Vec<_> = byrail.iter().collect();
all.sort();

for (rail, (device, index)) in &all {
write!(
&mut self.output,
r##"
Expand Down Expand Up @@ -1602,16 +1626,25 @@ impl ConfigGenerator {
}
}

for (k, ids) in s.by_device.iter_all() {
let mut by_device_sorted: Vec<_> = s.by_device.iter_all().collect();
by_device_sorted.sort();

for (k, ids) in &by_device_sorted {
self.emit_sensor(&k.device, &format!("{}", k.kind), ids)?;
}

for (k, ids) in s.by_name.iter_all() {
let mut by_name_sorted: Vec<_> = s.by_name.iter_all().collect();
by_name_sorted.sort();

for (k, ids) in &by_name_sorted {
let label = format!("{}_{}", k.name.to_uppercase(), k.kind);
self.emit_sensor(&k.device, &label, ids)?;
}

for (k, ids) in s.by_refdes.iter_all() {
let mut by_refdes_sorted: Vec<_> = s.by_refdes.iter_all().collect();
by_refdes_sorted.sort();

for (k, ids) in &by_refdes_sorted {
let label = format!("{}_{}", k.refdes.to_uppercase(), k.kind);
self.emit_sensor(&k.device, &label, ids)?;
}
Expand Down