1 #include "dotnet/dotnet_launcher.h"
2 #include "mono/mono_launcher.h"
15 #define __STR(x) __XSTR(x)
18 #define LAUNCHER_VERSION_STR "-Unknown-"
20 #define LAUNCHER_VERSION_STR __STR(VERSION)
23 static std::string VersionOption("--version");
24 static std::string StandaloneOption("--standalone");
26 int main(int argc, char *argv[])
29 bool standalone = false;
30 const char* standalonePath = nullptr;
32 std::vector<char*> vargs;
34 for (i=0; i<argc; i++)
36 if (VersionOption.compare(argv[i]) == 0)
38 printf("Dotnet launcher Version %s\n", LAUNCHER_VERSION_STR);
41 else if (StandaloneOption.compare(argv[i]) == 0)
47 fprintf(stderr, "Assembly path must be after \"--standalone\" option\n");
51 standalonePath = argv[i];
55 vargs.push_back(argv[i]);
59 using tizen::runtime::LauncherInterface;
60 using tizen::runtime::Launchpad;
61 using tizen::runtime::AppInfo;
62 std::unique_ptr<LauncherInterface> runtime;
64 bool useMono = !FileNotExist("/etc/.use_mono");
68 using tizen::runtime::dotnetcore::CoreRuntime;
69 std::unique_ptr<LauncherInterface> coreRuntime(new CoreRuntime());
70 runtime = std::move(coreRuntime);
72 _DBG("##### CoreCLR Launcher ######");
76 using tizen::runtime::mono::MonoRuntime;
77 std::unique_ptr<LauncherInterface> monoRuntime(new MonoRuntime());
78 runtime = std::move(monoRuntime);
80 _DBG("##### Mono Launcher ######");
85 _DBG("##### Run it standalone #########");
86 const char* appid = getenv("AUL_APPID");
87 _DBG("AUL_APPID : %s", appid);
91 const char* approot_path = aul_get_app_root_path();
92 if (approot_path != nullptr)
94 approot = std::string(approot_path);
99 approot = Basename(standalonePath);
101 if (runtime->Initialize(true) != 0)
103 _ERR("Failed to initialize");
107 int args_len = vargs.size();
108 char** args = &vargs[0];
109 if (runtime->Launch(approot.c_str(), standalonePath, args_len, args))
111 _ERR("Failed to launch");
117 Launchpad.OnCreate = [&runtime]()
119 if (runtime->Initialize(false) != 0)
121 _ERR("Failed to initialized");
125 auto idle_task = [](void *data) -> Eina_Bool
127 LauncherInterface* runtime = static_cast<LauncherInterface*>(data);
128 if (runtime->RunManagedLauncher() != 0)
130 _ERR("Failed to run managed launcher");
132 return ECORE_CALLBACK_CANCEL;
134 ecore_idler_add(idle_task, runtime.get());
138 Launchpad.OnTerminate = [&runtime](const AppInfo& info, int argc, char** argv)
140 _DBG("terminated with app path : %s", info.path.c_str());
141 _DBG("appid : %s", info.id.c_str());
142 _DBG("pkg : %s", info.pkg.c_str());
143 _DBG("type : %s", info.type.c_str());
145 if (runtime->Launch(info.root.c_str(), info.path.c_str(), argc, argv))
147 _ERR("Failed to launch");
150 Launchpad.LoaderMain(argc, argv);