support corerun mode
authorWoongsuk Cho <ws77.cho@samsung.com>
Fri, 10 Aug 2018 01:15:09 +0000 (10:15 +0900)
committer조웅석/Tizen Platform Lab(SR)/Staff Engineer/삼성전자 <ws77.cho@samsung.com>
Thu, 6 Sep 2018 01:22:00 +0000 (10:22 +0900)
Change-Id: Ieed7de4eeec2238e02191c4669bd28aa15bde1c1

NativeLauncher/launcher/main.cc

index e62e42e..9f64ebc 100644 (file)
@@ -35,15 +35,16 @@ static std::string StandaloneOption("--standalone");
 extern "C" int realMain(int argc, char *argv[], const char* mode)
 {
        int i;
-       bool standalone = false;
+       bool standaloneMode = false;
        char* standalonePath = nullptr;
+       bool corerunMode = false;
 
        std::vector<char*> vargs;
 
        // start index 1 to avoid passing executable name "dotnet-launcher" as a parameter
        for (i = 1; i < argc; i++) {
                if (StandaloneOption.compare(argv[i]) == 0) {
-                       standalone = true;
+                       standaloneMode = true;
 
                        if (i > argc-1) {
                                fprintf(stderr, "Assembly path must be after \"--standalone\" option\n");
@@ -56,14 +57,36 @@ extern "C" int realMain(int argc, char *argv[], const char* mode)
                }
        }
 
+       if (isManagedAssembly(argv[1]) || isNativeImage(argv[1])) {
+               corerunMode = true;
+       }
+
        using tizen::runtime::Launchpad;
        using tizen::runtime::AppInfo;
        using tizen::runtime::dotnetcore::CoreRuntime;
 
        std::unique_ptr<CoreRuntime> runtime(new CoreRuntime(mode));
 
-       if (standalone) {
-               _INFO("##### Run it standalone #########");
+       if (corerunMode) {
+               _INFO("##### Run it corerun Mode #########");
+               char appId[1024] = {0,};
+               std::string appRoot;
+               snprintf(appId, 16, "%s", "dotnet-launcher");
+               appRoot = baseName(argv[1]);
+
+               if (runtime->initialize(true) != 0) {
+                       _ERR("Failed to initialize");
+                       return 1;
+               }
+
+               int argsLen = vargs.size();
+               char** args = &vargs[0];
+               if (runtime->launch(appId, appRoot.c_str(), argv[1], argsLen, args)) {
+                       _ERR("Failed to launch");
+                       return 1;
+               }
+       } else if (standaloneMode) {
+               _INFO("##### Run it standalone Mode #########");
                char appId[1024] = {0,};
                std::string appRoot;
                if (AUL_R_OK == aul_app_get_appid_bypid(getpid(), appId, sizeof(appId))) {