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 #include +#if defined EMSCRIPTEN +#include +#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:\n\n" - " embindmaker \n\n" + " embindmaker \n\n" "where each is '+' (primary) or ':' (secondary), followed by: either a\n" "new- or legacy-format .rdb file, a single .idl file, or a root directory of an\n" ".idl file tree. For all primary registries, Embind code is written to\n" - " and corresponding JavaScript scaffolding code is written to\n" - ". The is used as part of some of the identifiers in those\n" - "generated files.\n"; + "/ and corresponding JavaScript scaffolding code is\n" + "written to . The is used as part of some of the identifiers\n" + "in those generated files.\n"; 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 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);\n"; dumpRegisterFunctionEpilog(cppOut, n); } - cppOut << "EMSCRIPTEN_BINDINGS(unoembind_" << name << ") {\n"; + cppOut << "void init_unoembind_" << name << "() {\n"; for (unsigned long long i = 0; i != n; ++i) { cppOut << " register" << i << "();\n"; @@ -933,6 +934,19 @@ SAL_IMPLEMENT_MAIN() std::cerr << "Failed to write \"" << cppPathname << "\"\n"; 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\n"; + std::exit(EXIT_FAILURE); + } + hppOut << "void init_unoembind_" << name << "();\n"; + hppOut.close(); + if (!hppOut) + { + std::cerr << "Failed to write \"" << hppPathname << "\"\n"; + std::exit(EXIT_FAILURE); + } std::ofstream jsOut(jsPathname, std::ios_base::out | std::ios_base::trunc); if (!jsOut) {