Skip to content

Commit 947874a

Browse files
committed
Version 0.2.3
- Fix `ar create` on Windows - Clippy fixes
1 parent d76c554 commit 947874a

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "decomp-toolkit"
33
description = "GameCube/Wii decompilation project tools."
44
authors = ["Luke Street <[email protected]>"]
55
license = "MIT OR Apache-2.0"
6-
version = "0.2.2"
6+
version = "0.2.3"
77
edition = "2021"
88
publish = false
99
build = "build.rs"

src/cmd/ar.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,16 @@ fn create(args: CreateArgs) -> Result<()> {
7171
let mut identifiers = Vec::with_capacity(files.len());
7272
let mut symbol_table = BTreeMap::new();
7373
for path in &files {
74-
let file_name = path.file_name().ok_or_else(|| {
75-
Error::msg(format!("'{}' is not a file path", path.to_string_lossy()))
76-
})?;
77-
let file_name = file_name.to_str().ok_or_else(|| {
78-
Error::msg(format!("'{}' is not valid UTF-8", file_name.to_string_lossy()))
74+
let path_str = path.to_str().ok_or_else(|| {
75+
Error::msg(format!("'{}' is not valid UTF-8", path.to_string_lossy()))
7976
})?;
80-
let identifier = file_name.as_bytes().to_vec();
77+
let identifier = path_str.as_bytes().to_vec();
8178
identifiers.push(identifier.clone());
8279

8380
let entries = match symbol_table.entry(identifier) {
8481
Entry::Vacant(e) => e.insert(Vec::new()),
8582
Entry::Occupied(_) => {
86-
return Err(Error::msg(format!("Duplicate file name '{file_name}'")))
83+
return Err(Error::msg(format!("Duplicate file name '{path_str}'")))
8784
}
8885
};
8986
let object_file = File::open(path)
@@ -103,7 +100,11 @@ fn create(args: CreateArgs) -> Result<()> {
103100
let mut builder =
104101
ar::GnuBuilder::new(out, identifiers, ar::GnuSymbolTableFormat::Size32, symbol_table)?;
105102
for path in files {
106-
builder.append_path(path)?;
103+
let path_str = path.to_str().ok_or_else(|| {
104+
Error::msg(format!("'{}' is not valid UTF-8", path.to_string_lossy()))
105+
})?;
106+
let mut file = File::open(&path)?;
107+
builder.append_file(path_str.as_bytes(), &mut file)?;
107108
}
108109
builder.into_inner()?.flush()?;
109110
Ok(())

src/cmd/elf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fn disasm(args: DisasmArgs) -> Result<()> {
9090
let asm_dir = args.out.join("asm");
9191
let include_dir = args.out.join("include");
9292
DirBuilder::new().recursive(true).create(&include_dir)?;
93-
fs::write(&include_dir.join("macros.inc"), include_bytes!("../../assets/macros.inc"))?;
93+
fs::write(include_dir.join("macros.inc"), include_bytes!("../../assets/macros.inc"))?;
9494

9595
for (unit, split_obj) in obj.link_order.iter().zip(&split_objs) {
9696
let out_path = asm_dir.join(file_name_from_unit(unit, ".s"));

src/util/asm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ fn write_symbol_entry<W: Write>(
376376
Ok(())
377377
}
378378

379+
#[allow(clippy::too_many_arguments)]
379380
fn write_data<W: Write>(
380381
w: &mut W,
381382
symbols: &[ObjSymbol],

src/util/elf.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ pub fn process_elf<P: AsRef<Path>>(path: P) -> Result<ObjInfo> {
7878
relocations: vec![],
7979
original_address: 0, // TODO load from abs symbol
8080
file_offset: section.file_range().map(|(v, _)| v).unwrap_or_default(),
81-
section_known: true,
8281
});
8382
}
8483

@@ -119,7 +118,7 @@ pub fn process_elf<P: AsRef<Path>>(path: P) -> Result<ObjInfo> {
119118
match section_starts.entry(file_name.clone()) {
120119
indexmap::map::Entry::Occupied(_) => {
121120
let index = match name_to_index.entry(file_name.clone()) {
122-
hash_map::Entry::Occupied(mut e) => e.into_mut(),
121+
hash_map::Entry::Occupied(e) => e.into_mut(),
123122
hash_map::Entry::Vacant(e) => e.insert(0),
124123
};
125124
*index += 1;

0 commit comments

Comments
 (0)