Skip to content

Commit d8c292c

Browse files
Merge pull request #147 from FrameworkComputer/installable
Allow installing with cargo install
2 parents ca1b703 + a087756 commit d8c292c

File tree

13 files changed

+193
-404
lines changed

13 files changed

+193
-404
lines changed

Cargo.lock

+8-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ members = [
1111
"framework_uefi",
1212
# Catchall library that we'll probably want to split up further
1313
"framework_lib",
14-
# Fork of https://github.com/rust-osdev/uefi-rs/blob/main/uefi-macros
15-
# To avoid pulling in UEFI dependencies when building for an OS
16-
"guid_macros",
1714
]
1815

1916
# Don't build UEFI by default. Needs special cargo invocation

README.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,12 @@ make -C framework_uefi
126126
ls -l framework_uefi/build/x86_64-unknown-uefi/boot.efi
127127
```
128128

129-
Building on Windows or in general with fewer features:
129+
## Install local package
130130

131-
```ps1
132-
# Build the library and tool
133-
cargo build
134-
135-
# Running the tool
136-
cargo run
131+
```
132+
> cargo install --path framework_tool
133+
> which framework_tool
134+
/home/zoid/.cargo/bin/framework_tool
137135
```
138136

139137
## Running

framework_lib/Cargo.toml

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
[package]
22
name = "framework_lib"
3-
version = "0.4.1"
3+
version = "0.4.2"
4+
description = "Library to control Framework Computer systems"
5+
homepage = "https://github.com/FrameworkComputer/framework-system"
6+
repository = "https://github.com/FrameworkComputer/framework-system"
7+
readme = "README.md"
8+
license = "BSD-3-Clause"
49
edition = "2021"
510
# Minimum Supported Rust Version
611
# Ubuntu 24.04 LTS ships 1.75
@@ -26,9 +31,9 @@ num-traits = { version = "0.2", default-features = false }
2631
log = { version = "0.4", default-features = true }
2732
spin = { version = "0.9.8" }
2833
no-std-compat = { version = "0.4.1", features = [ "alloc" ] }
29-
guid_macros = { path = "../guid_macros" }
3034
hidapi = { version = "2.6.3", features = [ "windows-native" ], optional = true }
3135
rusb = { version = "0.9.4", optional = true }
36+
guid-create = { git = "https://github.com/FrameworkComputer/guid-create", branch = "no-rand", default-features = false }
3237

3338
[target.'cfg(target_os = "uefi")'.dependencies]
3439
uefi = { version = "0.20", features = ["alloc"] }

framework_lib/src/capsule.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,12 @@
1111
use std::prelude::v1::*;
1212

1313
use core::prelude::rust_2021::derive;
14+
use guid_create::Guid;
1415
#[cfg(not(feature = "uefi"))]
1516
use std::fs::File;
1617
#[cfg(not(feature = "uefi"))]
1718
use std::io::prelude::*;
1819

19-
#[cfg(not(feature = "uefi"))]
20-
use crate::guid::Guid;
21-
#[cfg(feature = "uefi")]
22-
use uefi::Guid;
23-
2420
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
2521
#[repr(C)]
2622
pub struct EfiCapsuleHeader {
@@ -209,14 +205,14 @@ mod tests {
209205
let data = fs::read(capsule_path).unwrap();
210206
let cap = parse_capsule_header(&data).unwrap();
211207
let expected_header = EfiCapsuleHeader {
212-
capsule_guid: esrt::WINUX_GUID,
208+
capsule_guid: Guid::from(esrt::WINUX_GUID),
213209
header_size: 28,
214210
flags: 65536,
215211
capsule_image_size: 676898,
216212
};
217213
assert_eq!(cap, expected_header);
218214

219-
assert_eq!(cap.capsule_guid, esrt::WINUX_GUID);
215+
assert_eq!(cap.capsule_guid, Guid::from(esrt::WINUX_GUID));
220216
let ux_header = parse_ux_header(&data);
221217
assert_eq!(
222218
ux_header,

framework_lib/src/commandline/mod.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use alloc::format;
77
use alloc::string::String;
88
use alloc::string::ToString;
99
use alloc::vec::Vec;
10+
use guid_create::{Guid, GUID};
1011
use log::Level;
1112
use num_traits::FromPrimitive;
1213

@@ -494,7 +495,7 @@ fn print_versions(ec: &CrosEc) {
494495
let mut right_retimer: Option<u32> = None;
495496
if let Some(esrt) = esrt::get_esrt() {
496497
for entry in &esrt.entries {
497-
match entry.fw_class {
498+
match GUID::from(entry.fw_class) {
498499
esrt::TGL_RETIMER01_GUID
499500
| esrt::ADL_RETIMER01_GUID
500501
| esrt::RPL_RETIMER01_GUID
@@ -700,7 +701,7 @@ fn compare_version(device: Option<HardwareDeviceType>, version: String, ec: &Cro
700701

701702
if let Some(esrt) = esrt::get_esrt() {
702703
for entry in &esrt.entries {
703-
match entry.fw_class {
704+
match GUID::from(entry.fw_class) {
704705
esrt::TGL_RETIMER01_GUID | esrt::ADL_RETIMER01_GUID | esrt::RPL_RETIMER01_GUID => {
705706
if device == Some(HardwareDeviceType::RTM01) {
706707
println!("Comparing RTM01 version {:?}", entry.fw_version.to_string());
@@ -1032,7 +1033,7 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
10321033
println!(" Size: {:>20} B", data.len());
10331034
println!(" Size: {:>20} KB", data.len() / 1024);
10341035
if let Some(header) = analyze_capsule(&data) {
1035-
if header.capsule_guid == esrt::WINUX_GUID {
1036+
if header.capsule_guid == Guid::from(esrt::WINUX_GUID) {
10361037
let ux_header = capsule::parse_ux_header(&data);
10371038
if let Some(dump_path) = &args.dump {
10381039
// TODO: Better error handling, rather than just panicking
@@ -1434,7 +1435,7 @@ pub fn analyze_capsule(data: &[u8]) -> Option<capsule::EfiCapsuleHeader> {
14341435
let header = capsule::parse_capsule_header(data)?;
14351436
capsule::print_capsule_header(&header);
14361437

1437-
match header.capsule_guid {
1438+
match GUID::from(header.capsule_guid) {
14381439
esrt::TGL_BIOS_GUID => {
14391440
println!(" Type: Framework TGL Insyde BIOS");
14401441
}

0 commit comments

Comments
 (0)