Skip to content

Commit

Permalink
Merge pull request #1 from gremlin/dynamic-load
Browse files Browse the repository at this point in the history
Dynamically load Windows DLL instead of link
  • Loading branch information
ZachNo authored Jan 23, 2024
2 parents 4f22538 + fe998ce commit c5a2265
Show file tree
Hide file tree
Showing 7 changed files with 587 additions and 151 deletions.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ gat-std = { version = "0.1.1", optional = true }
# This really belongs in [dev-dependencies], but we can't have optional dev-deps
# and this libraries would truncate the min support Rust version (MSRV)
etherparse = { version = "0.13.0", optional = true }
libloading = "0.8"

[target.'cfg(target_os = "windows")'.dependencies]
windows-sys = { version = "0.36.1", features = ["Win32_Foundation", "Win32_Networking_WinSock"] }
once_cell = { version = "1.19", optional = true }

[target.'cfg(not(target_os = "windows"))'.dependencies]
# This really belongs in [dev-dependencies], but we can't have optional dev-deps
Expand All @@ -38,7 +40,7 @@ tempdir = "0.3"
eui48 = "1.1"

[build-dependencies]
libloading = "0.6"
libloading = "0.8"
regex = "1"
pkg-config = "0.3"

Expand All @@ -48,6 +50,7 @@ pkg-config = "0.3"
capture-stream = ["tokio", "futures", "windows-sys/Win32_System_Threading"]
tap-tests = ["tun-tap", "etherparse"]
lending-iter = ["gat-std"]
dynamic-load = ["once_cell"]
# an empty feature to detect if '--all-features' was set
all-features = []

Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ fn get_libpcap_version(libdirpath: Option<PathBuf>) -> Result<Version, Box<dyn s
libfile = libdir.join(libfile);
}

let lib = if let Ok(lib) = libloading::Library::new(libfile) {
let lib = if let Ok(lib) = unsafe { libloading::Library::new(libfile) } {
lib
} else {
return Ok(Version::max());
Expand Down
Loading

0 comments on commit c5a2265

Please sign in to comment.