@unieai/libreoffice-kit-wasm 0.0.0-stage → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +7 -2
  2. package/assets/dsoffice.cjs +26 -0
  3. package/assets/dsoffice.data +0 -0
  4. package/assets/dsoffice.data.js.metadata +1 -0
  5. package/assets/dsoffice.wasm +4 -0
  6. package/assets/manifest.json +1888 -0
  7. package/licenses/LICENSE +4666 -0
  8. package/licenses/NOTICE +63 -0
  9. package/licenses/Rabi-Harness-MIT.txt +28 -0
  10. package/package.json +22 -4
  11. package/prebuilds.json +128 -0
  12. package/sources/build-autogen.input +35 -0
  13. package/sources/core-source.json +4 -0
  14. package/sources/docs/ui-resources.md +123 -0
  15. package/sources/engine/build-identity.mjs +49 -0
  16. package/sources/engine/core-source.mjs +27 -0
  17. package/sources/engine/document-operations.hxx +51 -0
  18. package/sources/engine/ui-resource-policy.mjs +33 -0
  19. package/sources/engine/wasm-source/autogen.input +33 -0
  20. package/sources/engine/wasm-source/build.mjs +300 -0
  21. package/sources/engine/wasm-source/lok.cxx +428 -0
  22. package/sources/engine/wasm-source/patches/0001-macos-build-tools.patch +87 -0
  23. package/sources/engine/wasm-source/patches/0002-system-font-demand.patch +322 -0
  24. package/sources/engine/wasm-source/patches/0003-node-runtime.patch +99 -0
  25. package/sources/engine/wasm-source/patches/0004-system-fonts-only.patch +10 -0
  26. package/sources/engine/wasm-source/patches/0005-cross-build-rules.patch +46 -0
  27. package/sources/engine/wasm-source/patches/0006-wasm-external-platforms.patch +55 -0
  28. package/sources/engine/wasm-source/patches/0008-disable-link-updates.patch +30 -0
  29. package/sources/engine/wasm-source/patches/0009-disable-optional-curl.patch +11 -0
  30. package/sources/engine/wasm-source/patches/0010-refresh-component-registry.patch +11 -0
  31. package/sources/engine/wasm-source/patches/0011-preserve-optimization-with-prefix-maps.patch +21 -0
  32. package/sources/engine/wasm-source/patches/0012-anonymize-explicit-source-paths.patch +39 -0
  33. package/sources/engine/wasm-source/patches/0023-pdfium-for-embedded-graphics.patch +14 -0
  34. package/sources/engine/wasm-source/patches/0024-pdfium-emscripten-platform.patch +11 -0
  35. package/sources/engine/wasm-source/patches/0025-browser-editing.patch +18 -0
  36. package/sources/engine/wasm-source/patches/0028-synchronous-workbook-calculation.patch +64 -0
  37. package/sources/engine/wasm-source/patches/0029-unloaded-external-blip.patch +21 -0
  38. package/sources/engine/wasm-source/patches/0030-no-password-strength-ui.patch +117 -0
  39. package/sources/engine/wasm-source/patches/0031-size-optimization-lto.patch +26 -0
  40. package/sources/engine/wasm-source/patches/0047-defer-offscreen-canvas-output.patch +59 -0
  41. package/sources/engine/wasm-source/slim.mjs +74 -0
  42. package/sources/engine/wasm-source/source.json +16 -0
  43. package/sources/engine/wasm-source/source.mjs +12 -0
  44. package/sources/engine/wasm-source/stage.mjs +91 -0
  45. package/sources/scripts/checkout-wasm.mjs +24 -0
  46. package/sources/scripts/core-checkout.mjs +39 -0
  47. package/sources/scripts/minimize-ui-resources.py +198 -0
  48. package/sources/scripts/pack-utils.mjs +69 -0
  49. package/sources/scripts/platform-matrix.mjs +122 -0
  50. package/sources/scripts/verify-artifacts.mjs +261 -0
  51. package/sources/source-changes.patch +1081 -0
