Skip to content

Commit

Permalink
Support more targets (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
cions authored Aug 25, 2024
1 parent 1c6d863 commit 34d8599
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ use zerocopy::{AsBytes, FromBytes, FromZeroes};

pub mod apple_codesign;

#[cfg(target_os = "linux")]
#[cfg(all(unix, not(target_vendor = "apple")))]
pub use elf::find_section;
#[cfg(target_os = "macos")]
#[cfg(target_vendor = "apple")]
pub use macho::find_section;
#[cfg(target_os = "windows")]
#[cfg(windows)]
pub use pe::find_section;

#[derive(Debug)]
Expand Down Expand Up @@ -265,7 +265,7 @@ impl<'a> PortableExecutable<'a> {
}
}

#[cfg(target_os = "windows")]
#[cfg(windows)]
mod pe {
use std::ffi::CString;
use windows_sys::Win32::System::LibraryLoader::{
Expand Down Expand Up @@ -659,7 +659,7 @@ impl Macho {
}
}

#[cfg(target_os = "macos")]
#[cfg(target_vendor = "apple")]
mod macho {
use super::SEGNAME;
use std::ffi::CString;
Expand Down Expand Up @@ -737,7 +737,7 @@ impl<'a> Elf<'a> {
}
}

#[cfg(target_os = "linux")]
#[cfg(all(unix, not(target_vendor = "apple")))]
mod elf {
use std::io::Read;
use std::io::Seek;
Expand Down
20 changes: 10 additions & 10 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ fn test_macho(size: usize, sign: bool) {
let macho = Macho::from(input).unwrap();
let _path = std::env::temp_dir().join("exec_mach64_out");
// Remove the file if it exists
#[cfg(target_os = "macos")]
#[cfg(target_vendor = "apple")]
{
let _ = std::fs::remove_file(&_path);
}

let data = vec![0; size];
#[cfg(not(target_os = "macos"))]
#[cfg(not(target_vendor = "apple"))]
let mut out = std::io::sink();
#[cfg(target_os = "macos")]
#[cfg(target_vendor = "apple")]
let mut out = std::fs::OpenOptions::new()
.write(true)
.create(true)
Expand All @@ -73,7 +73,7 @@ fn test_macho(size: usize, sign: bool) {
m.build(&mut out).unwrap();
}

#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
#[cfg(all(target_vendor = "apple", target_arch = "aarch64"))]
if sign {
drop(out);
// Run the output
Expand Down Expand Up @@ -120,9 +120,9 @@ fn test_elf(size: usize) {
let _path = std::env::temp_dir().join("exec_elf64_out");

let data = vec![0; size];
#[cfg(not(target_os = "linux"))]
#[cfg(not(all(unix, not(target_vendor = "apple"))))]
let mut out = std::io::sink();
#[cfg(target_os = "linux")]
#[cfg(all(unix, not(target_vendor = "apple")))]
let mut out = std::fs::OpenOptions::new()
.write(true)
.create(true)
Expand All @@ -132,7 +132,7 @@ fn test_elf(size: usize) {

elf.append(RESOURCE_NAME, &data, &mut out).unwrap();

#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
#[cfg(all(unix, not(target_vendor = "apple"), target_arch = "x86_64"))]
{
drop(out);
// Run the output
Expand All @@ -159,9 +159,9 @@ fn test_pe(size: usize) {
let _path = std::env::temp_dir().join("exec_pe64_out");

let data = vec![0; size];
#[cfg(not(target_os = "windows"))]
#[cfg(not(windows))]
let mut out = std::io::sink();
#[cfg(target_os = "windows")]
#[cfg(windows)]
let mut out = std::fs::OpenOptions::new()
.write(true)
.create(true)
Expand All @@ -172,7 +172,7 @@ fn test_pe(size: usize) {
.build(&mut out)
.unwrap();

#[cfg(target_os = "windows")]
#[cfg(windows)]
{
drop(out);
// Run the output
Expand Down

0 comments on commit 34d8599

Please # to comment.