Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 3 additions & 3 deletions crates/cargo-wdk/src/actions/build/build_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::path::{Path, PathBuf};

use anyhow::Result;
use mockall_double::double;
use tracing::{debug, info};
use tracing::debug;
use wdk_build::utils::{PathExt, StripExtendedPathPrefixError};

#[double]
Expand Down Expand Up @@ -81,7 +81,7 @@ impl<'a> BuildTask<'a> {
/// * `BuildTaskError::CargoBuild` - If there is an error running the cargo
/// build command
pub fn run(&self) -> Result<(), BuildTaskError> {
info!("Running cargo build for package: {}", self.package_name);
debug!("Running cargo build");
let mut args = vec!["build".to_string()];
args.push("-p".to_string());
args.push(self.package_name.to_string());
Expand All @@ -107,7 +107,7 @@ impl<'a> BuildTask<'a> {
.map(std::string::String::as_str)
.collect::<Vec<&str>>();
self.command_exec.run("cargo", &args, None)?;
debug!("Done");
debug!("cargo build done");
Ok(())
}
}
30 changes: 8 additions & 22 deletions crates/cargo-wdk/src/actions/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ impl<'a> BuildAction<'a> {
Ok(())
}

// Method to initiate the build and package process for the given working
// directory and the cargo metadata
// Runs build for the given working directory and the cargo metadata
fn run_from_workspace_root(&self, working_dir: &Path) -> Result<(), BuildActionError> {
let cargo_metadata = &self.get_cargo_metadata(working_dir)?;
let target_directory = cargo_metadata.target_directory.as_std_path().to_path_buf();
Expand Down Expand Up @@ -344,7 +343,7 @@ impl<'a> BuildAction<'a> {
package_name: &str,
target_dir: &Path,
) -> Result<(), BuildActionError> {
info!("Processing package: {}", package_name);
info!("Building package {package_name}");
BuildTask::new(
package_name,
working_dir,
Expand All @@ -360,20 +359,13 @@ impl<'a> BuildAction<'a> {
debug!("Found wdk metadata in package: {}", package_name);
wdk_metadata
} else {
warn!(
"WDK metadata is not available. Skipping driver build workflow for package: {}",
package_name
);
warn!("Invalid WDK metadata. Skipping package task");
return Ok(());
};

// TODO: Do we need this check anymore?
// Identifying non driver packages
if package.metadata.get("wdk").is_none() {
warn!(
"No package.metadata.wdk section found. Skipping driver build workflow for \
package: {}",
package_name
);
debug!("Packaging task skipped for non-driver package");
return Ok(());
}

Expand All @@ -382,10 +374,7 @@ impl<'a> BuildAction<'a> {
.iter()
.any(|t| t.kind.contains(&TargetKind::CDyLib))
{
warn!(
"No cdylib target found. Skipping driver build workflow for package: {}",
package_name
);
warn!("No cdylib target found. Skipping package task");
return Ok(());
}

Expand All @@ -394,10 +383,7 @@ impl<'a> BuildAction<'a> {
let target_arch = match self.target_arch {
TargetArch::Default(arch) | TargetArch::Selected(arch) => arch,
};
debug!(
"Target architecture for package: {} is: {}",
package_name, target_arch
);
debug!("Target architecture for package: {package_name} is: {target_arch}");
let mut target_dir = target_dir.to_path_buf();
if let TargetArch::Selected(arch) = self.target_arch {
target_dir = target_dir.join(to_target_triple(arch));
Expand Down Expand Up @@ -428,7 +414,7 @@ impl<'a> BuildAction<'a> {
)?
.run()?;

info!("Processing completed for package: {}", package_name);
info!("Finished building {package_name}");
Ok(())
}
}
21 changes: 11 additions & 10 deletions crates/cargo-wdk/src/actions/build/package_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ impl<'a> PackageTask<'a> {
}

fn run_stampinf(&self) -> Result<(), PackageTaskError> {
info!("Running stampinf command.");
info!("Running stampinf");
let wdf_version_flags = match self.driver_model {
DriverConfig::Kmdf(kmdf_config) => {
vec![
Expand Down Expand Up @@ -308,7 +308,7 @@ impl<'a> PackageTask<'a> {
}

fn run_inf2cat(&self) -> Result<(), PackageTaskError> {
info!("Running inf2cat command.");
info!("Running inf2cat");
let args = [
&format!(
"/driver:{}",
Expand All @@ -328,7 +328,7 @@ impl<'a> PackageTask<'a> {
}

fn generate_certificate(&self) -> Result<(), PackageTaskError> {
debug!("Generating certificate.");
debug!("Generating certificate");
if self.fs.exists(&self.src_cert_file_path) {
return Ok(());
}
Expand All @@ -341,7 +341,7 @@ impl<'a> PackageTask<'a> {
}

fn is_self_signed_certificate_in_store(&self) -> Result<bool, PackageTaskError> {
debug!("Checking if self signed certificate exists in WDRTestCertStore store.");
debug!("Checking if self signed certificate exists in WDRTestCertStore store");
let args = ["-s", WDR_TEST_CERT_STORE];

match self.command_exec.run("certmgr.exe", &args, None) {
Expand All @@ -355,7 +355,7 @@ impl<'a> PackageTask<'a> {
}

fn create_self_signed_cert_in_store(&self) -> Result<(), PackageTaskError> {
info!("Creating self signed certificate in WDRTestCertStore store using makecert.");
info!("Creating self signed certificate in WDRTestCertStore store using makecert");
let cert_path = self.src_cert_file_path.to_string_lossy();
let args = [
"-r",
Expand All @@ -377,7 +377,7 @@ impl<'a> PackageTask<'a> {
}

fn create_cert_file_from_store(&self) -> Result<(), PackageTaskError> {
info!("Creating certificate file from WDRTestCertStore store using certmgr.");
info!("Creating certificate file from WDRTestCertStore store using certmgr");
let cert_path = self.src_cert_file_path.to_string_lossy();
let args = [
"-put",
Expand Down Expand Up @@ -410,7 +410,7 @@ impl<'a> PackageTask<'a> {
cert_name: &str,
) -> Result<(), PackageTaskError> {
info!(
"Signing {} using signtool.",
"Signing {} using signtool",
file_path
.file_name()
.expect("Unable to read file name from the path")
Expand Down Expand Up @@ -438,7 +438,7 @@ impl<'a> PackageTask<'a> {

fn run_signtool_verify(&self, file_path: &Path) -> Result<(), PackageTaskError> {
info!(
"Verifying {} using signtool.",
"Verifying {} using signtool",
file_path
.file_name()
.expect("Unable to read file name from the path")
Expand All @@ -455,21 +455,22 @@ impl<'a> PackageTask<'a> {
}

fn run_infverif(&self) -> Result<(), PackageTaskError> {
info!("Running infverif command.");
info!("Running infverif");
let additional_args = if self.sample_class {
let wdk_build_number = self.wdk_build.detect_wdk_build_number()?;
if MISSING_SAMPLE_FLAG_WDK_BUILD_NUMBER_RANGE.contains(&wdk_build_number) {
debug!(
"InfVerif in WDK Build {wdk_build_number} is bugged and does not contain the \
/samples flag."
);
info!("Skipping InfVerif for samples class. WDK Build: {wdk_build_number}");
info!("InfVerif skipped for samples class. WDK Build: {wdk_build_number}");
return Ok(());
}
"/msft"
} else {
""
};

let mut args = vec![
"/v",
match self.driver_model {
Expand Down
24 changes: 10 additions & 14 deletions crates/cargo-wdk/tests/build_command_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ fn mixed_package_kmdf_workspace_builds_successfully() {
with_file_lock(|| {
let stdout = run_build_cmd("tests/mixed-package-kmdf-workspace");

assert!(stdout.contains("Processing completed for package: driver"));
assert!(stdout.contains(
"No package.metadata.wdk section found. Skipping driver build workflow for package: \
non_driver_crate"
));

assert!(stdout.contains("Building package driver"));
assert!(stdout.contains("Building package non_driver_crate"));
assert!(stdout.contains("Packaging task skipped for non-driver package"));
assert!(stdout.contains("Build completed successfully"));
verify_driver_package_files("tests/mixed-package-kmdf-workspace", "driver", "sys");
});
}
Expand Down Expand Up @@ -77,16 +75,13 @@ fn emulated_workspace_builds_successfully() {
let emulated_workspace_path = "tests/emulated-workspace";
let stdout = run_build_cmd(emulated_workspace_path);

assert!(stdout.contains("Building package driver_1"));
assert!(stdout.contains("Building package driver_2"));
// Matches warning about WDK metadata not being available for non driver project
// but a valid rust project
assert!(stdout.contains(
"WDK metadata is not available. Skipping driver build workflow for package: \
rust-project"
));
assert!(stdout.contains("Invalid WDK metadata. Skipping package task"));

assert!(stdout.contains("Processing completed for package: driver_1"));
assert!(stdout.contains("Processing completed for package: driver_2"));
assert!(stdout.contains(r"Build completed successfully"));
assert!(stdout.contains("Build completed successfully"));

let umdf_driver_workspace_path = format!("{emulated_workspace_path}/umdf-driver-workspace");
verify_driver_package_files(&umdf_driver_workspace_path, "driver_1", "dll");
Expand All @@ -100,7 +95,8 @@ fn build_driver_project(driver_type: &str) {

let stdout = run_build_cmd(&driver_path);

assert!(stdout.contains(&format!("Processing completed for package: {driver_name}")));
assert!(stdout.contains(&format!("Building package {driver_name}")));
assert!(stdout.contains("Build completed successfully"));

let driver_binary_extension = match driver_type {
"kmdf" | "wdm" => "sys",
Expand Down