@@ -0,0 +1,428 @@
1
+ // The browser Worker owns one LibreOfficeKit instance and serializes all calls.
2
+ // Pointers remain inside that worker's WebAssembly memory.
3
+
4
+ #include "rabi_document_operations.hxx"
5
+
6
+ #include <cstdlib>
7
+ #include <cstdio>
8
+ #include <cstring>
9
+ #include <exception>
10
+ #include <emscripten.h>
11
+ #include <cmath>
12
+ #include <limits>
13
+ #include <memory>
14
+ #include <stdexcept>
15
+ #include <vector>
16
+ #include <basegfx/vector/b2dsize.hxx>
17
+ #include <vcl/filter/PDFiumLibrary.hxx>
18
+ #include <vcl/pdf/PDFBitmapType.hxx>
19
+
20
+ extern "C" LibreOfficeKit* libreofficekit_hook_2(const char*, const char*);
21
+ extern "C" bool rabi_lok_yield();
22
+
23
+ EM_JS(void, rabi_lok_callback, (int type, const char* payload), {
24
+ if (Module['rabiOnCallback']) Module['rabiOnCallback'](type, payload ? UTF8ToString(payload) : '');
25
+ });
26
+
27
+ namespace {
28
+
29
+ // Exception diagnostics remain available even when a LOK instance could not be
30
+ // created. The fixed buffer also records allocation failures without allocating.
31
+ char lastError[4096] = {};
32
+
33
+ // PDFium retains the original input and its library for the document lifetime.
34
+ struct PdfDocument {
35
+ std::vector<unsigned char> bytes;
36
+ std::shared_ptr<vcl::pdf::PDFium> library;
37
+ std::unique_ptr<vcl::pdf::PDFiumDocument> document;
38
+ };
39
+
40
+ int checkedTwips(double points)
41
+ {
42
+ const double twips = std::round(points * 20.0);
43
+ if (!std::isfinite(twips) || twips < 1 || twips > std::numeric_limits<int>::max())
44
+ throw std::runtime_error("PDF page dimensions exceed the supported coordinate range");
45
+ return static_cast<int>(twips);
46
+ }
47
+
48
+ basegfx::B2DSize pdfPageSize(PdfDocument* pdf, int page)
49
+ {
50
+ if (!pdf || !pdf->document || page < 0 || page >= pdf->document->getPageCount())
51
+ throw std::runtime_error("PDF page index is outside the document");
52
+ return pdf->document->getPageSize(page);
53
+ }
54
+
55
+ void editorCallback(int type, const char* payload, void*)
56
+ {
57
+ rabi_lok_callback(type, payload);
58
+ }
59
+
60
+ template <typename Result, typename Function>
61
+ Result guarded(Function function, Result failure) noexcept
62
+ {
63
+ lastError[0] = '\0';
64
+ try {
65
+ return function();
66
+ } catch (const std::exception& error) {
67
+ std::snprintf(lastError, sizeof(lastError), "%s", error.what());
68
+ } catch (...) {
69
+ std::snprintf(lastError, sizeof(lastError), "%s", "LibreOfficeKit raised an unknown C++ exception");
70
+ }
71
+ return failure;
72
+ }
73
+
74
+ char* copyLastError() noexcept
75
+ {
76
+ const auto length = std::strlen(lastError) + 1;
77
+ auto* result = static_cast<char*>(std::malloc(length));
78
+ if (result != nullptr) std::memcpy(result, lastError, length);
79
+ return result;
80
+ }
81
+
82
+ }
83
+
84
+ extern "C" {
85
+
86
+ /**
87
+ * Initializes the module's single office instance after its filesystem is loaded.
88
+ * installPath names the virtual program directory; profileUrl is a file URL.
89
+ * Returns null when initialization fails. The caller must not initialize twice.
90
+ */
91
+ LibreOfficeKit* rabi_lok_initialize(const char* installPath, const char* profileUrl)
92
+ {
93
+ return guarded([&] {
94
+ // The owning Worker drives nonblocking event slices for editing sessions.
95
+ ::setenv("SAL_LOK_OPTIONS", "unipoll", 1);
96
+ auto* office = libreofficekit_hook_2(installPath, profileUrl);
97
+ if (office != nullptr)
98
+ office->pClass->setOptionalFeatures(office, LOK_FEATURE_PART_IN_INVALIDATION_CALLBACK);
99
+ return office;
100
+ }, static_cast<LibreOfficeKit*>(nullptr));
101
+ }
102
+
103
+ /** Loads a virtual file URL with LOK options; returns null on load failure. */
104
+ LibreOfficeKitDocument* rabi_lok_document_load(LibreOfficeKit* office, const char* url,
105
+ const char* options)
106
+ {
107
+ return guarded([&] {
108
+ return office->pClass->documentLoadWithOptions(office, url, options);
109
+ }, static_cast<LibreOfficeKitDocument*>(nullptr));
110
+ }
111
+
112
+ /** Writes PDF to a virtual file URL; returns nonzero only when LOK reports success. */
113
+ int rabi_lok_document_save_pdf(LibreOfficeKitDocument* document, const char* url,
114
+ const char* filterOptions)
115
+ {
116
+ return guarded([&] {
117
+ return document->pClass->saveAs(document, url, "pdf", filterOptions);
118
+ }, 0);
119
+ }
120
+
121
+ /** Export an editable snapshot in its original Office format. */
122
+ int rabi_lok_document_save(LibreOfficeKitDocument* document, const char* url, const char* format)
123
+ {
124
+ return guarded([&] { return document->pClass->saveAs(document, url, format, "TakeOwnership"); }, 0);
125
+ }
126
+
127
+ /** Register the single owning Worker's document notifications. */
128
+ int rabi_lok_document_listen(LibreOfficeKitDocument* document)
129
+ {
130
+ return guarded([&] { document->pClass->registerCallback(document, editorCallback, nullptr); return 1; }, 0);
131
+ }
132
+
133
+ /** Process pending VCL events and timers without blocking the Worker message loop. */
134
+ int rabi_lok_pump()
135
+ {
136
+ return guarded([&] { return rabi_lok_yield() ? 1 : 0; }, -1);
137
+ }
138
+
139
+ int rabi_lok_document_key(LibreOfficeKitDocument* document, int type, int character, int key)
140
+ {
141
+ return guarded([&] { document->pClass->postKeyEvent(document, type, character, key); return 1; }, 0);
142
+ }
143
+
144
+ int rabi_lok_document_mouse(LibreOfficeKitDocument* document, int type, int x, int y,
145
+ int count, int buttons, int modifiers)
146
+ {
147
+ return guarded([&] { document->pClass->postMouseEvent(document, type, x, y, count, buttons, modifiers); return 1; }, 0);
148
+ }
149
+
150
+ int rabi_lok_document_composition(LibreOfficeKitDocument* document, int type, const char* text)
151
+ {
152
+ return guarded([&] { document->pClass->postWindowExtTextInputEvent(document, 0, type, text); return 1; }, 0);
153
+ }
154
+
155
+ int rabi_lok_document_command(LibreOfficeKitDocument* document, const char* command, const char* arguments)
156
+ {
157
+ return guarded([&] { document->pClass->postUnoCommand(document, command, arguments, true); return 1; }, 0);
158
+ }
159
+
160
+ char* rabi_lok_document_command_values(LibreOfficeKitDocument* document, const char* command)
161
+ {
162
+ return guarded([&] { return document->pClass->getCommandValues(document, command); }, static_cast<char*>(nullptr));
163
+ }
164
+
165
+ int rabi_lok_document_paste(LibreOfficeKitDocument* document, const char* mime, const char* text, int size)
166
+ {
167
+ return guarded([&] { return document->pClass->paste(document, mime, text, size); }, false) ? 1 : 0;
168
+ }
169
+
170
+ char* rabi_lok_document_selection(LibreOfficeKitDocument* document)
171
+ {
172
+ return guarded([&] { return document->pClass->getTextSelection(document, "text/plain;charset=utf-8", nullptr); }, static_cast<char*>(nullptr));
173
+ }
174
+
175
+ int rabi_lok_document_part(LibreOfficeKitDocument* document, int part)
176
+ {
177
+ return guarded([&] { document->pClass->setPart(document, part); return 1; }, 0);
178
+ }
179
+
180
+ char* rabi_lok_document_part_name(LibreOfficeKitDocument* document, int part)
181
+ {
182
+ return guarded([&] { return document->pClass->getPartName(document, part); }, static_cast<char*>(nullptr));
183
+ }
184
+
185
+ int rabi_lok_document_viewport(LibreOfficeKitDocument* document, int pixels, int twips,
186
+ int x, int y, int width, int height)
187
+ {
188
+ return guarded([&] {
189
+ document->pClass->setClientZoom(document, pixels, pixels, twips, twips);
190
+ document->pClass->setClientVisibleArea(document, x, y, width, height);
191
+ return 1;
192
+ }, 0);
193
+ }
194
+
195
+ /** Part metadata includes Calc's actual data area, visibility, and RTL layout. */
196
+ char* rabi_lok_document_part_info(LibreOfficeKitDocument* document, int part)
197
+ {
198
+ return guarded([&] { return document->pClass->getPartInfo(document, part); }, static_cast<char*>(nullptr));
199
+ }
200
+
201
+ /** A capture view is separate from the user's active edit/IME view. */
202
+ int rabi_lok_document_create_view(LibreOfficeKitDocument* document)
203
+ {
204
+ return guarded([&] {
205
+ const int view = document->pClass->createView(document);
206
+ if (view >= 0) document->pClass->setViewReadOnly(document, view, true);
207
+ return view;
208
+ }, -1);
209
+ }
210
+
211
+ int rabi_lok_document_get_view(LibreOfficeKitDocument* document)
212
+ {
213
+ return guarded([&] { return document->pClass->getView(document); }, -1);
214
+ }
215
+
216
+ int rabi_lok_document_set_view(LibreOfficeKitDocument* document, int view)
217
+ {
218
+ return guarded([&] {
219
+ if (view < 0) throw std::runtime_error("Invalid document view");
220
+ document->pClass->setView(document, view);
221
+ return document->pClass->getView(document) == view ? 1 : 0;
222
+ }, 0);
223
+ }
224
+
225
+ int rabi_lok_document_destroy_view(LibreOfficeKitDocument* document, int view)
226
+ {
227
+ return guarded([&] {
228
+ if (view < 0) throw std::runtime_error("Invalid document view");
229
+ document->pClass->destroyView(document, view);
230
+ return 1;
231
+ }, 0);
232
+ }
233
+
234
+ /** Initializes read-only Writer pages or normal Impress slides for tiled rendering. */
235
+ int rabi_lok_document_initialize_rendering(LibreOfficeKitDocument* document)
236
+ {
237
+ return guarded([&] {
238
+ document->pClass->initializeForRendering(document, "{\".uno:ShowBorderShadow\":{\"type\":\"boolean\",\"value\":\"false\"}}");
239
+ if (document->pClass->getDocumentType(document) == LOK_DOCTYPE_PRESENTATION)
240
+ document->pClass->setPartMode(document, LOK_PARTMODE_SLIDES);
241
+ return 1;
242
+ }, 0);
243
+ }
244
+
245
+ /** Returns a LibreOfficeKitDocumentType, or -1 when the query throws. */
246
+ int rabi_lok_document_type(LibreOfficeKitDocument* document)
247
+ {
248
+ return guarded([&] { return document->pClass->getDocumentType(document); }, -1);
249
+ }
250
+
251
+ /** Returns the number of Impress slides, or -1 when the query throws. */
252
+ int rabi_lok_document_parts(LibreOfficeKitDocument* document)
253
+ {
254
+ return guarded([&] { return document->pClass->getParts(document); }, -1);
255
+ }
256
+
257
+ /** Returns owned Writer page rectangles in twips; free with the exported free function. */
258
+ char* rabi_lok_document_page_rectangles(LibreOfficeKitDocument* document)
259
+ {
260
+ return guarded([&] { return document->pClass->getPartPageRectangles(document); }, static_cast<char*>(nullptr));
261
+ }
262
+
263
+ /** Writes the selected slide's twip dimensions into two wasm32 longs. */
264
+ int rabi_lok_document_size(LibreOfficeKitDocument* document, int part, long* width, long* height)
265
+ {
266
+ return guarded([&] {
267
+ // Writer's part setter navigates to a page and moves its selection.
268
+ // Measuring the retained reading view must have no navigation effects.
269
+ if (document->pClass->getDocumentType(document) != LOK_DOCTYPE_TEXT)
270
+ document->pClass->setPart(document, part);
271
+ document->pClass->getDocumentSize(document, width, height);
272
+ return 1;
273
+ }, 0);
274
+ }
275
+
276
+ /** Returns the LibreOfficeKitTileMode, or -1 when the query throws. */
277
+ int rabi_lok_document_tile_mode(LibreOfficeKitDocument* document)
278
+ {
279
+ return guarded([&] { return document->pClass->getTileMode(document); }, -1);
280
+ }
281
+
282
+ /** Paints twip coordinates into a premultiplied RGBA/BGRA buffer; part -1 selects Writer. */
283
+ int rabi_lok_document_paint(LibreOfficeKitDocument* document, unsigned char* buffer, int part,
284
+ int canvasWidth, int canvasHeight, int x, int y, int width, int height)
285
+ {
286
+ return guarded([&] {
287
+ if (part < 0)
288
+ document->pClass->paintTile(document, buffer, canvasWidth, canvasHeight, x, y, width, height);
289
+ else
290
+ document->pClass->paintPartTile(document, buffer, part, LOK_PARTMODE_SLIDES,
291
+ canvasWidth, canvasHeight, x, y, width, height);
292
+ return 1;
293
+ }, 0);
294
+ }
295
+
296
+ /** Export any supported format after synchronous calculation and CSV selection. */
297
+ int rabi_lok_document_export(LibreOfficeKit* office, LibreOfficeKitDocument* document,
298
+ const char* url, const char* format, const char* filterOptions, int calculate, const char* sheet)
299
+ {
300
+ return guarded([&] {
301
+ if (calculate) rabi::recalculate(office, document);
302
+ if (std::strcmp(format, "csv") == 0) rabi::selectCsvSheet(office, document, sheet && sheet[0] ? sheet : nullptr);
303
+ return document->pClass->saveAs(document, url, format, filterOptions);
304
+ }, 0);
305
+ }
306
+
307
+ /** Open PDF directly in PDFium; never import it as an editable Draw document. */
308
+ PdfDocument* rabi_pdf_open(const unsigned char* bytes, int length, const char* password)
309
+ {
310
+ return guarded([&] {
311
+ if (!bytes || length < 5 || std::memcmp(bytes, "%PDF-", 5) != 0)
312
+ throw std::runtime_error("Input does not contain a PDF header");
313
+ auto pdf = std::make_unique<PdfDocument>();
314
+ pdf->bytes.assign(bytes, bytes + length);
315
+ pdf->library = vcl::pdf::PDFiumLibrary::get();
316
+ if (!pdf->library) throw std::runtime_error("This engine has no PDFium support");
317
+ pdf->document = pdf->library->openDocument(pdf->bytes.data(), length, OString(password ? password : ""));
318
+ if (!pdf->document) throw std::runtime_error("PDFium could not open the PDF (invalid, unsupported, or password-protected)");
319
+ return pdf.release();
320
+ }, static_cast<PdfDocument*>(nullptr));
321
+ }
322
+
323
+ int rabi_pdf_page_count(PdfDocument* pdf)
324
+ {
325
+ return guarded([&] {
326
+ if (!pdf || !pdf->document) throw std::runtime_error("Invalid PDF handle");
327
+ return pdf->document->getPageCount();
328
+ }, -1);
329
+ }
330
+
331
+ /** Coordinates use int32 twips, consistent with the LOK raster ABI. */
332
+ int rabi_pdf_page_size(PdfDocument* pdf, int page, int* width, int* height)
333
+ {
334
+ return guarded([&] {
335
+ const auto size = pdfPageSize(pdf, page);
336
+ *width = checkedTwips(size.getWidth());
337
+ *height = checkedTwips(size.getHeight());
338
+ return 1;
339
+ }, 0);
340
+ }
341
+
342
+ /** Paint an opaque white PDF page/crop as owned straight RGBA at the requested scale. */
343
+ int rabi_pdf_paint(PdfDocument* pdf, unsigned char* buffer, int page, int canvasWidth,
344
+ int canvasHeight, int x, int y, int width, int height)
345
+ {
346
+ return guarded([&] {
347
+ const auto size = pdfPageSize(pdf, page);
348
+ const int pageWidth = checkedTwips(size.getWidth());
349
+ const int pageHeight = checkedTwips(size.getHeight());
350
+ if (!buffer || canvasWidth < 1 || canvasHeight < 1
351
+ || static_cast<long long>(canvasWidth) * canvasHeight > 16 * 1024 * 1024
352
+ || x < 0 || y < 0 || width < 1 || height < 1
353
+ || static_cast<long long>(x) + width > pageWidth
354
+ || static_cast<long long>(y) + height > pageHeight)
355
+ throw std::runtime_error("PDF tile dimensions exceed their bounds");
356
+ const double scaleX = static_cast<double>(canvasWidth) / width;
357
+ const double scaleY = static_cast<double>(canvasHeight) / height;
358
+ const double fullWidth = std::round(pageWidth * scaleX);
359
+ const double fullHeight = std::round(pageHeight * scaleY);
360
+ if (fullWidth > std::numeric_limits<int>::max() || fullHeight > std::numeric_limits<int>::max())
361
+ throw std::runtime_error("PDF scaled page exceeds the coordinate range");
362
+ auto loadedPage = pdf->document->openPage(page);
363
+ if (!loadedPage) throw std::runtime_error("PDFium could not load the selected page");
364
+ int actualWidth = canvasWidth;
365
+ int actualHeight = canvasHeight;
366
+ auto bitmap = pdf->library->createBitmap(actualWidth, actualHeight, 1);
367
+ if (!bitmap || actualWidth != canvasWidth || actualHeight != canvasHeight
368
+ || bitmap->getFormat() != vcl::pdf::PDFBitmapType::BGRA)
369
+ throw std::runtime_error("PDFium could not allocate the requested tile");
370
+ bitmap->fillRect(0, 0, canvasWidth, canvasHeight, 0xffffffff);
371
+ bitmap->renderPageBitmap(pdf->document.get(), loadedPage.get(),
372
+ -static_cast<int>(std::round(x * scaleX)), -static_cast<int>(std::round(y * scaleY)),
373
+ static_cast<int>(fullWidth), static_cast<int>(fullHeight));
374
+ const auto* pixels = bitmap->getBuffer();
375
+ const int stride = bitmap->getStride();
376
+ if (!pixels || stride < canvasWidth * 4) throw std::runtime_error("PDFium returned an invalid bitmap");
377
+ for (int row = 0; row < canvasHeight; ++row) {
378
+ for (int col = 0; col < canvasWidth; ++col) {
379
+ const auto* source = pixels + row * stride + col * 4;
380
+ auto* target = buffer + (row * canvasWidth + col) * 4;
381
+ target[0] = source[2]; target[1] = source[1]; target[2] = source[0]; target[3] = 255;
382
+ }
383
+ }
384
+ return 1;
385
+ }, 0);
386
+ }
387
+
388
+ int rabi_pdf_destroy(PdfDocument* pdf)
389
+ {
390
+ return guarded([&] { delete pdf; return 1; }, 0);
391
+ }
392
+
393
+ /** Releases a document after conversion; returns zero when destruction throws. */
394
+ int rabi_lok_document_destroy(LibreOfficeKitDocument* document)
395
+ {
396
+ return guarded([&] {
397
+ document->pClass->destroy(document);
398
+ return 1;
399
+ }, 0);
400
+ }
401
+
402
+ /**
403
+ * Returns an owned UTF-8 error string, released with the exported free function.
404
+ * A null office reads shim exceptions after initialization or teardown failure.
405
+ * Call before another operation; exception messages are limited to 4095 bytes.
406
+ */
407
+ char* rabi_lok_error(LibreOfficeKit* office)
408
+ {
409
+ if (lastError[0] != '\0') return copyLastError();
410
+ auto* error = guarded([&] {
411
+ return office == nullptr ? nullptr : office->pClass->getError(office);
412
+ }, static_cast<char*>(nullptr));
413
+ return error == nullptr && lastError[0] != '\0' ? copyLastError() : error;
414
+ }
415
+
416
+ /**
417
+ * Releases the office after all documents are destroyed; returns zero on exception.
418
+ * No later operations may use the office, including after destruction fails.
419
+ */
420
+ int rabi_lok_destroy(LibreOfficeKit* office)
421
+ {
422
+ return guarded([&] {
423
+ office->pClass->destroy(office);
424
+ return 1;
425
+ }, 0);
426
+ }
427
+
428
+ }
@@ -0,0 +1,87 @@
1
+ diff --git a/configure.ac b/configure.ac
2
+ index 32651cf64..61263583d 100644
3
+ --- a/configure.ac
4
+ +++ b/configure.ac
5
+ @@ -3870,8 +3870,13 @@ if test $_os = Darwin; then
6
+ if test ! -d "$MACOSX_SDK_PATH"; then
7
+ AC_MSG_ERROR([Could not find an appropriate macOS SDK])
8
+ fi
9
+ - macosx_sdk=`xcodebuild -version -sdk "$MACOSX_SDK_PATH" SDKVersion`
10
+ - MACOSX_SDK_BUILD_VERSION=$(xcodebuild -version -sdk "$MACOSX_SDK_PATH" ProductBuildVersion)
11
+ + if test "$libo_build_tools_only" = yes; then
12
+ + macosx_sdk=$(xcrun --sdk macosx --show-sdk-version)
13
+ + MACOSX_SDK_BUILD_VERSION=$(xcrun --sdk macosx --show-sdk-build-version)
14
+ + else
15
+ + macosx_sdk=`xcodebuild -version -sdk "$MACOSX_SDK_PATH" SDKVersion`
16
+ + MACOSX_SDK_BUILD_VERSION=$(xcodebuild -version -sdk "$MACOSX_SDK_PATH" ProductBuildVersion)
17
+ + fi
18
+ # format changed between 10.9 and 10.10 - up to 10.9 it was just four digits (1090), starting
19
+ # with macOS 10.10 it was switched to account for x.y.z with six digits, 10.10 is 101000,
20
+ # 10.10.2 is 101002
21
+ @@ -3910,27 +3915,39 @@ if test $_os = Darwin; then
22
+ FRAMEWORKSHOME="$MACOSX_SDK_PATH/System/Library/Frameworks"
23
+ MACOSX_DEPLOYMENT_TARGET="$with_macosx_version_min_required"
24
+
25
+ - AC_MSG_CHECKING([whether Xcode is new enough])
26
+ - my_xcode_ver1=$(xcrun xcodebuild -version | head -n 1)
27
+ - my_xcode_ver2=${my_xcode_ver1#Xcode }
28
+ - my_xcode_ver3=$(printf %s "$my_xcode_ver2" | $AWK -F. '{ print $1*100+($2<100?$2:99) }')
29
+ - if test "$my_xcode_ver3" -ge 1403; then
30
+ - AC_MSG_RESULT([yes ($my_xcode_ver2)])
31
+ - if test $MAC_OS_X_VERSION_MIN_REQUIRED -lt 120000; then
32
+ - if test "$my_xcode_ver3" -eq 1500; then
33
+ - dnl the bug was already fixed on 15.1 and 15.2 still has the same OS requirements as 15.0
34
+ - dnl in other words all affected users could update to a working Xcode version
35
+ - AC_MSG_WARN([Use a current version of XCode or bump the minimum deployment target])
36
+ - AC_MSG_WARN([[see https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking]])
37
+ - AC_MSG_ERROR([Xcode 15.0 has a bug in the new linker that causes runtime crashes on macOS 11 - aborting])
38
+ - fi
39
+ + if test "$libo_build_tools_only" = yes; then
40
+ + # Cross-build tools use the installed SDK and clang; they do not package a macOS app.
41
+ + AC_MSG_CHECKING([whether the build-tools clang is new enough])
42
+ + libo_build_clang=$(xcrun clang -dumpversion)
43
+ + libo_build_clang_major=${libo_build_clang%%.*}
44
+ + if test "$libo_build_clang_major" -lt 14; then
45
+ + AC_MSG_ERROR([clang $libo_build_clang is too old for the macOS build tools])
46
+ fi
47
+ + AC_MSG_RESULT([$libo_build_clang])
48
+ + MACOSX_XCODE_BUILD_VERSION=
49
+ else
50
+ - AC_MSG_ERROR(["$my_xcode_ver1" is too old or unrecognized, must be at least Xcode 14.3])
51
+ - fi
52
+ + AC_MSG_CHECKING([whether Xcode is new enough])
53
+ + my_xcode_ver1=$(xcrun xcodebuild -version | head -n 1)
54
+ + my_xcode_ver2=${my_xcode_ver1#Xcode }
55
+ + my_xcode_ver3=$(printf %s "$my_xcode_ver2" | $AWK -F. '{ print $1*100+($2<100?$2:99) }')
56
+ + if test "$my_xcode_ver3" -ge 1403; then
57
+ + AC_MSG_RESULT([yes ($my_xcode_ver2)])
58
+ + if test $MAC_OS_X_VERSION_MIN_REQUIRED -lt 120000; then
59
+ + if test "$my_xcode_ver3" -eq 1500; then
60
+ + dnl the bug was already fixed on 15.1 and 15.2 still has the same OS requirements as 15.0
61
+ + dnl in other words all affected users could update to a working Xcode version
62
+ + AC_MSG_WARN([Use a current version of XCode or bump the minimum deployment target])
63
+ + AC_MSG_WARN([[see https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking]])
64
+ + AC_MSG_ERROR([Xcode 15.0 has a bug in the new linker that causes runtime crashes on macOS 11 - aborting])
65
+ + fi
66
+ + fi
67
+ + else
68
+ + AC_MSG_ERROR(["$my_xcode_ver1" is too old or unrecognized, must be at least Xcode 14.3])
69
+ + fi
70
+
71
+ - my_xcode_ver1=$(xcrun xcodebuild -version | tail -n 1)
72
+ - MACOSX_XCODE_BUILD_VERSION=${my_xcode_ver1#Build version }
73
+ + my_xcode_ver1=$(xcrun xcodebuild -version | tail -n 1)
74
+ + MACOSX_XCODE_BUILD_VERSION=${my_xcode_ver1#Build version }
75
+ + fi
76
+
77
+ LIBTOOL=/usr/bin/libtool
78
+ INSTALL_NAME_TOOL=install_name_tool
79
+ @@ -6358,7 +6375,7 @@ if test "$cross_compiling" = "yes"; then
80
+ $with_build_platform_configure_options \
81
+ --srcdir=$srcdir
82
+
83
+ - ./configure \
84
+ + libo_build_tools_only=yes ./configure \
85
+ $sub_conf_defaults \
86
+ --with-parallelism="$with_parallelism" \
87
+ --with-theme="$with_theme" \