* limitations under the License.
*/
-#include "dotnet_launcher.h"
+#include "core_runtime.h"
#include "utils.h"
#include "log.h"
#include <vector>
#include <memory>
-#include <Ecore.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/prctl.h>
+#include <glib.h>
+#include <glib-unix.h>
+
#include <launchpad.h>
#include <aul.h>
using tizen::runtime::dotnetcore::CoreRuntime;
-static Ecore_Fd_Handler *__fd_handler;
+static const char* KEY_APP_TYPE = "--appType";
+static const char* KEY_TIZEN_UIFW = "TIZEN_UIFW";
+static const char* KEY_PROFILE = "--profile";
+
+static guint __fd_handler;
static loader_receiver_cb __receiver;
// To precreate window(EFL/DALI), argc and argv should be passed.
} AppInfo;
static AppInfo __appInfo;
+// Collect/use multicorejit profile or not
+static bool profile;
+
+namespace {
+GMainLoop* __loop = nullptr;
+} // namespace
//################## Code for running event loop for loader ####################
-static Eina_Bool __process_fd_handler(void *data, Ecore_Fd_Handler *handler)
+static gboolean __process_fd_handler(int fd, GIOCondition condition, gpointer user_data)
{
- int fd;
-
- fd = ecore_main_fd_handler_fd_get(handler);
- if (fd == -1) {
- _ERR("[candidate] ECORE_FD_GET");
- exit(-1);
- }
-
- if (ecore_main_fd_handler_active_get(handler, ECORE_FD_READ)) {
- if (__receiver)
+ if (condition & G_IO_IN) {
+ if (__receiver) {
__receiver(fd);
- } else if (ecore_main_fd_handler_active_get(handler, ECORE_FD_ERROR)) {
- _ERR("[candidate] ECORE_FD_ERROR");
+ }
+ } else if (condition & (G_IO_HUP | G_IO_ERR)) {
+ _ERR("[candidate] error condition: %d", static_cast<int>(condition));
close(fd);
exit(-1);
}
- return ECORE_CALLBACK_CANCEL;
+ return G_SOURCE_REMOVE;
}
static void __adapter_loop_begin(void *user_data)
{
- ecore_main_loop_begin();
+ __loop = g_main_loop_new(nullptr, FALSE);
+ g_main_loop_run(__loop);
}
static void __adapter_loop_quit(void *user_data)
{
- ecore_main_loop_quit();
+ if (__loop != nullptr) {
+ g_main_loop_quit(__loop);
+ g_main_loop_unref(__loop);
+ __loop = nullptr;
+ }
}
-static void __adapter_add_fd(void *user_data, int fd,
- loader_receiver_cb receiver)
+static void __adapter_add_fd(void *user_data, int fd, loader_receiver_cb receiver)
{
- __fd_handler = ecore_main_fd_handler_add(fd,
- static_cast<Ecore_Fd_Handler_Flags>(ECORE_FD_READ | ECORE_FD_ERROR),
- __process_fd_handler, NULL, NULL, NULL);
-
- if (__fd_handler == NULL) {
+ __fd_handler = g_unix_fd_add(fd,
+ static_cast<GIOCondition>(G_IO_IN | G_IO_HUP | G_IO_ERR), __process_fd_handler, nullptr);
+ if (__fd_handler == 0) {
_ERR("fd_handler is NULL");
close(fd);
exit(-1);
static void __adapter_remove_fd(void *user_data, int fd)
{
- if (__fd_handler) {
- ecore_main_fd_handler_del(__fd_handler);
- __fd_handler = NULL;
+ if (__fd_handler != 0) {
+ g_source_remove(__fd_handler);
+ __fd_handler = 0;
__receiver = NULL;
}
}
static void __loader_create_cb(bundle *extra, int type, void *user_data)
{
- CoreRuntime* runtime = (CoreRuntime*)user_data;
+ char *appType = NULL;
+ if (bundle_get_str(extra, KEY_APP_TYPE, &appType) != BUNDLE_ERROR_NONE) {
+ appType = NULL;
+ }
- {
- // do native window precreation here
+ char *uifw = NULL;
+ bundle_get_str(extra, KEY_TIZEN_UIFW, &uifw);
+ if (uifw != NULL) {
+ setenv(KEY_TIZEN_UIFW, uifw, 1);
+ _INFO("TIZEN_UIFW is set to %s", uifw);
+ }
+
+ char *profile_str = NULL;
+ profile = false;
+ bundle_get_str(extra, KEY_PROFILE, &profile_str);
+ if (profile_str != NULL) {
+ if (!strcmp(profile_str, "true")) {
+ profile = true;
+ } else if (!strcmp(profile_str, "false")) {
+ profile = false;
+ } else {
+ _DBG("PROFILE value %s not recognized. Valid values: true, false. Turn off PROFILE mode as default", profile_str);
+ }
+ }
+
+ char *ui_thread = nullptr;
+ bundle_get_str(extra, "TIZEN_UI_THREAD", &ui_thread);
+ if (ui_thread != nullptr && !strcmp(ui_thread, "true")) {
+ setenv("TIZEN_UI_THREAD", "true", 1);
+ _INFO("TIZEN_UI_THREAD is set");
}
// initialize CoreRuntime (launchmode, dlog redirection enable, root path NULL)
- if (runtime->initialize(LaunchMode::loader) != 0) {
+ if (CoreRuntime::initialize(appType ? appType : "dotnet", LaunchMode::loader) != 0) {
_ERR("Failed to initialized");
} else {
_INFO("Success to initialized");
static int __loader_terminate_cb(int argc, char **argv, void *user_data)
{
- CoreRuntime* runtime = (CoreRuntime*)user_data;
-
_INFO("launch request with app path : %s", __appInfo.app_path.c_str());
// The launchpad pass the name of exe file to the first argument.
// For the C# spec, we have to skip this first argument.
- if (runtime->launch(__appInfo.appid.c_str(), __appInfo.root.c_str(),
- __appInfo.app_path.c_str(), argc - 1, argv + 1)) {
+ if (CoreRuntime::launch(__appInfo.appid.c_str(), __appInfo.root.c_str(),
+ __appInfo.app_path.c_str(), argc - 1, argv + 1, profile)) {
_ERR("Failed to launch");
+ return -1;
}
return 0;
//################## Main Code #################################################
-extern "C" int realMain(int argc, char *argv[], const char* mode)
+extern "C" int realMain(int argc, char *argv[])
{
_INFO("##### Run in candidate mode #####");
- CoreRuntime* runtime = new CoreRuntime(mode);
-
// change cmdline from dotnet-hydra-loader to dotnet-loader
if (strcmp(argv[0], "/usr/bin/dotnet-hydra-loader") == 0) {
memset(argv[0], '\0', strlen("/usr/bin/dotnet-hydra-loader"));
"/usr/bin/dotnet-loader");
}
- setCmdName("dotnet-loader");
-
loader_lifecycle_callback_s callbacks = {
.create = __loader_create_cb,
.launch = __loader_launch_cb,
.remove_fd = __adapter_remove_fd
};
- int ret = launchpad_loader_main(argc, argv, &callbacks, &adapter, runtime);
- delete runtime;
+ int ret = launchpad_loader_main(argc, argv, &callbacks, &adapter, NULL);
+
+ CoreRuntime::finalize();
return ret;
}
__argc = argc;
__argv = argv;
- return realMain(argc, argv, "candidate");
+ return realMain(argc, argv);
}
-