Skip to content
Draft
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
10 changes: 8 additions & 2 deletions glean-core/glean-sym/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,26 @@ macro_rules! library_binding {
}

impl GleanSym {
#[cfg(unix)]
#[cfg(all(unix, not(target_os = "ios")))]
pub fn load() -> std::io::Result<Self> {
let name = libloading::library_filename("xul");
let library = match unsafe { libloading::Library::new(name) } {
Ok(lib) => Some(lib),
Err(_e) => None,
};
// Try each of the libraries, debug-logging load failures.
let $localname = library.ok_or_else(|| {
std::io::Error::new(std::io::ErrorKind::NotFound, "failed to find glean library")
})?;
Ok(GleanSym { $($load)* _library: $localname })
}

#[cfg(target_os = "ios")]
pub fn load() -> std::io::Result<Self> {
// On iOS we compile it all together and can look up symbols without loading a library
let $localname: libloading::Library = libloading::os::unix::Library::this().into();
Ok(GleanSym { $($load)* _library: $localname })
}

#[cfg(not(unix))]
pub fn load() -> std::io::Result<Self> {
compile_error!("This crate is not implemented for Windows");
Expand Down
Loading