#include "launcher.h"
#include "dotnet_launcher.h"
+#define PLUGIN_PATH "/usr/share/dotnet.tizen/lib/libdotnet_plugin.so"
+
namespace tizen {
namespace runtime {
namespace dotnetcore {
__hostHandle(nullptr),
__domainId(-1),
preparedFunction(nullptr),
- launchFunction(nullptr)
+ launchFunction(nullptr),
+ __pluginLib(nullptr),
+ pluginInitialize(nullptr),
+ pluginPreload(nullptr),
+ pluginSetAppInfo(nullptr),
+ pluginGetDllPath(nullptr),
+ pluginBeforeExecute(nullptr),
+ pluginFinalize(nullptr)
{
#define __XSTR(x) #x
#define __STR(x) __XSTR(x)
#undef __STR
#undef __XSTR
+ // support launcher plugin
+ if (!fileNotExist(PLUGIN_PATH)) {
+ __pluginLib = dlopen(PLUGIN_PATH, RTLD_NOW | RTLD_LOCAL);
+ if (__pluginLib) {
+ pluginInitialize = (plugin_initialize_ptr)dlsym(__pluginLib, "plugin_initialize");
+ pluginPreload = (plugin_preload_ptr)dlsym(__pluginLib, "plugin_preload");
+ pluginSetAppInfo = (plugin_set_app_info_ptr)dlsym(__pluginLib, "plugin_set_app_info");
+ pluginGetDllPath = (plugin_get_dll_path_ptr)dlsym(__pluginLib, "plugin_get_dll_path");
+ pluginBeforeExecute = (plugin_before_execute_ptr)dlsym(__pluginLib, "plugin_before_execute");
+ pluginFinalize = (plugin_finalize_ptr)dlsym(__pluginLib, "plugin_finalize");
+ }
+ }
+
+ if (pluginInitialize)
+ pluginInitialize();
+
_DBG("Constructor called!!");
}
_DBG("this addr : %x", this);
_DBG("coreclr_initialize : %x", initializeClr);
+ if (!standalone && pluginPreload)
+ pluginPreload();
+
return 0;
}
__coreclrLib = nullptr;
+ if (pluginFinalize)
+ pluginFinalize();
+
+ if (__pluginLib != nullptr) {
+ if (dlclose(__pluginLib) != 0)
+ _ERR("libdotnet_plugin.so close failed");
+
+ __pluginLib = nullptr;
+ pluginInitialize = nullptr;
+ pluginPreload = nullptr;
+ pluginSetAppInfo = nullptr;
+ pluginGetDllPath = nullptr;
+ pluginBeforeExecute = nullptr;
+ pluginFinalize = nullptr;
+ }
+
_DBG("Dotnet runtime disposed");
}
return 1;
}
+ if (pluginSetAppInfo)
+ pluginSetAppInfo(appId, path);
+
std::string tpa;
std::string appRoot = root;
std::string appBin = concatPath(appRoot, "bin");
std::vector<std::string> searchDirectories;
searchDirectories.push_back(appBin);
searchDirectories.push_back(appLib);
+ if (pluginGetDllPath) {
+ std::string pluginPath = pluginGetDllPath();
+ if (!pluginPath.empty()) {
+ probePath = probePath + ":" + pluginPath;
+ searchDirectories.push_back(pluginPath);
+ }
+ }
searchDirectories.push_back(__runtimeDirectory);
searchDirectories.push_back(__deviceAPIDirectory);
searchDirectories.push_back(__refAPIDirectory);
assembliesInDirectory(searchDirectories, tpa);
+ if (pluginBeforeExecute)
+ pluginBeforeExecute();
+
#ifdef USE_MANAGED_LAUNCHER
runManagedLauncher(appId, probePath.c_str(), tpa.c_str());
const char* entryPointTypeName,
const char* entryPointMethodName,
void** delegate);
+
+ typedef void (*plugin_initialize_ptr)();
+
+ typedef void (*plugin_preload_ptr)();
+
+ typedef void (*plugin_set_app_info_ptr)(
+ const char* appId,
+ const char* hostHandle);
+
+ typedef char* (*plugin_get_dll_path_ptr)();
+
+ typedef void (*plugin_before_execute_ptr)();
+
+ typedef void (*plugin_finalize_ptr)();
}
namespace tizen {
unsigned int __domainId;
PreparedFunctionPtr preparedFunction;
LaunchFunctionPtr launchFunction;
+ // plugin function pointer
+ void* __pluginLib;
+ plugin_initialize_ptr pluginInitialize;
+ plugin_preload_ptr pluginPreload;
+ plugin_set_app_info_ptr pluginSetAppInfo;
+ plugin_get_dll_path_ptr pluginGetDllPath;
+ plugin_before_execute_ptr pluginBeforeExecute;
+ plugin_finalize_ptr pluginFinalize;
};
} // dotnetcore