Skip to content

Commit

Permalink
Fix not tracking wgsl file changes for web build (#4374)
Browse files Browse the repository at this point in the history
### What

* Fixes #2185
* the "and compiles too many things" seems to have resolved itself, at
least I can't see how that's the case

Turned out we accidentally only tracked them for re_viewer itself

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [app.rerun.io](https://app.rerun.io/pr/4374) (if
applicable)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG

- [PR Build Summary](https://build.rerun.io/pr/4374)
- [Docs
preview](https://rerun.io/preview/359cf68a0aed5ea7a47dba4dd4927b10a4773b2c/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/359cf68a0aed5ea7a47dba4dd4927b10a4773b2c/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
  • Loading branch information
Wumpf authored and teh-cmc committed Nov 30, 2023
1 parent 080d09e commit 5483e4d
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions crates/re_build_tools/src/rebuild_detector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
path::{Path, PathBuf},
};

use cargo_metadata::{CargoOpt, Metadata, MetadataCommand, Package, PackageId};
use cargo_metadata::{camino::Utf8Path, CargoOpt, Metadata, MetadataCommand, Package, PackageId};

use crate::should_output_cargo_build_instructions;

Expand Down Expand Up @@ -138,6 +138,16 @@ pub fn write_file_if_necessary(
std::fs::write(path, content)
}

/// Track any files that are part of the given crate, identified by the manifest path.
fn track_crate_files(manifest_path: &Utf8Path, files_to_watch: &mut HashSet<PathBuf>) {
let mut dep_path = manifest_path.to_owned();
dep_path.pop();

rerun_if_changed_glob(dep_path.join("Cargo.toml"), files_to_watch); // manifest too!
rerun_if_changed_glob(dep_path.join("**/*.rs"), files_to_watch);
rerun_if_changed_glob(dep_path.join("**/*.wgsl"), files_to_watch);
}

// ---

pub struct Packages<'a> {
Expand Down Expand Up @@ -168,16 +178,7 @@ impl<'a> Packages<'a> {
});

// Track the root package itself
{
let mut path = pkg.manifest_path.clone();
path.pop();

// NOTE: Since we track the cargo manifest, past this point we only need to
// account for locally patched dependencies.
rerun_if_changed_glob(path.join("Cargo.toml"), files_to_watch);
rerun_if_changed_glob(path.join("**/*.rs"), files_to_watch);
rerun_if_changed_glob(path.join("**/*.wgsl"), files_to_watch);
}
track_crate_files(&pkg.manifest_path, files_to_watch);

// Track all direct and indirect dependencies of that root package
let mut tracked = HashSet::new();
Expand All @@ -202,11 +203,7 @@ impl<'a> Packages<'a> {
{
let exists_on_local_disk = dep_pkg.source.is_none();
if exists_on_local_disk {
let mut dep_path = dep_pkg.manifest_path.clone();
dep_path.pop();

rerun_if_changed_glob(dep_path.join("Cargo.toml"), files_to_watch); // manifest too!
rerun_if_changed_glob(dep_path.join("**/*.rs"), files_to_watch);
track_crate_files(&dep_pkg.manifest_path, files_to_watch);
}

if tracked.insert(dep_pkg.id.clone()) {
Expand Down

0 comments on commit 5483e4d

Please sign in to comment.