1 #include "dotnet/dotnet_launcher.h"
2 #include "mono/mono_launcher.h"
14 #define __STR(x) __XSTR(x)
17 #define LAUNCHER_VERSION_STR "-Unknown-"
19 #define LAUNCHER_VERSION_STR __STR(VERSION)
22 static std::string VersionOption("--version");
23 static std::string StandaloneOption("--standalone");
25 int main(int argc, char *argv[])
28 bool standalone = false;
29 const char* standalonePath = nullptr;
31 std::vector<char*> vargs;
33 for (i=1; i<argc; i++)
35 if (VersionOption.compare(argv[i]) == 0)
37 printf("Dotnet launcher Version %s\n", LAUNCHER_VERSION_STR);
40 else if (StandaloneOption.compare(argv[i]) == 0)
46 fprintf(stderr, "Assembly path must be after \"--standalone\" option\n");
50 standalonePath = argv[i];
54 vargs.push_back(argv[i]);
58 using tizen::runtime::LauncherInterface;
59 using tizen::runtime::Launchpad;
60 using tizen::runtime::AppInfo;
61 std::unique_ptr<LauncherInterface> runtime;
63 bool useMono = !FileNotExist("/etc/.use_mono");
67 using tizen::runtime::dotnetcore::CoreRuntime;
68 std::unique_ptr<LauncherInterface> coreRuntime(new CoreRuntime());
69 runtime = std::move(coreRuntime);
73 using tizen::runtime::mono::MonoRuntime;
74 std::unique_ptr<LauncherInterface> monoRuntime(new MonoRuntime());
75 runtime = std::move(monoRuntime);
80 std::string base = Basename(standalonePath);
81 if (runtime->Initialize(true) != 0)
83 _ERR("Failed to initialize");
86 if (runtime->RunManagedLauncher() != 0)
88 _ERR("Failed to run managed launcher");
92 int args_len = vargs.size();
93 char** args = &vargs[0];
94 if (!runtime->Launch(base.c_str(), standalonePath, args_len, args))
96 _ERR("Failed to launch");
102 Launchpad.OnCreate = [&runtime]
104 auto idle_task = [](void *data) -> Eina_Bool
106 LauncherInterface* runtime = static_cast<LauncherInterface*>(data);
107 if (runtime->RunManagedLauncher() != 0)
109 _ERR("Failed to run managed launcher");
111 return ECORE_CALLBACK_CANCEL;
113 if (runtime->Initialize(false) != 0)
115 _ERR("Failed to initialized");
118 ecore_idler_add(idle_task, runtime.get());
121 Launchpad.OnTerminate = [&runtime](const AppInfo& info, int argc, char** argv)
123 _DBG("terminated with app path : %s", info.path.c_str());
124 _DBG("appid : %s", info.id.c_str());
125 _DBG("pkg : %s", info.pkg.c_str());
126 _DBG("type : %s", info.type.c_str());
128 if (!runtime->Launch(info.root.c_str(), info.path.c_str(), argc, argv))
130 _ERR("Failed to launch");
133 Launchpad.LoaderMain(argc, argv);