Skip to content

Commit

Permalink
Don't recompile dpe every single time
Browse files Browse the repository at this point in the history
The build script always writes to `arbitrary_max_handles.rs`, which
means that a recompile is always required.

This then triggers a rebuild of any project (i.e., Caliptra) that uses
this.

This fixes is so that we only write the file if the contents need to be
changed, so the build can be cached.

Clippy fix
  • Loading branch information
swenson authored and jhand2 committed Feb 3, 2025
1 parent 7679315 commit 3870341
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
17 changes: 7 additions & 10 deletions dpe/build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Licensed under the Apache-2.0 license

use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;

fn main() {
let default_value: usize = 24;
Expand All @@ -18,13 +17,11 @@ fn main() {
println!("cargo:rerun-if-env-changed=ARBITRARY_MAX_HANDLES");
println!("cargo:rerun-if-changed=build.rs");

let mut file = File::create(&dest_path).unwrap();
write!(
file,
"pub const MAX_HANDLES: usize = {};",
arbitrary_max_handles
)
.unwrap();
let max_handles_str = format!("pub const MAX_HANDLES: usize = {};", arbitrary_max_handles);

println!("cargo:rerun-if-changed={}", dest_path);
let dest_path = PathBuf::from(&dest_path);
if dest_path.exists() && std::fs::read_to_string(&dest_path).unwrap_or_default() != max_handles_str {
std::fs::write(&dest_path, max_handles_str).unwrap();
}
println!("cargo:rerun-if-changed={}", dest_path.display());
}
5 changes: 1 addition & 4 deletions dpe/src/x509.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2994,10 +2994,7 @@ pub(crate) mod tests {
_ => (),
}

match cert.get_extension_unique(&oid!(2.5.29 .35)) {
Err(_) => panic!("multiple authority key identifier extensions found"),
_ => (),
}
if let Err(_) = cert.get_extension_unique(&oid!(2.5.29 .35)) { panic!("multiple authority key identifier extensions found") }

match cert.subject_alternative_name() {
Ok(Some(ext)) => {
Expand Down

0 comments on commit 3870341

Please sign in to comment.