2022-11-11 07:26:34 -06:00
|
|
|
|
2022-12-12 10:40:15 -06:00
|
|
|
EXEEXT = .js
|
|
|
|
|
2023-01-25 03:47:57 -06:00
|
|
|
AM_CXXFLAGS = \
|
|
|
|
-pthread -s USE_PTHREADS=1 \
|
|
|
|
-s DISABLE_EXCEPTION_CATCHING=0
|
2022-11-11 07:26:34 -06:00
|
|
|
|
2023-01-25 03:47:57 -06:00
|
|
|
AM_CPPFLAGS = \
|
|
|
|
-I$(top_srcdir) \
|
|
|
|
-I$(top_srcdir)/common \
|
|
|
|
-I$(top_srcdir)/kit \
|
|
|
|
-I$(top_srcdir)/net \
|
|
|
|
-I$(top_srcdir)/wsd \
|
|
|
|
-I@LOBUILDDIR@/workdir/UnpackedTarball/libpng \
|
|
|
|
-I@LOBUILDDIR@/workdir/UnpackedTarball/zlib \
|
|
|
|
-DCOOLWSD_CONFIGDIR='"@COOLWSD_CONFIGDIR@"' \
|
|
|
|
-DDEBUG_ABSSRCDIR='"@abs_srcdir@"' \
|
|
|
|
-DMOBILEAPP=1
|
|
|
|
|
|
|
|
bin_PROGRAMS = online
|
|
|
|
|
|
|
|
online_SOURCES = \
|
|
|
|
wasmapp.cpp \
|
2023-01-09 04:23:48 -06:00
|
|
|
../common/Authorization.cpp \
|
|
|
|
../common/ConfigUtil.cpp \
|
2024-03-23 09:00:48 -05:00
|
|
|
../common/Crypto-stub.cpp \
|
2023-01-09 04:23:48 -06:00
|
|
|
../common/FileUtil.cpp \
|
|
|
|
../common/CommandControl.cpp \
|
|
|
|
../common/Log.cpp \
|
|
|
|
../common/TraceEvent.cpp \
|
|
|
|
../common/Protocol.cpp \
|
|
|
|
../common/StringVector.cpp \
|
|
|
|
../common/Session.cpp \
|
|
|
|
../common/SigUtil.cpp \
|
2023-10-02 18:23:15 -05:00
|
|
|
../common/Simd.cpp \
|
2023-01-09 04:23:48 -06:00
|
|
|
../common/SpookyV2.cpp \
|
|
|
|
../common/Unit.cpp \
|
|
|
|
../common/Util.cpp \
|
2024-03-17 14:23:18 -05:00
|
|
|
../common/Util-mobile.cpp \
|
2023-01-09 04:23:48 -06:00
|
|
|
../kit/ChildSession.cpp \
|
|
|
|
../kit/Kit.cpp \
|
2024-05-08 11:47:53 -05:00
|
|
|
../kit/KitQueue.cpp \
|
2024-03-06 06:43:53 -06:00
|
|
|
../kit/KitWebSocket.cpp \
|
2023-10-02 18:23:15 -05:00
|
|
|
../kit/DeltaSimd.c \
|
2023-01-09 04:23:48 -06:00
|
|
|
../net/FakeSocket.cpp \
|
|
|
|
../net/Socket.cpp \
|
|
|
|
../wsd/ClientSession.cpp \
|
|
|
|
../wsd/DocumentBroker.cpp \
|
|
|
|
../wsd/COOLWSD.cpp \
|
2024-02-11 10:42:22 -06:00
|
|
|
../wsd/ClientRequestDispatcher.cpp \
|
2023-01-09 04:23:48 -06:00
|
|
|
../wsd/RequestDetails.cpp \
|
|
|
|
../wsd/Storage.cpp \
|
2023-11-29 07:59:01 -06:00
|
|
|
../wsd/TileCache.cpp \
|
|
|
|
../wsd/coolwsd-fork.cpp
|
2022-11-11 07:26:34 -06:00
|
|
|
|
2022-11-14 13:33:49 -06:00
|
|
|
online_DEPENDENCIES = \
|
2022-12-12 10:40:15 -06:00
|
|
|
@LOBUILDDIR@/instdir/program/soffice.html.linkdeps \
|
2022-12-13 04:12:59 -06:00
|
|
|
soffice.data \
|
2023-01-25 03:47:57 -06:00
|
|
|
soffice.data.js.metadata
|
2022-11-14 13:33:49 -06:00
|
|
|
|
2022-12-12 10:40:15 -06:00
|
|
|
# note cannot add content of .linkdeps to DEPENDENCIES because it contains -lFoo
|
2022-11-14 13:33:49 -06:00
|
|
|
online_LDADD = \
|
|
|
|
${POCOLIB}/libPocoEncodings@POCODEBUG@.a \
|
|
|
|
${POCOLIB}/libPocoNet@POCODEBUG@.a \
|
|
|
|
${POCOLIB}/libPocoUtil@POCODEBUG@.a \
|
|
|
|
${POCOLIB}/libPocoXML@POCODEBUG@.a \
|
|
|
|
${POCOLIB}/libPocoJSON@POCODEBUG@.a \
|
|
|
|
${POCOLIB}/libPocoFoundation@POCODEBUG@.a \
|
|
|
|
${ZSTDLIB}/libzstd.a \
|
|
|
|
-L@LOBUILDDIR@/instdir/program \
|
|
|
|
$(shell cat @LOBUILDDIR@/instdir/program/soffice.html.linkdeps)
|
|
|
|
|
|
|
|
# TODO these are just copypasta from core
|
|
|
|
online_LDFLAGS = \
|
2023-01-12 09:11:27 -06:00
|
|
|
-pthread -s MODULARIZE -s EXPORT_NAME=createOnlineModule -s USE_PTHREADS=1 -s TOTAL_MEMORY=1GB -s PTHREAD_POOL_SIZE=15 --bind -s FORCE_FILESYSTEM=1 -s WASM_BIGINT=1 -s ERROR_ON_UNDEFINED_SYMBOLS=1 -s FETCH=1 -s ASSERTIONS=1 -s EXIT_RUNTIME=0 -s EXPORTED_RUNTIME_METHODS=["UTF16ToString","stringToUTF16","UTF8ToString","allocateUTF8","ccall","cwrap","FS"] -pthread -s USE_PTHREADS=1 -s DISABLE_EXCEPTION_CATCHING=0 -s EXPORTED_FUNCTIONS=["_main","_libreofficekit_hook","_libreofficekit_hook_2","_lok_preinit","_lok_preinit_2","_handle_cool_message"] \
|
2022-12-05 04:00:52 -06:00
|
|
|
--pre-js @LOBUILDDIR@/workdir/CustomTarget/static/emscripten_fs_image/soffice.data.js.link
|
2022-12-12 10:40:15 -06:00
|
|
|
|
2023-11-27 14:32:44 -06:00
|
|
|
if ENABLE_DEBUG
|
|
|
|
online_LDFLAGS += \
|
|
|
|
-gseparate-dwarf
|
|
|
|
endif
|
|
|
|
|
Make the temporary "WASM app" work
Now I hope things are initialised in the right order and the plumbing
gets set up so that messages are passed as expected. It seems to work
most of the time.
Main changes are:
- The online WASM executable is built using the -s MODULARIZE -s
EXPORT_NAME=createOnlineModule options. This means that the WASM
runtime is not automatically initialized and the main() function
is not automatically started. Only when the createOnlineModule()
function is called is that done. Calling exported C/C++ functions
is a little bit more complicated.
- Code to actually Base64-encode strings to be executed as
JavaScript when expected is now present in wasmapp.cpp. (After
being passed through the Base64ToArrayBuffer function on the JS
side.) Whether this is actually necessary is not fully clear, but
to keep the code similar to that in the GTK, iOS, and Android
apps, this is kept as such for now. It would probably work fine to
just directly create the ArrayBuffer in the C++ (using the EM_ASM
magic).
- The COOLWSD::run() function is now run in a separate thread so
that main() can return.
- The FakeWebSocket's onopen() function is now called from
innerMain(), where the HULLO message is sent. It remains a bit
unclear if this really is the ideal place.
In the mobile apps the HULLO message is sent and the onopen()
function is called in the window.socket.onopen() function in
global.js.
But note that despite that the WASM app and the mobile apps are
largely quite similarly constructed and the FakeSocket and
FakeWebSocket plumbing is the same, there is an important
difference. In a mobile app the C++ code is what runs first, and
that then loads the HTML page into WebKit, in which the JS
runs. In the WASM app it is the other way around. The web page is
naturaly the one that is loaded and the JS code then starts
running the C++ code as WASM.
Finally, note that the whole concept that there is a separate "WASM
app" is temporary.
What we eventually want to achieve is that the COOL webpage upon
loading will connect a COOL server. As it does currently. The COOL
server runs the online and core C++ code to load a document, and
renders document tiles and sends those to the client JS code to
dispay.
The new thing will be that, if enabled, in addition to the HTML and JS
resources, the client will also download the WASM code and data
resources. Also, the document and updates to it will be downloaded
while being edited so that a copy can be kept in client memory. But
the WASM code and the downloaded document will remain unused most of
the time. Only if the connection to the COOL server breaks will the JS
start running the WASM code and the JS will talk to online code
running locally as WASM instead of to a COOL server. Obviously there
are still lots of things hanging in the air here regarding how exactly
this will work.
Signed-off-by: Tor Lillqvist <tml@collabora.com>
Change-Id: Ib1786a0b485d51797b0f2302d4296aa1ff9df5c1
2023-01-05 12:11:01 -06:00
|
|
|
if ENABLE_WASM_ADDITIONAL_FILES
|
|
|
|
online_LDFLAGS += \
|
|
|
|
--preload-file $(WASM_ADDITIONAL_FILES)@
|
|
|
|
endif
|
|
|
|
|
2022-12-12 10:40:15 -06:00
|
|
|
|
2022-12-13 04:12:59 -06:00
|
|
|
soffice.dat%: @LOBUILDDIR@/instdir/program/soffice.dat%
|
2022-12-12 10:40:15 -06:00
|
|
|
cp $< $@
|