Skip to content

Commit

Permalink
Share the Kit environment setup code.
Browse files Browse the repository at this point in the history
Particularly configuration layers so we can tweak mobile config
easily.

Add core source files from configmgr for breakpointing convenience in
the iOS project. Add loolkitconfig.xcu to the iOS app bundle. Use
${BRAND_BASE_DIR} instead of a compile-time LOOLWSD_CONFIGDIR literal
on iOS (because there is no compile-time constant path to the app
bundle). No "registry" directory directly in the app bundle any longer
on iOS, a corresponding change in core.git moved that stuff to be
under "share", like on other platforms.

Change-Id: I6672efc0505abf27297c4758118a20992b10ceb3
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/88765
Tested-by: Michael Meeks <[email protected]>
Reviewed-by: Michael Meeks <[email protected]>
  • Loading branch information
mmeeks committed Feb 17, 2020
1 parent 8c9e539 commit 6bdf561
Show file tree
Hide file tree
Showing 7 changed files with 206 additions and 33 deletions.
2 changes: 1 addition & 1 deletion android/lib/src/main/cpp/androidapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ JNI_OnLoad(JavaVM* vm, void*) {
return JNI_ERR; // JNI version not supported.
}

setenv("SAL_LOK_OPTIONS", "unipoll", 0);
setupKitEnvironment();

// Uncomment the following to see the logs from the core too
//setenv("SAL_LOG", "+WARN+INFO", 0);
Expand Down
158 changes: 154 additions & 4 deletions ios/Mobile.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion ios/Mobile/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#import "Document.h"

#import "FakeSocket.hpp"
#import "Kit.hpp"
#import "Log.hpp"
#import "LOOLWSD.hpp"
#import "Util.hpp"
Expand Down Expand Up @@ -187,7 +188,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
if (!trace)
trace = strdup("warning");

setenv("SAL_LOK_OPTIONS", "unipoll", 0);
setupKitEnvironment();

Log::initialize("Mobile", trace, false, false, {});
Util::setThreadName("main");
Expand Down
27 changes: 1 addition & 26 deletions kit/ForKit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,25 +489,7 @@ int main(int argc, char** argv)
return EX_USAGE;
}

// Setup & check environment
const std::string layers(
"xcsxcu:${BRAND_BASE_DIR}/share/registry "
"res:${BRAND_BASE_DIR}/share/registry "
"bundledext:${${BRAND_BASE_DIR}/program/lounorc:BUNDLED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
"sharedext:${${BRAND_BASE_DIR}/program/lounorc:SHARED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
"userext:${${BRAND_BASE_DIR}/program/lounorc:UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
#if ENABLE_DEBUG // '*' denotes non-writable.
"user:*file://" DEBUG_ABSSRCDIR "/loolkitconfig.xcu "
#else
"user:*file://" LOOLWSD_CONFIGDIR "/loolkitconfig.xcu "
#endif
);

// No-caps tracing can spawn eg. glxinfo & other oddness.
unsetenv("DISPLAY");

::setenv("CONFIGURATION_LAYERS", layers.c_str(),
1 /* override */);
setupKitEnvironment();

if (!std::getenv("LD_BIND_NOW")) // must be set by parent.
LOG_INF("Note: LD_BIND_NOW is not set.");
Expand All @@ -520,13 +502,6 @@ int main(int argc, char** argv)
return EX_SOFTWARE;
}

// Set various options we need.
std::string options = "unipoll";
if (Log::logger().trace())
options += ":profile_events";
// options += ":sc_no_grid_bg"; // leave ths disabled for now, merged-cells needs more work.
::setenv("SAL_LOK_OPTIONS", options.c_str(), 0);

// Initialize LoKit
if (!globalPreinit(loTemplate))
{
Expand Down
40 changes: 40 additions & 0 deletions kit/Kit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2292,6 +2292,43 @@ void wakeCallback(void* pData)
return reinterpret_cast<KitSocketPoll*>(pData)->wakeup();
}

void setupKitEnvironment()
{
// Setup & check environment
const std::string layers(
"xcsxcu:${BRAND_BASE_DIR}/share/registry "
"res:${BRAND_BASE_DIR}/share/registry "
"bundledext:${${BRAND_BASE_DIR}/program/lounorc:BUNDLED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
"sharedext:${${BRAND_BASE_DIR}/program/lounorc:SHARED_EXTENSIONS_USER}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
"userext:${${BRAND_BASE_DIR}/program/lounorc:UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini "
#ifdef IOS
"user:*${BRAND_BASE_DIR}/loolkitconfig.xcu "
#else
#if ENABLE_DEBUG // '*' denotes non-writable.
"user:*file://" DEBUG_ABSSRCDIR "/loolkitconfig.xcu "
#else
"user:*file://" LOOLWSD_CONFIGDIR "/loolkitconfig.xcu "
#endif
#endif
);
::setenv("CONFIGURATION_LAYERS", layers.c_str(),
1 /* override */);

#if !MOBILEAPP
// No-caps tracing can spawn eg. glxinfo & other oddness.
unsetenv("DISPLAY");
#endif

// Set various options we need.
std::string options = "unipoll";
#if !MOBILEAPP
if (Log::logger().trace())
options += ":profile_events";
#endif
// options += ":sc_no_grid_bg"; // leave this disabled for now, merged-cells needs more work.
::setenv("SAL_LOK_OPTIONS", options.c_str(), 0);
}

#ifndef BUILDING_TESTS

void lokit_main(
Expand Down Expand Up @@ -2570,6 +2607,9 @@ void lokit_main(

#else // MOBILEAPP

// was not done by the preload
setupKitEnvironment();

#if defined(__linux) && !defined(__ANDROID__)
Poco::URI userInstallationURI("file", LO_PATH);
LibreOfficeKit *kit = lok_init_2(LO_PATH "/program", userInstallationURI.toString().c_str());
Expand Down
3 changes: 3 additions & 0 deletions kit/Kit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ void lokit_main(
size_t spareKitId
);

/// We need to get several env. vars right
void setupKitEnvironment();

bool globalPreinit(const std::string& loTemplate);
/// Wrapper around private Document::ViewCallback().
void documentViewCallback(const int type, const char* p, void* data);
Expand Down
6 changes: 5 additions & 1 deletion test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ check_PROGRAMS = fakesockettest
noinst_PROGRAMS = fakesockettest unittest

AM_CXXFLAGS = $(CPPUNIT_CFLAGS) -DTDOC=\"$(abs_top_srcdir)/test/data\" \
-I${top_srcdir}/common -I${top_srcdir}/net -I${top_srcdir}/wsd -I${top_srcdir}/kit
-I${top_srcdir}/common -I${top_srcdir}/net -I${top_srcdir}/wsd -I${top_srcdir}/kit \
-pthread -DLOOLWSD_DATADIR='"@LOOLWSD_DATADIR@"' \
-DLOOLWSD_CONFIGDIR='"@LOOLWSD_CONFIGDIR@"' \
-DDEBUG_ABSSRCDIR='"@abs_srcdir@"' \
${include_paths}

noinst_LTLIBRARIES = \
unit-base.la unit-tiletest.la \
Expand Down

0 comments on commit 6bdf561

Please sign in to comment.