LOK runs on Windows and Linux; packaging stages engines (W-01, K-01)
The kernel is the merged library on every platform; Windows and Linux find it beside the app in libreoffice/program. All three run unipoll: macOS through GCD, Linux by answering one request per poll, Windows through a message-only window on the loop's thread (LOK's own main thread had deadlocked Calc loads). Patch 0043 flushes callbacks inline everywhere, so a request sees its result; 0042 stops MSVC's Boost auto-link. Linux paints with cairo, BGRA; the start-up check now paints red text and finds red in byte two on every platform, since getTileMode does not see Skia. ely-lok on Windows: 180 of 189 pass; on Linux 187. The rest are listed after 0.1.3 (spelling, Calc dark tiles, show layers and fields, a11y selection). Tests build file URLs portably and accept CRLF where Windows writes it. packaging/stage.sh lays out an app with its engines for Windows and Linux; licenses.sh finds each licence on all three. ElyMark finds its page beside the app. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
dc4c1ed0fe
commit
c96d39a342
34 files changed
+658
-214
No files matched your search
+46
-73
@@ -185,7 +185,6 @@ impl Lok {
|
||||
call!(class, 10, F, self.kit, url_c.as_ptr())
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
/// Answers the kernel's "input waiting?" without a run-loop peek.
|
||||
pub fn register_any_input(&self, waiting: extern "C" fn(*mut c_void, i32) -> bool) {
|
||||
static DATA: u8 = 0;
|
||||
@@ -196,29 +195,30 @@ impl Lok {
|
||||
call!(class, 24, F, self.kit, waiting, data);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
/// Runs LOK's loop until kit exit (R-01).
|
||||
pub fn run_loop(&self) {
|
||||
type PollCb = Option<extern "C" fn(*mut c_void, i32) -> i32>;
|
||||
type WakeCb = Option<extern "C" fn(*mut c_void)>;
|
||||
extern "C" fn poll(_: *mut c_void, _: i32) -> i32 {
|
||||
0
|
||||
}
|
||||
extern "C" fn wake(_: *mut c_void) {}
|
||||
/// Runs LOK's loop until kit exit; unipoll calls `poll`.
|
||||
pub fn run_loop(&self, poll: Option<Poll>, wake: Option<Wake>) {
|
||||
// VCL calls neither hook while their data is null.
|
||||
static DATA: u8 = 0;
|
||||
let data = std::ptr::addr_of!(DATA).cast_mut().cast();
|
||||
let class = unsafe { (*self.kit).class };
|
||||
type F = unsafe extern "C" fn(*mut Kit, PollCb, WakeCb, *mut c_void);
|
||||
call!(
|
||||
class,
|
||||
12,
|
||||
F,
|
||||
self.kit,
|
||||
Some(poll),
|
||||
Some(wake),
|
||||
std::ptr::null_mut()
|
||||
);
|
||||
type F = unsafe extern "C" fn(*mut Kit, Option<Poll>, Option<Wake>, *mut c_void);
|
||||
call!(class, 12, F, self.kit, poll, wake, data);
|
||||
}
|
||||
}
|
||||
|
||||
/// The kernel library: every build here merges its libraries.
|
||||
#[cfg(target_os = "macos")]
|
||||
pub const KERNEL: &str = "libmergedlo.dylib";
|
||||
#[cfg(target_os = "linux")]
|
||||
pub const KERNEL: &str = "libmergedlo.so";
|
||||
#[cfg(windows)]
|
||||
pub const KERNEL: &str = "mergedlo.dll";
|
||||
|
||||
/// Waits up to its microseconds; above zero, work was done.
|
||||
pub type Poll = extern "C" fn(*mut c_void, i32) -> i32;
|
||||
/// The kernel has work for its loop.
|
||||
pub type Wake = extern "C" fn(*mut c_void);
|
||||
|
||||
impl Drop for Lok {
|
||||
fn drop(&mut self) {
|
||||
if self.kit.is_null() {
|
||||
@@ -244,37 +244,17 @@ struct Library {
|
||||
|
||||
#[cfg(unix)]
|
||||
impl Library {
|
||||
/// dlopens the LOK library, merged candidates in order.
|
||||
/// dlopens the merged kernel from `install`.
|
||||
fn open(install: &Path) -> io::Result<Self> {
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
let mut last = "no candidate".to_string();
|
||||
for name in [
|
||||
"libsofficeapp.dylib",
|
||||
"libmergedlo.dylib",
|
||||
"libsofficeapp.so",
|
||||
"libmergedlo.so",
|
||||
] {
|
||||
let path = install.join(name);
|
||||
if !path.try_exists()? {
|
||||
continue;
|
||||
}
|
||||
let c = CString::new(path.as_os_str().as_bytes())
|
||||
.map_err(|_| io::Error::new(io::ErrorKind::InvalidInput, "the path holds a NUL"))?;
|
||||
let handle = unsafe { libc::dlopen(c.as_ptr(), libc::RTLD_LAZY | libc::RTLD_GLOBAL) };
|
||||
if handle.is_null() {
|
||||
last = dl_error();
|
||||
log::warn!("lok: dlopen {} failed: {last}", path.display());
|
||||
continue;
|
||||
}
|
||||
return Ok(Self { handle });
|
||||
let path = install.join(KERNEL);
|
||||
let c = CString::new(path.as_os_str().as_bytes())
|
||||
.map_err(|_| io::Error::new(io::ErrorKind::InvalidInput, "the path holds a NUL"))?;
|
||||
let handle = unsafe { libc::dlopen(c.as_ptr(), libc::RTLD_LAZY | libc::RTLD_GLOBAL) };
|
||||
if handle.is_null() {
|
||||
return Err(io::Error::other(format!("dlopen {}: {}", path.display(), dl_error())));
|
||||
}
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::NotFound,
|
||||
format!(
|
||||
"no loadable LOK library under {}: {last}",
|
||||
install.display()
|
||||
),
|
||||
))
|
||||
Ok(Self { handle })
|
||||
}
|
||||
|
||||
/// dlsyms `name` from the library.
|
||||
@@ -308,36 +288,29 @@ struct Library {
|
||||
|
||||
#[cfg(windows)]
|
||||
impl Library {
|
||||
/// Loads `<install>/sofficeapp.dll`, merged fallback.
|
||||
/// Loads the merged kernel from `install`.
|
||||
fn open(install: &Path) -> io::Result<Self> {
|
||||
use std::os::windows::ffi::OsStrExt;
|
||||
use windows_sys::Win32::System::LibraryLoader::{
|
||||
LOAD_LIBRARY_SEARCH_DEFAULT_DIRS, LoadLibraryExW,
|
||||
LOAD_LIBRARY_SEARCH_DEFAULT_DIRS, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR, LoadLibraryExW,
|
||||
};
|
||||
for name in ["sofficeapp.dll", "mergedlo.dll"] {
|
||||
let path = install.join(name);
|
||||
if !path.try_exists()? {
|
||||
continue;
|
||||
}
|
||||
let wide: Vec<u16> = path.as_os_str().encode_wide().chain(Some(0)).collect();
|
||||
let handle = unsafe {
|
||||
LoadLibraryExW(
|
||||
wide.as_ptr(),
|
||||
std::ptr::null_mut(),
|
||||
LOAD_LIBRARY_SEARCH_DEFAULT_DIRS,
|
||||
)
|
||||
};
|
||||
if handle.is_null() {
|
||||
return Err(io::Error::last_os_error());
|
||||
}
|
||||
return Ok(Self {
|
||||
handle: handle as isize,
|
||||
});
|
||||
let path = install.join(KERNEL);
|
||||
let wide: Vec<u16> = path.as_os_str().encode_wide().chain(Some(0)).collect();
|
||||
let handle = unsafe {
|
||||
LoadLibraryExW(
|
||||
wide.as_ptr(),
|
||||
std::ptr::null_mut(),
|
||||
// Its dependencies sit beside it, in program/.
|
||||
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS,
|
||||
)
|
||||
};
|
||||
if handle.is_null() {
|
||||
let error = io::Error::last_os_error();
|
||||
return Err(io::Error::other(format!("LoadLibrary {}: {error}", path.display())));
|
||||
}
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::NotFound,
|
||||
format!("no LOK library under {}", install.display()),
|
||||
))
|
||||
Ok(Self {
|
||||
handle: handle as isize,
|
||||
})
|
||||
}
|
||||
|
||||
/// Gets `name` from the library.
|
||||
|
||||
Reference in new issue
Block a user