Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 0e2115f

Browse files
Treehugger RobotGerrit Code Review
authored andcommitted
Merge "Rebuild cargo_embargo every 2 weeks." into main
2 parents ed71332 + 7fefbbe commit 0e2115f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tools/external_crates/crate_tool/src/android_bp.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use std::{
1818
fs::{remove_file, rename},
1919
path::Path,
2020
process::{Command, Output},
21+
time::{Duration, SystemTime},
2122
};
2223

2324
use anyhow::{Context, Result};
@@ -84,12 +85,16 @@ pub fn cargo_embargo_autoconfig(path: &RootedPath) -> Result<Output> {
8485
}
8586

8687
pub fn maybe_build_cargo_embargo(repo_root: &impl AsRef<Path>, force_rebuild: bool) -> Result<()> {
87-
if !force_rebuild && repo_root.as_ref().join("out/host/linux-x86/bin/cargo_embargo").exists() {
88-
Ok(())
89-
} else {
88+
let cargo_embargo = repo_root.as_ref().join("out/host/linux-x86/bin/cargo_embargo");
89+
if force_rebuild
90+
|| !cargo_embargo.exists()
91+
|| SystemTime::now().duration_since(cargo_embargo.metadata()?.modified()?)?
92+
> Duration::from_secs(14 * 24 * 60 * 60)
93+
{
9094
println!("Rebuilding cargo_embargo");
91-
build_cargo_embargo(repo_root)
95+
return build_cargo_embargo(repo_root);
9296
}
97+
Ok(())
9398
}
9499

95100
pub fn build_cargo_embargo(repo_root: &impl AsRef<Path>) -> Result<()> {

0 commit comments

Comments
 (0)