[Libreoffice-commits] core.git: Branch 'feature/wasm' - config_host.mk.in configure.ac cppuhelper/source README.wasm sal/osl solenv/gbuild static/CustomTarget_data.mk static/debug.js vcl/Module_vcl.mk

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 2 09:54:40 UTC 2021


 README.wasm                                    |   20 ++++++++
 config_host.mk.in                              |    1 
 configure.ac                                   |    6 ++
 cppuhelper/source/paths.cxx                    |    4 +
 sal/osl/unx/uunxapi.cxx                        |   10 +++-
 solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk |    4 -
 static/CustomTarget_data.mk                    |   59 +++++++++++++++++++++++++
 static/debug.js                                |    3 +
 vcl/Module_vcl.mk                              |    2 
 9 files changed, 105 insertions(+), 4 deletions(-)

New commits:
commit b5789b8d65a67f86acf57a2464d6801780f2ee8e
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Fri Jul 2 11:49:37 2021 +0200
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Fri Jul 2 11:53:00 2021 +0200

    Build vcldemo + link image + image instructions
    
    Change-Id: Iaf6fbdaee0f8842fdde25de81f1345f1458cfcbb

diff --git a/README.wasm b/README.wasm
index 21a81d6684a4..abe7c2af6f4e 100644
--- a/README.wasm
+++ b/README.wasm
@@ -1,3 +1,23 @@
+= Manually updating the WASM FS image =
+
+.../git_emsdk/upstream/emscripten/tools/file_packager instdir/program/soffice.data --use-preload-plugins --preload instdir/program/*rc instdir/program/*.rdb instdir/program/services/services.rdb instdir/program/resource/* instdir/program/types/* instdir/presets/  --js-output=instdir/program/soffice.data.js --separate-metadata
+
+Anything can be added to the list. I just kept the normal instdir layout.
+
+This generates the reqired image files. --separate-metadata is used, so
+regenerating the image doesn't require re-linking.
+
+The environment settings are in static/debug.js. This unfortunatly needs re-
+linking. It could probably use some mechanism equal to the FS metadata, but
+I didn't find anything.
+
+There is a stub of the generation CustomTarget in static/CustomTarget_data.mk.
+
+The actual data should probably just be generated in workdir/CustomTarget/static
+and then linked to instdir/program and workdir/LinkTarget/Executable/. 
+
+
+
 = Status =
 
 $ make
diff --git a/config_host.mk.in b/config_host.mk.in
index 4f56771cc8af..4b3d8fc52269 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -132,6 +132,7 @@ export DO_FETCH_TARBALLS=@DO_FETCH_TARBALLS@
 export DPKG=@DPKG@
 export EBOOK_CFLAGS=$(gb_SPACE)@EBOOK_CFLAGS@
 export EBOOK_LIBS=$(gb_SPACE)@EBOOK_LIBS@
+export EMSDK_FILE_PACKAGER=@EMSDK_FILE_PACKAGER@
 export ENABLE_ANDROID_LOK=@ENABLE_ANDROID_LOK@
 export ENABLE_ANDROID_EDITING=@ENABLE_ANDROID_EDITING@
 export ENABLE_AVAHI=@ENABLE_AVAHI@
diff --git a/configure.ac b/configure.ac
index 199e2318e304..e801e3e1030c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1345,10 +1345,16 @@ if test "$_os" = "Emscripten"; then
         AC_MSG_WARN(["\$EMMAKEN_JUST_CONFIGURE wasn't set by emconfigure. Prefix configure or use autogen.sh])
         EMSCRIPTEN_ERROR=1
     fi
+    EMSDK_FILE_PACKAGER="$(em-config EMSCRIPTEN_ROOT)"/tools/file_packager
+    if ! test -x "$EMSDK_FILE_PACKAGER"; then
+        AC_MSG_WARN([No file_packager found in $(em-config EMSCRIPTEN_ROOT)/tools/file_packager.])
+	EMSCRIPTEN_ERROR=1
+    fi
     if test $EMSCRIPTEN_ERROR -ne 0; then
         AC_MSG_ERROR(["Please fix your EMSDK setup to build with Emscripten!"])
     fi
 fi
+AC_SUBST(EMSDK_FILE_PACKAGER)
 
 ###############################################################################
 # Extensions switches --enable/--disable
diff --git a/cppuhelper/source/paths.cxx b/cppuhelper/source/paths.cxx
index 41dd609e584c..0996321fb7ae 100644
--- a/cppuhelper/source/paths.cxx
+++ b/cppuhelper/source/paths.cxx
@@ -62,7 +62,11 @@ OUString cppu::getUnoIniUri() {
     //     defaultBootstrap_InitialComponentContext
     // and since rtlBootstrapHandle is not ref-counted doing anything
     // clean here is hardish.
+#if defined ANDROID
     OUString uri("file:///assets/program");
+#else
+    OUString uri("file:///instdir/program");
+#endif
 #else
 
     OUString uri;
diff --git a/sal/osl/unx/uunxapi.cxx b/sal/osl/unx/uunxapi.cxx
index 917476d7ab03..e301c54b34a0 100644
--- a/sal/osl/unx/uunxapi.cxx
+++ b/sal/osl/unx/uunxapi.cxx
@@ -214,14 +214,22 @@ template<> OUString fromOString(OString const & s)
 template<typename T> bool realpath_(const T& pstrFileName, T& ppstrResolvedName)
 {
     OString fn = toOString(pstrFileName);
-#ifdef ANDROID
+#if defined ANDROID || defined EMSCRIPTEN
+#if defined ANDROID
     if (fn == "/assets" || fn.startsWith("/assets/"))
+#else
+    if (fn == "/instdir" || fn.startsWith("/instdir/"))
+#endif
     {
         if (osl::access(fn, F_OK) == -1)
+        {
+            SAL_INFO("sal.file", "realpath(" << fn << "): FAILED");
             return false;
+        }
 
         ppstrResolvedName = pstrFileName;
 
+        SAL_INFO("sal.file", "realpath(" << fn << "): OK");
         return true;
     }
 #endif
diff --git a/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk b/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk
index da6169e9459c..e8b090516633 100644
--- a/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk
+++ b/solenv/gbuild/platform/EMSCRIPTEN_INTEL_GCC.mk
@@ -17,7 +17,7 @@ gb_EMSCRIPTEN_CPPFLAGS := -pthread -s TOTAL_MEMORY=1GB -s USE_PTHREADS=1 -s PTHR
 # To keep the link time (and memory) down, prevent all rewriting options from wasm-emscripten-finalize
 # See emscrypten.py, finalize_wasm, modify_wasm = True
 # So we need WASM_BIGINT=1 and ASSERTIONS=1 (2 implies STACK_OVERFLOW_CHECK)
-gb_EMSCRIPTEN_LDFLAGS := $(gb_EMSCRIPTEN_CPPFLAGS) --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 EXTRA_EXPORTED_RUNTIME_METHODS=["UTF16ToString","stringToUTF16"]
+gb_EMSCRIPTEN_LDFLAGS := $(gb_EMSCRIPTEN_CPPFLAGS) --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 EXTRA_EXPORTED_RUNTIME_METHODS=["UTF16ToString","stringToUTF16"] --pre-js instdir/program/soffice.data.js --pre-js static/debug.js
 gb_EMSCRIPTEN_QTDEFS := -DQT_NO_LINKED_LIST -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB
 
 gb_Executable_EXT := .html
@@ -32,7 +32,7 @@ gb_LINKEROPTFLAGS :=
 gb_LINKERSTRIPDEBUGFLAGS :=
 # This maps to g3, no source maps, but DWARF with current emscripten!
 # https://developer.chrome.com/blog/wasm-debugging-2020/
-gb_DEBUGINFO_FLAGS = -g3
+gb_DEBUGINFO_FLAGS = -g
 #gb_DEBUGINFO_FLAGS = -gsource-map --source-map-base=file://$(WORKDIR)/LinkTarget/Executable
 # We need at least code elimination, otherwise linking OOMs even with 64GB.
 # So we "fake" -Og support to mean -O1 for Emscripten and always enable it for debug in configure.
diff --git a/static/CustomTarget_data.mk b/static/CustomTarget_data.mk
new file mode 100644
index 000000000000..52344b6c35cc
--- /dev/null
+++ b/static/CustomTarget_data.mk
@@ -0,0 +1,59 @@
+# vim: set noet sw=4 ts=4:
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_CustomTarget_CustomTarget,static/data))
+
+/home/jmg/Development/libreoffice/git_emsdk/upstream/emscripten/tools/file_packager instdir/program/soffice.data --use-preload-plugins --preload instdir/program/*rc instdir/program/*.rdb instdir/program/services/services.rdb instdir/program/resource/* instdir/program/types/* instdir/presets/  --js-output=instdir/program/soffice.data.js --separate-metadata
+
+gb_objcopy_bfdname := $(shell objdump -a $(call gb_GenCxxObject_get_target,CustomTarget/static/component_maps) | sed -ne 's/^.*format //p')
+
+static_WORKDIR := $(call gb_CustomTarget_get_workdir,static)
+postprocess_WORKDIR := $(call gb_CustomTarget_get_workdir,postprocess)
+
+$(call gb_CustomTarget_get_target,static/components): \
+    $(static_WORKDIR)/component_maps.cxx \
+
+gb_GenCxxObject_get_target
+static_WORKDIR := $(call gb_CustomTarget_get_workdir,static)
+postprocess_WORKDIR := $(call gb_CustomTarget_get_workdir,postprocess)
+
+gb_GenCxxObject_get_target
+gb_GenCxxObject_get_dwo_target
+CustomTarget/static/component_maps
+
+define gb_static_components_create_component_map
+TEMPFILE=`$(gb_MKTEMP)` && \
+$(call gb_Helper_abbreviate_dirs, \
+    $(call gb_ExternalExecutable_get_command,python) $(1) \
+        $(if $(ENABLE_SERVICES_RDB_FROM_BUILD), \
+            -c $(postprocess_WORKDIR)/services_constructors.list, \
+            -g core -g writer -g desktop \
+        ) \
+) > $$TEMPFILE && \
+$(call gb_Helper_replace_if_different_and_touch,$${TEMPFILE},$(2))
+
+endef
+
+
+
+$(call gb_CustomTarget_get_target,static/data): \
+    $(static_WORKDIR)/soffice.data.js.metadata \
+    $(static_WORKDIR)/soffice.data \
+
+$(static_WORKDIR)/component_maps.cxx: \
+    $(SRCDIR)/solenv/bin/native-code.py \
+    | $(static_WORKDIR)/.dir
+        $(call gb_Output_announce,$(subst $(BUILDDIR)/,,$@),$(true),GEN,2)
+	objcopy -I binary -B i386 -O elf64-x86-64 \
+  --rename-section .data=.mydata,readonly,contents src dst.o
+	objdump -a $(call gb_GenCxxObject_get_target,CustomTarget/static/component_maps) | sed -ne 's/^.*format //p'
+        $(call gb_static_components_create_component_map,$<,$@)
+
+# vim: set noet sw=4:
diff --git a/static/debug.js b/static/debug.js
new file mode 100644
index 000000000000..9e4e263f3c73
--- /dev/null
+++ b/static/debug.js
@@ -0,0 +1,3 @@
+Module.preRun.push(function() {
+    ENV.SAL_LOG = "+INFO+WARN"
+});
diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk
index c8f01c947217..aae6167817e1 100644
--- a/vcl/Module_vcl.mk
+++ b/vcl/Module_vcl.mk
@@ -36,7 +36,7 @@ $(eval $(call gb_Module_add_targets,vcl,\
         Package_skia_denylist ) \
     $(if $(filter DESKTOP,$(BUILD_TYPE)), \
         StaticLibrary_vclmain \
-        $(if $(or $(DISABLE_GUI),$(DISABLE_DYNLOADING)),, \
+        $(if $(or $(DISABLE_GUI),$(DISABLE_DYNLOADING)),Executable_vcldemo, \
             $(if $(ENABLE_MACOSX_SANDBOX),, \
                 Executable_ui-previewer) \
             $(if $(filter LINUX MACOSX SOLARIS WNT %BSD,$(OS)), \


More information about the Libreoffice-commits mailing list