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:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-10 18:27:53 -04:00
1 parent dc4c1ed0fe
commit c96d39a342
34 files changed
+658 -214

No files matched your search

+12 -8
View File
@@ -22,6 +22,12 @@ pub fn templates(kind: &str) -> io::Result<Vec<PathBuf>> {
Ok(found)
}
/// The kernel's folder beside the app, and in this build.
#[cfg(target_os = "macos")]
const LAYOUT: (&str, &str) = ("../Frameworks", "instdir/LibreOffice.app/Contents/Frameworks");
#[cfg(not(target_os = "macos"))]
const LAYOUT: (&str, &str) = ("libreoffice/program", "instdir/program");
/// The LOK build: `ELY_LOK_DIR`, the app bundle's, or engines/.
pub fn install_dir() -> io::Result<PathBuf> {
if let Ok(dir) = std::env::var("ELY_LOK_DIR") {
@@ -35,17 +41,15 @@ pub fn install_dir() -> io::Result<PathBuf> {
))
};
}
let (beside, built) = LAYOUT;
let library = crate::ffi::KERNEL;
let exe = std::env::current_exe()?;
let bundled = exe
.parent()
.unwrap_or(Path::new("."))
.join("../Frameworks");
if cfg!(target_os = "macos") && bundled.join("libmergedlo.dylib").try_exists()? {
let bundled = exe.parent().unwrap_or(Path::new(".")).join(beside);
if bundled.join(library).try_exists()? {
return Ok(bundled);
}
let dev = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("../../engines/lo-src/instdir/LibreOffice.app/Contents/Frameworks");
if dev.try_exists()? {
let dev = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../../engines/lo-src").join(built);
if dev.join(library).try_exists()? {
return Ok(dev);
}
Err(io::Error::new(
+14 -9
View File
@@ -157,20 +157,20 @@ fn the_worker_round_trips_a_document() {
let source = dir.path().join("note.fodt");
write(&source, FODT);
let url = format!("file://{}", source.display());
let url = crate::file_url(&source);
let doc = worker.load(&url).expect("the document loads");
let (width, height) = doc.size(&mut worker).expect("the size");
assert!(width > 0 || height > 0, "a nonzero document size");
let odt = dir.path().join("note.odt");
doc.save_as(&mut worker, &format!("file://{}", odt.display()), "odt")
doc.save_as(&mut worker, &crate::file_url(&odt), "odt")
.expect("the odt save");
assert!(odt.try_exists().expect("the odt exists"));
let doc2 = worker
.load(&format!("file://{}", odt.display()))
.load(&crate::file_url(&odt))
.expect("the odt reloads");
let pdf = dir.path().join("note.pdf");
doc2.save_as(&mut worker, &format!("file://{}", pdf.display()), "pdf")
doc2.save_as(&mut worker, &crate::file_url(&pdf), "pdf")
.expect("the pdf save");
let head = std::fs::read(&pdf).expect("the pdf reads");
assert!(head.starts_with(b"%PDF"), "a real PDF comes out");
@@ -187,7 +187,7 @@ fn a_missing_file_is_an_error_never_a_success() {
let dir = tempfile::tempdir().expect("a temp dir");
let mut worker = Worker::spawn(&install, &dir.path().join("profile")).expect("the worker");
let missing = dir.path().join("gone.odt");
let outcome = worker.load(&format!("file://{}", missing.display()));
let outcome = worker.load(&crate::file_url(&missing));
assert!(outcome.is_err(), "LOK-09: the failure is an error");
}
@@ -209,7 +209,12 @@ fn a_failed_check_refuses_every_later_request() {
/// Initializes the profile fully, the CLI way (registers Basic).
fn seed_basic(install: &Path, profile: &Path) {
#[cfg(target_os = "macos")]
let soffice = install.parent().expect("the app dir").join("MacOS/soffice");
#[cfg(target_os = "linux")]
let soffice = install.join("soffice.bin");
#[cfg(windows)]
let soffice = install.join("soffice.exe");
let url = ipc::file_url_of(profile);
let status = std::process::Command::new(&soffice)
.args(["--headless", "--norestore", "--terminate_after_init"])
@@ -249,7 +254,7 @@ fn a_macro_never_writes_its_marker() {
let source = dir.path().join("macro.fodt");
std::fs::write(&source, macro_fodt(&marker)).expect("the macro fodt writes");
let doc = worker
.load(&format!("file://{}", source.display()))
.load(&crate::file_url(&source))
.expect("the macro document loads");
std::thread::sleep(std::time::Duration::from_millis(800));
assert!(
@@ -313,7 +318,7 @@ fn shutdown_leaves_no_locks_or_temp() {
let source = dir.path().join("note.fodt");
write(&source, FODT);
let doc = worker
.load(&format!("file://{}", source.display()))
.load(&crate::file_url(&source))
.expect("the document loads");
let lock = dir.path().join(".~lock.note.fodt#");
worker.close_doc(doc).expect("the document closes");
@@ -347,7 +352,7 @@ fn each_load_is_its_own_session() {
let mut worker = Worker::spawn(&install, &dir.path().join("profile")).expect("the worker spawns");
let source = dir.path().join("note.fodt");
write(&source, FODT);
let url = format!("file://{}", source.display());
let url = crate::file_url(&source);
// Freed native documents reuse addresses; sessions never repeat.
let mut old = Vec::new();
for _ in 0..4 {
@@ -375,7 +380,7 @@ fn a_document_belongs_to_its_worker() {
let dir = tempfile::tempdir().expect("a temp dir");
let source = dir.path().join("note.fodt");
write(&source, FODT);
let url = format!("file://{}", source.display());
let url = crate::file_url(&source);
let mut first = Worker::spawn(&install, &dir.path().join("one")).expect("a worker");
let mut second = Worker::spawn(&install, &dir.path().join("two")).expect("another worker");
let theirs = first.load(&url).expect("loads");
+2 -2
View File
@@ -240,7 +240,7 @@ fn a_kernel_dialog_is_closed_and_reported() {
let source = dir.path().join("in.fods");
write(&source, FODS);
let doc = worker
.load(&format!("file://{}", source.display()))
.load(&crate::file_url(&source))
.expect("the sheet loads");
let base = poll_until(&mut worker, &doc, &Events::default(), SETTLE, |_| false);
// Calc's Backspace opens Delete Contents.
@@ -436,7 +436,7 @@ fn an_owned_save_clears_the_modified_state() {
state(seen, ".uno:ModifiedStatus") == Some("true")
});
let copy = dir.path().join("copy.docx");
doc.save_owned(&mut worker, &format!("file://{}", copy.display()), "docx")
doc.save_owned(&mut worker, &crate::file_url(&copy), "docx")
.expect("the owned save");
let saved = poll_until(&mut worker, &doc, &base, SETTLE, |seen| {
state(seen, ".uno:ModifiedStatus") == Some("false")
+3 -2
View File
@@ -12,7 +12,7 @@ fn open() -> (tempfile::TempDir, Worker, Doc, Events) {
let source = dir.path().join("in.fods");
write(&source, FODS);
let doc = worker
.load(&format!("file://{}", source.display()))
.load(&crate::file_url(&source))
.expect("the sheet loads");
let seen = poll_until(&mut worker, &doc, &Events::default(), SETTLE, |seen| {
seen.cell.cursor.is_some()
@@ -29,7 +29,8 @@ fn type_text(worker: &mut Worker, doc: &Doc, text: &str) {
/// The cells of `range`, as the kernel copies them.
fn values(worker: &mut Worker, doc: &Doc, range: &str) -> String {
worker.run(doc, "cell.goto", &[range]).expect("the range");
doc.selection_text(worker).expect("the text")
// Windows ends copied lines with CRLF.
doc.selection_text(worker).expect("the text").replace("\r\n", "\n")
}
#[test]
+6 -6
View File
@@ -24,7 +24,7 @@ pub(super) fn open(body: &str) -> (tempfile::TempDir, Worker, Doc) {
let source = dir.path().join("in.fodt");
write(&source, body);
let doc = worker
.load(&format!("file://{}", source.display()))
.load(&crate::file_url(&source))
.expect("the document loads");
(dir, worker, doc)
}
@@ -32,7 +32,7 @@ pub(super) fn open(body: &str) -> (tempfile::TempDir, Worker, Doc) {
/// The document saved as flat XML.
pub(super) fn saved(dir: &tempfile::TempDir, worker: &mut Worker, doc: &Doc, name: &str) -> String {
let out = dir.path().join(name);
doc.save_as(worker, &format!("file://{}", out.display()), "fodt")
doc.save_as(worker, &crate::file_url(&out), "fodt")
.expect("the save works");
std::fs::read_to_string(&out).expect("the save reads")
}
@@ -210,7 +210,7 @@ fn copy_gives_text_and_html_and_paste_takes_html() {
let target = dir.path().join("b.fodt");
write(&target, FODT);
let other = worker
.load(&format!("file://{}", target.display()))
.load(&crate::file_url(&target))
.expect("b loads");
click(&mut worker, &other, 150, 150);
worker
@@ -312,7 +312,7 @@ fn a_calc_cut_finishes_without_a_dialog() {
let source = root.join("in.fods");
write(&source, FODS);
let doc = worker
.load(&format!("file://{}", source.display()))
.load(&crate::file_url(&source))
.expect("the sheet loads");
worker
.post_key(&doc, 0, 1027 | 0x1000)
@@ -320,7 +320,7 @@ fn a_calc_cut_finishes_without_a_dialog() {
let copied = worker.copy(&doc).expect("copy runs");
worker.cut(&doc).expect("the cut runs");
let out = root.join("out.fods");
doc.save_as(&mut worker, &format!("file://{}", out.display()), "fods")
doc.save_as(&mut worker, &crate::file_url(&out), "fods")
.expect("the save works");
let xml = std::fs::read_to_string(&out).expect("the save reads");
done.send((copied.len(), xml.contains("Hello")))
@@ -367,7 +367,7 @@ fn a_table_survives_copy_and_paste() {
let target = dir.path().join("b.fodt");
write(&target, FODT);
let other = worker
.load(&format!("file://{}", target.display()))
.load(&crate::file_url(&target))
.expect("b loads");
click(&mut worker, &other, 150, 150);
worker
+1 -1
View File
@@ -13,7 +13,7 @@ fn keys_never_wait_behind_the_event_watch() {
let source = dir.path().join("in.fods");
write(&source, FODS);
let doc = worker
.load(&format!("file://{}", source.display()))
.load(&crate::file_url(&source))
.unwrap();
let feed = worker.feed();
let shared = std::sync::Arc::new(std::sync::Mutex::new(worker));
+1 -2
View File
@@ -44,8 +44,7 @@ fn a_locked_document_asks_for_its_password() {
for password in ["", "wrong"] {
let error = worker
.unlock(&url, password)
.err()
.expect("a locked load fails");
.expect_err("a locked load fails");
assert_eq!(
error.kind(),
std::io::ErrorKind::PermissionDenied,
+15 -15
View File
@@ -16,7 +16,7 @@ fn a_tile_paints_real_pixels() {
let source = dir.path().join("note.fodt");
write(&source, FODT);
let doc = worker
.load(&format!("file://{}", source.display()))
.load(&crate::file_url(&source))
.expect("the document loads");
let tile = doc
.paint_tile(&mut worker, (0, 0, 960, 960), (64, 64))
@@ -51,7 +51,7 @@ fn an_edit_bumps_the_generation_and_invalidates() {
let source = dir.path().join("note.fodt");
write(&source, FODT);
let doc = worker
.load(&format!("file://{}", source.display()))
.load(&crate::file_url(&source))
.expect("the document loads");
let base = poll_until(&mut worker, &doc, &Events::default(), QUIET, |_| false);
let before = doc
@@ -95,7 +95,7 @@ fn uno_commands_invalidate_and_repaint() {
let source = dir.path().join("note.fodt");
write(&source, FODT);
let doc = worker
.load(&format!("file://{}", source.display()))
.load(&crate::file_url(&source))
.expect("the document loads");
let base = poll_until(&mut worker, &doc, &Events::default(), QUIET, |_| false);
let before = doc
@@ -137,7 +137,7 @@ fn a_red_span_paints_red_bytes() {
let source = dir.path().join("red.html");
write(&source, RED_HTML);
let doc = worker
.load(&format!("file://{}", source.display()))
.load(&crate::file_url(&source))
.expect("the document loads");
let tile = doc
.paint_tile(&mut worker, (0, 0, 2000, 1000), (64, 64))
@@ -162,12 +162,12 @@ fn a_key_press_edits_the_document() {
let source = dir.path().join("note.fodt");
write(&source, FODT);
let doc = worker
.load(&format!("file://{}", source.display()))
.load(&crate::file_url(&source))
.expect("the document loads");
click(&mut worker, &doc, 150, 150);
worker.post_key(&doc, 0, 1280).expect("Return posts");
let out = dir.path().join("after.fodt");
doc.save_as(&mut worker, &format!("file://{}", out.display()), "fodt")
doc.save_as(&mut worker, &crate::file_url(&out), "fodt")
.expect("the save works");
let before = std::fs::read_to_string(&source).expect("the source reads");
let after = std::fs::read_to_string(&out).expect("the save reads");
@@ -187,7 +187,7 @@ fn selection_only_requests_keep_the_generation() {
let source = dir.path().join("note.fodt");
write(&source, FODT);
let doc = worker
.load(&format!("file://{}", source.display()))
.load(&crate::file_url(&source))
.expect("the document loads");
let base = poll_until(&mut worker, &doc, &Events::default(), QUIET, |_| false);
click(&mut worker, &doc, 150, 150);
@@ -211,7 +211,7 @@ fn bad_tile_geometry_is_an_error_and_the_worker_lives() {
let source = dir.path().join("note.fodt");
write(&source, FODT);
let doc = worker
.load(&format!("file://{}", source.display()))
.load(&crate::file_url(&source))
.expect("the document loads");
for (x, y, w, h, pw, ph) in [
(0, 0, 0, 960, 64, 64),
@@ -243,7 +243,7 @@ fn a_long_wait_is_clamped_and_requests_flow() {
let source = dir.path().join("note.fodt");
write(&source, FODT);
let doc = worker
.load(&format!("file://{}", source.display()))
.load(&crate::file_url(&source))
.expect("the document loads");
let started = std::time::Instant::now();
let batch = worker
@@ -270,7 +270,7 @@ fn polling_times_out_with_the_same_generation() {
let source = dir.path().join("note.fodt");
write(&source, FODT);
let doc = worker
.load(&format!("file://{}", source.display()))
.load(&crate::file_url(&source))
.expect("the document loads");
let base = poll_until(&mut worker, &doc, &Events::default(), QUIET, |_| false);
let again = poll_until(&mut worker, &doc, &base, QUIET, |_| false);
@@ -291,16 +291,16 @@ fn uno_commands_reach_their_own_document() {
write(&first, FODT);
write(&second, FODT);
let a = worker
.load(&format!("file://{}", first.display()))
.load(&crate::file_url(&first))
.expect("a loads");
let b = worker
.load(&format!("file://{}", second.display()))
.load(&crate::file_url(&second))
.expect("b loads");
worker.run(&a, "edit.select_all", &[]).expect("select all");
worker.cut(&a).expect("the cut runs");
let saved = |doc: &Doc, worker: &mut Worker, name: &str| {
let out = dir.path().join(name);
doc.save_as(worker, &format!("file://{}", out.display()), "fodt")
doc.save_as(worker, &crate::file_url(&out), "fodt")
.expect("the save works");
std::fs::read_to_string(&out).expect("the save reads")
};
@@ -327,7 +327,7 @@ fn writer_reports_its_page_rects() {
let source = dir.path().join("note.fodt");
write(&source, FODT);
let doc = worker
.load(&format!("file://{}", source.display()))
.load(&crate::file_url(&source))
.expect("the document loads");
let pages = doc.pages(&mut worker).expect("the page rects");
let (width, height) = doc.size(&mut worker).expect("the size");
@@ -361,7 +361,7 @@ fn the_page_follows_a_dark_theme_and_back() {
let source = dir.path().join(name);
write(&source, text);
let doc = worker
.load(&format!("file://{}", source.display()))
.load(&crate::file_url(&source))
.expect("the document loads");
let area = (1440, 1440, 3840, 3840);
let seen = poll_until(&mut worker, &doc, &Events::default(), QUIET, |_| false);
+11 -5
View File
@@ -154,12 +154,13 @@ fn text_exports_write_the_shown_sheet_as_values() {
let out = dir.path().join("out.csv");
doc.export_text(&mut worker, &crate::file_url(&out), ';')
.expect("exports S1");
let first = std::fs::read_to_string(&out).expect("reads");
// Windows writes CSV lines with CRLF, as RFC 4180 does.
let first = std::fs::read_to_string(&out).expect("reads").replace("\r\n", "\n");
assert_eq!(first, "Name;Total\nSum;3\n", "values, not formulas");
doc.show_sheet(&mut worker, 1).expect("S2");
doc.export_text(&mut worker, &crate::file_url(&out), ';')
.expect("exports S2");
let second = std::fs::read_to_string(&out).expect("reads");
let second = std::fs::read_to_string(&out).expect("reads").replace("\r\n", "\n");
assert_eq!(second, "Item;Note\nPen;\"a;b\"\nInk;2\n", "only S2");
}
@@ -284,11 +285,16 @@ fn excel_caches_recompute_and_unknown_functions_show_errors() {
let end = xml[at..].find("</row>").expect("row one") + at + "</row>".len();
std::fs::write(&sheet, format!("{}{row}{}", &xml[..at], &xml[end..])).expect("writes");
let excel = dir.path().join("excel.xlsx");
let zip = std::process::Command::new("zip")
// Python's zipfile, as ooxml.py uses: no zip on Windows.
let pack = "import os, sys, zipfile
with zipfile.ZipFile(sys.argv[1], 'w', zipfile.ZIP_DEFLATED) as z:
for d, _, fs in os.walk('.'):
for f in fs:
z.write(os.path.join(d, f))";
let zip = std::process::Command::new("python3")
.current_dir(&unpacked)
.args(["-q", "-r"])
.args(["-c", pack])
.arg(&excel)
.arg(".")
.status()
.expect("zip runs");
assert!(zip.success());
+3 -2
View File
@@ -50,7 +50,8 @@ fn open() -> (tempfile::TempDir, Worker, Doc, Events) {
/// The cells of `range`, as the kernel copies them.
fn cells(worker: &mut Worker, doc: &Doc, range: &str) -> String {
worker.run(doc, "cell.goto", &[range]).expect("the range");
doc.selection_text(worker).expect("the text")
// Windows ends copied lines with CRLF.
doc.selection_text(worker).expect("the text").replace("\r\n", "\n")
}
/// The latest report of `name`.
@@ -112,7 +113,7 @@ fn number_formats_alignment_and_fills_apply() {
// The cell properties of the document's own cell formats.
let saved = |worker: &mut Worker| {
let out = _dir.path().join("borders.fods");
doc.save_as(worker, &format!("file://{}", out.display()), "fods")
doc.save_as(worker, &crate::file_url(&out), "fods")
.expect("the save");
let xml = std::fs::read_to_string(&out).expect("the saved book");
let start = xml.find("<office:automatic-styles>").expect("cell formats");
+2 -2
View File
@@ -37,7 +37,7 @@ fn open_sheet() -> (tempfile::TempDir, Worker, Doc) {
let source = dir.path().join("in.fods");
write(&source, FODS);
let doc = worker
.load(&format!("file://{}", source.display()))
.load(&crate::file_url(&source))
.expect("the sheet loads");
(dir, worker, doc)
}
@@ -174,7 +174,7 @@ pub(super) fn open_book(text: &str) -> (tempfile::TempDir, Worker, Doc) {
let source = dir.path().join("book.fods");
write(&source, text);
let doc = worker
.load(&format!("file://{}", source.display()))
.load(&crate::file_url(&source))
.expect("the book loads");
doc.visible_area(&mut worker, (0, 0, 15000, 10000), (256, 3840))
.expect("the area");