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

Update crate dependencies to use crates.io #619

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions AdvLoggerPkg/Crates/RustAdvancedLoggerDxe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ path = "src/lib.rs"

[dependencies]
r-efi = { workspace = true }
boot_services = { workspace = true }
mu_uefi_boot_services = { workspace = true }

[dev-dependencies]
boot_services = { workspace = true, features = ["mockall"] }
mu_uefi_boot_services = { workspace = true, features = ["mockall"] }

[features]
std = []
25 changes: 10 additions & 15 deletions AdvLoggerPkg/Crates/RustAdvancedLoggerDxe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,8 @@ impl AdvancedLogger {

// initialize the AdvancedLogger by acquiring a pointer to the AdvancedLogger protocol.
fn init(&self, boot_services_impl: &impl boot_services::BootServices) {
let protocol_ptr = match boot_services_impl.locate_protocol(&ADVANCED_LOGGER_PROTOCOL, None) {
Ok(Some(interface)) => interface as *mut AdvancedLoggerProtocolInterface,
Ok(None) => ptr::null_mut(),
let protocol_ptr = match unsafe { boot_services_impl.locate_protocol(&ADVANCED_LOGGER_PROTOCOL, None) } {
Ok(interface) => interface as *mut AdvancedLoggerProtocolInterface,
Err(_status) => ptr::null_mut(),
};

Expand Down Expand Up @@ -289,12 +288,10 @@ mod tests {
let mut mock_boot_services = boot_services::MockBootServices::new();
mock_boot_services.expect_locate_protocol().returning(|_: &AdvancedLoggerProtocol, registration| unsafe {
assert_eq!(registration, None);
Ok(Some(
(&ADVANCED_LOGGER_INSTANCE as *const AdvancedLoggerProtocolInterface
as *mut AdvancedLoggerProtocolInterface)
.as_mut()
.unwrap(),
))
Ok((&ADVANCED_LOGGER_INSTANCE as *const AdvancedLoggerProtocolInterface
as *mut AdvancedLoggerProtocolInterface)
.as_mut()
.unwrap())
});
static TEST_LOGGER: AdvancedLogger = AdvancedLogger::new();
TEST_LOGGER.init(&mock_boot_services);
Expand All @@ -309,12 +306,10 @@ mod tests {
let mut mock_boot_services = boot_services::MockBootServices::new();
mock_boot_services.expect_locate_protocol().returning(|_: &AdvancedLoggerProtocol, registration| unsafe {
assert_eq!(registration, None);
Ok(Some(
(&ADVANCED_LOGGER_INSTANCE as *const AdvancedLoggerProtocolInterface
as *mut AdvancedLoggerProtocolInterface)
.as_mut()
.unwrap(),
))
Ok((&ADVANCED_LOGGER_INSTANCE as *const AdvancedLoggerProtocolInterface
as *mut AdvancedLoggerProtocolInterface)
.as_mut()
.unwrap())
});
LOGGER.init(&mock_boot_services);

Expand Down
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ members = [

# Add packages that generate libraries here
[workspace.dependencies]
RustAdvancedLoggerDxe = {path = "AdvLoggerPkg/Crates/RustAdvancedLoggerDxe"}
RustBootServicesAllocatorDxe = {path = "MsCorePkg/Crates/RustBootServicesAllocatorDxe"}
HidIo = {path = "HidPkg/Crates/HidIo"}
hidparser = {git = "https://github.com/microsoft/mu_rust_hid.git", branch = "main"}
hidparser = {version = "1"}
HiiKeyboardLayout = {path = "HidPkg/Crates/HiiKeyboardLayout"}
mu_pi = {git = "https://github.com/microsoft/mu_rust_pi.git", tag = "v5.1.0"}
mu_rust_helpers = { git = "https://github.com/microsoft/mu_rust_helpers.git", tag = "v1.2.1" }
boot_services = { git = "https://github.com/microsoft/mu_rust_helpers.git", tag = "v1.2.1" }
mu_pi = {version = "5"}
mu_rust_helpers = { version = "2" }
MuTelemetryHelperLib = {path = "MsWheaPkg/Crates/MuTelemetryHelperLib"}
RustAdvancedLoggerDxe = {path = "AdvLoggerPkg/Crates/RustAdvancedLoggerDxe"}
RustBootServicesAllocatorDxe = {path = "MsCorePkg/Crates/RustBootServicesAllocatorDxe"}
mu_uefi_boot_services = { version = "2" }

memoffset = "0.9.0"
num-traits = { version = "0.2", default-features = false}
Expand Down
4 changes: 2 additions & 2 deletions MsWheaPkg/Crates/MuTelemetryHelperLib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ name = "mu_telemetry_helper_lib"
path = "src/lib.rs"

[dependencies]
boot_services = { workspace = true }
mu_pi = { workspace = true }
mu_rust_helpers = { workspace = true }
r-efi = { workspace = true }
mu_uefi_boot_services = { workspace = true }

[dev-dependencies]
boot_services = { workspace = true, features = ["mockall"] }
mockall = { version = "0.13.0" }
mu_uefi_boot_services = { workspace = true, features = ["mockall"] }

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] }
10 changes: 4 additions & 6 deletions MsWheaPkg/Crates/MuTelemetryHelperLib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,9 @@ mod test {

mock_boot_services.expect_locate_protocol().returning(|_: &StatusCodeRuntimeProtocol, registration| unsafe {
assert_eq!(registration, None);
Ok(Some(
(&MOCK_STATUS_CODE_RUNTIME_INTERFACE as *const status_code::Protocol as *mut status_code::Protocol)
.as_mut()
.unwrap(),
))
Ok((&MOCK_STATUS_CODE_RUNTIME_INTERFACE as *const status_code::Protocol as *mut status_code::Protocol)
.as_mut()
.unwrap())
});

// Test sizes of "repr(C)" structs
Expand Down Expand Up @@ -249,7 +247,7 @@ mod test {
mock_boot_services.expect_locate_protocol().returning(|_: &StatusCodeRuntimeProtocol, registration| {
assert_eq!(registration, None);
//Simulate "marker protocol" without an Interface
Ok(None)
Err(efi::Status::NOT_FOUND)
});
assert_eq!(
Err(efi::Status::NOT_FOUND),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ impl ReportStatusCode for StatusCodeRuntimeProtocol {
data_type: efi::Guid,
data: T,
) -> Result<(), efi::Status> {
let protocol = boot_services.locate_protocol(&StatusCodeRuntimeProtocol, None)?;
if protocol.is_none() {
return Err(efi::Status::NOT_FOUND);
}
let protocol = unsafe { boot_services.locate_protocol(&StatusCodeRuntimeProtocol, None)? };

let header_size = mem::size_of::<EfiStatusCodeData>();
let data_size = mem::size_of::<T>();
Expand All @@ -73,8 +70,7 @@ impl ReportStatusCode for StatusCodeRuntimeProtocol {

let caller_id = caller_id.or(Some(&guid::CALLER_ID)).unwrap();

let status =
(protocol.unwrap().report_status_code)(status_code_type, status_code_value, instance, caller_id, data_ptr);
let status = (protocol.report_status_code)(status_code_type, status_code_value, instance, caller_id, data_ptr);

if status.is_error() {
Err(status)
Expand Down
9 changes: 8 additions & 1 deletion MsWheaPkg/MsWheaPkg.ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,15 @@
"PREVERR",
"malformatted",
"Subcomponent",

],
"AdditionalIncludePaths": [] # Additional paths to spell check relative to package root (wildcards supported)
},

"RustHostUnitTestPlugin": {
"Coverage": .75,
"CoverageOverrides": {
"MuTelemetryHelperLib": 0.7
}
}
}
Loading