desktop/Library_sofficeapp.mk             |    6 ++++++
 desktop/source/app/appinit.cxx            |    7 +++++++
 static/CustomTarget_unoembind.mk          |    8 ++++----
 static/source/embindmaker/embindmaker.cxx |   30 ++++++++++++++++++++++--------
 4 files changed, 39 insertions(+), 12 deletions(-)

New commits:
commit c7664f12a99b6e08eb334d63646c3d2a6aa75e18
Author:     Stephan Bergmann <stephan.bergm...@allotropia.de>
AuthorDate: Tue Feb 27 16:30:24 2024 +0100
Commit:     Stephan Bergmann <stephan.bergm...@allotropia.de>
CommitDate: Wed Feb 28 07:53:21 2024 +0100

    Init Embind-ings manually, once UNO is set up
    
    Upcoming code that changes the Embind'ing of UNO sequences will require
    availability of the UNO type manager during that Embind init code, so only 
call
    that after UNO has been bootstrapped (rather than as part of the 
initialization
    of global static data, which is what EMSCRIPTEN_BINDINGS does).
    
    Change-Id: Iba19851ffb82c055dcab10a28a8c1fafa9d2a414
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164065
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de>

diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index 641efda7eda2..cc39ccd12f92 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -37,6 +37,12 @@ $(eval $(call gb_Library_use_custom_headers,sofficeapp,\
        officecfg/registry \
 ))
 
+ifeq ($(OS),EMSCRIPTEN)
+$(eval $(call gb_Library_use_custom_headers,sofficeapp, \
+    static/unoembind \
+))
+endif
+
 $(eval $(call gb_Library_use_api,sofficeapp,\
        udkapi \
        offapi \
diff --git a/desktop/source/app/appinit.cxx b/desktop/source/app/appinit.cxx
index 51b466c6b980..1a0681f0d163 100644
--- a/desktop/source/app/appinit.cxx
+++ b/desktop/source/app/appinit.cxx
@@ -45,6 +45,10 @@
 #include <iostream>
 #include <map>
 
+#if defined EMSCRIPTEN
+#include <bindings_uno.hxx>
+#endif
+
 using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::beans;
@@ -83,6 +87,9 @@ void Desktop::InitApplicationServiceManager()
         UNO_QUERY_THROW);
 #endif
     comphelper::setProcessServiceFactory(sm);
+#if defined EMSCRIPTEN
+    init_unoembind_uno();
+#endif
 }
 
 void Desktop::RegisterServices()
diff --git a/static/CustomTarget_unoembind.mk b/static/CustomTarget_unoembind.mk
index 045e0fea511c..d1bc294e0b9f 100644
--- a/static/CustomTarget_unoembind.mk
+++ b/static/CustomTarget_unoembind.mk
@@ -15,14 +15,14 @@ $(eval $(call 
gb_CustomTarget_register_targets,static/unoembind, \
 ))
 
 $(call gb_CustomTarget_get_workdir,static/unoembind)/bindings_uno.cxx \
+$(call gb_CustomTarget_get_workdir,static/unoembind)/bindings_uno.hxx \
 $(call gb_CustomTarget_get_workdir,static/unoembind)/bindings_uno.js: \
         $(call gb_Executable_get_target_for_build,embindmaker) $(call 
gb_UnoApi_get_target,udkapi) \
-        $(call gb_UnoApi_get_target,offapi) \
-        $(if $(ENABLE_DBGUTIL),$(call gb_UnoApiTarget_get_target,embindtest))
+        $(call gb_UnoApi_get_target,offapi)
        $(call gb_Executable_get_command,embindmaker) uno \
         $(call gb_CustomTarget_get_workdir,static/unoembind)/bindings_uno.cxx \
+        $(call gb_CustomTarget_get_workdir,static/unoembind)/bindings_uno.hxx \
         $(call gb_CustomTarget_get_workdir,static/unoembind)/bindings_uno.js \
