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

wasm-builder: Optimize rerun-if-changed logic #2282

Merged
merged 2 commits into from
Nov 13, 2023
Merged
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
14 changes: 8 additions & 6 deletions substrate/utils/wasm-builder/src/wasm_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use crate::{write_file_if_changed, CargoCommandVersioned, OFFLINE};

use build_helper::rerun_if_changed;
use cargo_metadata::{CargoOpt, Metadata, MetadataCommand};
use cargo_metadata::{DependencyKind, Metadata, MetadataCommand};
use parity_wasm::elements::{deserialize_buffer, Module};
use std::{
borrow::ToOwned,
Expand Down Expand Up @@ -89,8 +89,7 @@ fn crate_metadata(cargo_manifest: &Path) -> Metadata {
cargo_manifest.to_path_buf()
};

let mut crate_metadata_command = create_metadata_command(cargo_manifest);
crate_metadata_command.features(CargoOpt::AllFeatures);
let crate_metadata_command = create_metadata_command(cargo_manifest);

let crate_metadata = crate_metadata_command
.exec()
Expand Down Expand Up @@ -915,6 +914,11 @@ fn generate_rerun_if_changed_instructions(
packages.insert(DeduplicatePackage::from(package));

while let Some(dependency) = dependencies.pop() {
// Ignore all dev dependencies
if dependency.kind == DependencyKind::Development {
continue;
}

let path_or_git_dep =
dependency.source.as_ref().map(|s| s.starts_with("git+")).unwrap_or(true);

Expand Down Expand Up @@ -967,9 +971,7 @@ fn package_rerun_if_changed(package: &DeduplicatePackage) {
p.path() == manifest_path || !p.path().is_dir() || !p.path().join("Cargo.toml").exists()
})
.filter_map(|p| p.ok().map(|p| p.into_path()))
.filter(|p| {
p.is_dir() || p.extension().map(|e| e == "rs" || e == "toml").unwrap_or_default()
})
.filter(|p| p.extension().map(|e| e == "rs" || e == "toml").unwrap_or_default())
.for_each(rerun_if_changed);
}

Expand Down