Skip to content

Commit

Permalink
Rerun repository rule if manifests changed
Browse files Browse the repository at this point in the history
  • Loading branch information
illicitonion committed Dec 17, 2024
1 parent 7a1f037 commit 0104980
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions crate_universe/src/cli/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,12 @@ pub fn generate(opt: GenerateOptions) -> Result<()> {
// Write the outputs to disk
write_outputs(normalized_outputs, opt.dry_run)?;

let splicing_manifest = SplicingManifest::try_from_path(&opt.splicing_manifest)?;

write_paths_to_track(
&opt.paths_to_track,
&opt.warnings_output_path,
splicing_manifest.manifests.keys(),
context
.crates
.values()
Expand Down Expand Up @@ -164,9 +167,12 @@ pub fn generate(opt: GenerateOptions) -> Result<()> {
&opt.nonhermetic_root_bazel_workspace_dir,
)?;

let splicing_manifest = SplicingManifest::try_from_path(&opt.splicing_manifest)?;

write_paths_to_track(
&opt.paths_to_track,
&opt.warnings_output_path,
splicing_manifest.manifests.keys(),
annotations.lockfile.crates.values(),
cargo_lockfile.patch.unused.iter(),
)?;
Expand All @@ -189,8 +195,6 @@ pub fn generate(opt: GenerateOptions) -> Result<()> {

// Ensure Bazel lockfiles are written to disk so future generations can be short-circuited.
if let Some(lockfile) = opt.lockfile {
let splicing_manifest = SplicingManifest::try_from_path(&opt.splicing_manifest)?;

let lock_content =
lock_context(context, &config, &splicing_manifest, &cargo_bin, rustc_bin)?;

Expand Down Expand Up @@ -220,10 +224,12 @@ fn update_cargo_lockfile(path: &Path, cargo_lockfile: Lockfile) -> Result<()> {
fn write_paths_to_track<
'a,
SourceAnnotations: Iterator<Item = &'a SourceAnnotation>,
Paths: Iterator<Item = &'a Utf8PathBuf>,
UnusedPatches: Iterator<Item = &'a cargo_lock::Dependency>,
>(
output_file: &Path,
warnings_output_path: &Path,
manifests: Paths,
source_annotations: SourceAnnotations,
unused_patches: UnusedPatches,
) -> Result<()> {
Expand All @@ -235,6 +241,7 @@ fn write_paths_to_track<
None
}
})
.chain(manifests)
.collect();
std::fs::write(
output_file,
Expand Down

0 comments on commit 0104980

Please sign in to comment.