-        +$(call gb_UnoApi_get_target,udkapi) +$(call 
gb_UnoApi_get_target,offapi) \
-        +$(if $(ENABLE_DBGUTIL),$(call gb_UnoApiTarget_get_target,embindtest))
+        +$(call gb_UnoApi_get_target,udkapi) +$(call 
gb_UnoApi_get_target,offapi)
 
 # vim: set noet sw=4 ts=4:
diff --git a/static/source/embindmaker/embindmaker.cxx 
b/static/source/embindmaker/embindmaker.cxx
index bff11e99b16d..335b7983503c 100644
--- a/static/source/embindmaker/embindmaker.cxx
+++ b/static/source/embindmaker/embindmaker.cxx
@@ -46,13 +46,13 @@ void badUsage()
 {
     std::cerr
         << "Usage:

"
-           "  embindmaker <name> <cpp-output> <js-output> <registries>

"
+           "  embindmaker <name> <cpp-output> <hpp-output> <js-output> 
<registries>

"
            "where each <registry> is '+' (primary) or ':' (secondary), 
followed by: either a
"
            "new- or legacy-format .rdb file, a single .idl file, or a root 
directory of an
"
            ".idl file tree.  For all primary registries, Embind code is 
written to
"
-           "<cpp-output> and corresponding JavaScript scaffolding code is 
written to
"
-           "<js-output>.  The <name> is used as part of some of the 
identifiers in those
"
-           "generated files.
";
+           "<cpp-output>/<hpp-output> and corresponding JavaScript scaffolding 
code is
"
+           "written to <js-output>.  The <name> is used as part of some of the 
identifiers
"
+           "in those generated files.
";
     std::exit(EXIT_FAILURE);
 }
 
@@ -708,16 +708,17 @@ SAL_IMPLEMENT_MAIN()
     try
     {
         auto const args = rtl_getAppCommandArgCount();
-        if (args < 3)
+        if (args < 4)
         {
             badUsage();
         }
         OUString name;
         rtl_getAppCommandArg(0, &name.pData);
         auto const cppPathname = getPathnameArgument(1);
-        auto const jsPathname = getPathnameArgument(2);
+        auto const hppPathname = getPathnameArgument(2);
+        auto const jsPathname = getPathnameArgument(3);
         rtl::Reference<TypeManager> mgr(new TypeManager);
-        for (sal_uInt32 i = 3; i != args; ++i)
+        for (sal_uInt32 i = 4; i != args; ++i)
         {
             auto const & [ uri, primary ] = parseRegistryArgument(i);
             try
@@ -906,7 +907,7 @@ SAL_IMPLEMENT_MAIN()
                    << "::get);
";
             dumpRegisterFunctionEpilog(cppOut, n);
         }
-        cppOut << "EMSCRIPTEN_BINDINGS(unoembind_" << name << ") {
";
+        cppOut << "void init_unoembind_" << name << "() {
";
         for (unsigned long long i = 0; i != n; ++i)
         {
             cppOut << "    register" << i << "();
";
@@ -933,6 +934,19 @@ SAL_IMPLEMENT_MAIN()
             std::cerr << "Failed to write \"" << cppPathname << "\"
";
             std::exit(EXIT_FAILURE);
         }
+        std::ofstream hppOut(hppPathname, std::ios_base::out | 
std::ios_base::trunc);
+        if (!hppOut)
+        {
+            std::cerr << "Cannot open \"" << hppPathname << "\" for writing
";
+            std::exit(EXIT_FAILURE);
+        }
+        hppOut << "void init_unoembind_" << name << "();
";
+        hppOut.close();
+        if (!hppOut)
+        {
+            std::cerr << "Failed to write \"" << hppPathname << "\"
";
+            std::exit(EXIT_FAILURE);
+        }
         std::ofstream jsOut(jsPathname, std::ios_base::out | 
std::ios_base::trunc);
         if (!jsOut)
         {

Reply via email to