Merge branch 'tizen' of https://github.sec.samsung.net/j-h-choi/dotnet-launcher into...
authorj-h.choi <j-h.choi@samsung.com>
Tue, 11 Jun 2019 09:14:14 +0000 (18:14 +0900)
committerj-h.choi <j-h.choi@samsung.com>
Tue, 11 Jun 2019 09:14:14 +0000 (18:14 +0900)
NativeLauncher/inc/launcher_env.h [new file with mode: 0644]
NativeLauncher/inc/ni_common.h
NativeLauncher/inc/utils.h
NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc
NativeLauncher/launcher/dotnet/dotnet_launcher.cc
NativeLauncher/launcher/dotnet/dotnet_launcher.h
NativeLauncher/tool/ni_common.cc
NativeLauncher/tool/nitool.cc
NativeLauncher/util/plugin_manager.cc
packaging/dotnet-launcher.spec

diff --git a/NativeLauncher/inc/launcher_env.h b/NativeLauncher/inc/launcher_env.h
new file mode 100644 (file)
index 0000000..55f600d
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LAUNCHER_ENV_H_
+#define __LAUNCHER_ENV_H_
+
+#define PLUGIN_PATH         "/usr/share/dotnet.tizen/lib/libdotnet_plugin.so"
+#define ENV_FILE_PATH       "/usr/share/dotnet.tizen/lib/coreclr_env.list"
+#define AOT_METADATA_KEY    "http://tizen.org/metadata/prefer_dotnet_aot"
+#define AOT_METADATA_VALUE  "true"
+#define APP_NI_SUB_DIR      "/.native_image"
+
+#endif //__LAUNCHER_ENV_H_
\ No newline at end of file
index b36282f..3f3de82 100644 (file)
 
 typedef std::function<void (std::string)> afterCreate;
 
+typedef enum {
+       NI_ERROR_NONE = 0,
+       NI_ERROR_INVALID_PARAMETER = -1,
+       NI_ERROR_ALREADY_EXIST = -2,
+       NI_ERROR_NO_SUCH_FILE = -3,
+       NI_ERROR_INVALID_PACKAGE = -4,
+       NI_ERROR_NOT_SUPPORTED = -5,
+       NI_ERROR_UNKNOWN = -9
+} ni_error_e;
+
 /**
  * @brief : structure which contains directory info
  */
@@ -33,9 +43,9 @@ typedef struct NiCommonOption {
 /**
  * @brief initialize NICommon
  * @param[in] options to initialize path
- * @return 0 on success, otherwise a negative error value
+ * @return ni_error_e 0 on success, otherwise a negative error value
  */
-int initNICommon(NiCommonOption* option);
+ni_error_e initNICommon(NiCommonOption* option);
 
 /**
  * @brief finalize NICommon
@@ -52,34 +62,35 @@ void createNiPlatform(bool enableR2R);
  * @brief create native image for specific dll with file path.
  * @param[i] dllPath file path to generate native image
  * @param[i] enableR2R enable ready-to-run mode
- * @return 0 on success, otherwise a negative error value
+ * @return ni_error_e
  */
-int createNiDll(const std::string& dllPath, bool enableR2R);
+ni_error_e createNiDll(const std::string& dllPath, bool enableR2R);
 
 /**
  * @brief create native images with files under specific directory.
  * @param[i] rootPaths directories whicn contains DLLs
  * @param[i] count number of rootPath
  * @param[i] enableR2R enable ready-to-run mode
+ * @param[i] isAppNI if you want to create ni files under nativeImage directory, set it true
  */
-void createNiUnderDirs(const std::string rootPaths[], int count, bool enableR2R);
+void createNiUnderDirs(const std::string rootPaths[], int count, bool enableR2R, bool isAppNI = false);
 
 /**
  * @brief create native images for specific package. (All DLLs)
  * @param[i] pkgId package ID
  * @param[i] enableR2R enable ready-to-run mode
- * @return 0 on success, otherwise a negative error value
+ * @return ni_error_e
  */
-int createNiUnderPkgRoot(const std::string& pkgId, bool enableR2R);
+ni_error_e createNiUnderPkgRoot(const std::string& pkgId, bool enableR2R);
 
 /**
  * @brief create native image for specific dll in the package.
  * @Details All dlls in the package are added for reference when create native image.
  * @param[i] pkgId package ID
  * @param[i] enableR2R enable ready-to-run mode
- * @return 0 on success, otherwise a negative error value
+ * @return ni_error_e
  */
-int createNiDllUnderPkgRoot(const std::string& pkgId, const std::string& dllPath, bool enableR2R);
+ni_error_e createNiDllUnderPkgRoot(const std::string& pkgId, const std::string& dllPath, bool enableR2R);
 
 /**
  * @brief remove native images (NI file) for Platform DLLs (.NETCore + TizenFX)
@@ -96,13 +107,14 @@ void removeNiUnderDirs(const std::string rootPaths[], int count);
 /**
  * @brief remove native images for specific package.
  * @param[i] pkgId package ID
- * @return 0 on success, otherwise a negative error value
+ * @return ni_error_e
  */
-int removeNiUnderPkgRoot(const std::string& pkgId);
+ni_error_e removeNiUnderPkgRoot(const std::string& pkgId);
 
 /**
  * @brief regenerate native image for all installed application
+ * @return ni_error_e
  */
-int regenerateAppNI(bool enableR2R = true);
+ni_error_e regenerateAppNI(bool enableR2R = true);
 
 #endif /* __NI_COMMON_H__ */
index 9a4aced..bb72e00 100644 (file)
@@ -22,6 +22,8 @@
 #include <functional>
 #include <boost/filesystem.hpp>
 
+#include <launcher_env.h>
+
 #ifndef PATH_SEPARATOR
 #define PATH_SEPARATOR '/'
 #endif
index 45f22b9..ffed938 100644 (file)
@@ -33,8 +33,6 @@ typedef struct Metadata {
        const char *value;
 } Metadata;
 
-const std::string valueType = "true";
-const std::string mdKey = "http://tizen.org/metadata/prefer_dotnet_aot";
 extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *appId, GList *list)
 {
        GList *tag = NULL;
@@ -43,7 +41,7 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *app
        tag = g_list_first(list);
        while (tag) {
                mdInfo = (Metadata*)tag->data;
-               if (mdInfo->key == mdKey && mdInfo->value == valueType) {
+               if (strcmp(mdInfo->key, AOT_METADATA_KEY) == 0 && strcmp(mdInfo->value, AOT_METADATA_VALUE) == 0) {
                        _DBG("Prefer dotnet application AOT set TRUE");
                        mdValue = true;
                }
index 2d10210..838a5e6 100644 (file)
@@ -45,9 +45,6 @@
 #include "path_manager.h"
 #include "log_manager.h"
 
-#define PLUGIN_PATH "/usr/share/dotnet.tizen/lib/libdotnet_plugin.so"
-#define ENV_FILE_PATH "/usr/share/dotnet.tizen/lib/coreclr_env.list"
-
 namespace tizen {
 namespace runtime {
 namespace dotnetcore {
@@ -393,12 +390,12 @@ int CoreRuntime::initialize(bool standalone)
        std::string appBin = concatPath(appRoot, "bin");
        std::string appLib = concatPath(appRoot, "lib");
        std::string appTAC = concatPath(appBin, ".TAC.Release");
-       std::string probePath = appBin + ":" + appLib + ":" + appTAC;
+       std::string NIprobePath = appBin + APP_NI_SUB_DIR + ":" + appLib + APP_NI_SUB_DIR + ":" + appTAC;
        std::string tpa = getTPA();
        std::string nativeLibPath = getExtraNativeLibDirs(appRoot) + ":" + appBin + ":" + appLib + ":" + __nativeLibDirectory;
        std::string appName = std::string("dotnet-launcher-") + std::to_string(getpid());
 
-       if (!initializeCoreClr(appName.c_str(), probePath.c_str(), nativeLibPath.c_str(), tpa.c_str())) {
+       if (!initializeCoreClr(appName.c_str(), probePath.c_str(), NIprobePath.c_str(), nativeLibPath.c_str(), tpa.c_str())) {
                _ERR("Failed to initialize coreclr");
                return -1;
        }
@@ -417,6 +414,7 @@ int CoreRuntime::initialize(bool standalone)
 
 bool CoreRuntime::initializeCoreClr(const char* appId,
                                                                         const char* assemblyProbePaths,
+                                                                        const char* NIProbePaths,
                                                                         const char* pinvokeProbePaths,
                                                                         const char* tpaList)
 {
@@ -431,7 +429,7 @@ bool CoreRuntime::initializeCoreClr(const char* appId,
        const char *propertyValues[] = {
                tpaList,
                assemblyProbePaths,
-               assemblyProbePaths,
+               NIProbePaths,
                pinvokeProbePaths,
                "UseLatestBehaviorWhenTFMNotSpecified"
        };
index e230914..e9e6c5d 100644 (file)
@@ -35,7 +35,8 @@ class CoreRuntime
                int launch(const char* appId, const char* root, const char* path, int argc, char* argv[]);
 
        private:
-               bool initializeCoreClr(const char* appId, const char* assemblyProbePaths, const char* pinvokeProbePaths, const char* tpaList);
+
+               bool initializeCoreClr(const char* appId, const char* assemblyProbePaths, const char* NIProbePaths, const char* pinvokeProbePaths, const char* tpaList);
                void preloadTypes();
                coreclr_initialize_ptr initializeClr;
                coreclr_execute_assembly_ptr executeAssembly;
index 3811e97..d2b7ec3 100644 (file)
@@ -69,7 +69,27 @@ static void waitInterval()
        }
 }
 
-static std::string getNiFileName(const std::string& dllPath)
+static void updateNiFileInfo(const std::string& dllPath, const std::string& niPath)
+{
+       char* label = NULL;
+
+       // change smack label
+       if (smack_getlabel(dllPath.c_str(), &label, SMACK_LABEL_ACCESS) == 0) {
+               if (smack_setlabel(niPath.c_str(), label, SMACK_LABEL_ACCESS) < 0) {
+                       fprintf(stderr, "Fail to set smack label\n");
+               }
+               free(label);
+       }
+
+       // change owner and groups for generated ni file.
+       struct stat info;
+       if (!stat(dllPath.c_str(), &info)) {
+               if (chown(niPath.c_str(), info.st_uid, info.st_gid) == -1)
+                       fprintf(stderr, "Failed to change owner and group name\n");
+       }
+}
+
+static std::string getNiFilePath(const std::string& dllPath)
 {
        size_t index = dllPath.find_last_of(".");
        if (index == std::string::npos) {
@@ -86,9 +106,32 @@ static std::string getNiFileName(const std::string& dllPath)
        return niPath;
 }
 
+static std::string getAppNIPath(const std::string& niPath)
+{
+       size_t index = niPath.find_last_of("/");
+       if (index == std::string::npos) {
+               fprintf(stderr, "dllPath doesnot contains path info\n");
+               return "";
+       }
+
+       std::string prevPath = niPath.substr(0, index);
+       std::string fileName = niPath.substr(index, niPath.length());
+       std::string niDirPath = prevPath + APP_NI_SUB_DIR;
+
+       if (!isFileExist(niDirPath)) {
+               if (mkdir(niDirPath.c_str(), 0755) == 0) {
+                       updateNiFileInfo(prevPath, niDirPath);
+               } else {
+                       fprintf(stderr, "Fail to create app ni directory (%s)\n", niDirPath.c_str());
+               }
+       }
+
+       return niDirPath + fileName;
+}
+
 static bool niExist(const std::string& path)
 {
-       std::string f = getNiFileName(path);
+       std::string f = getNiFilePath(path);
        if (f.empty()) {
                return false;
        }
@@ -109,53 +152,37 @@ static bool niExist(const std::string& path)
        return false;
 }
 
-static void updateNiFileInfo(const std::string& dllPath, const std::string& niPath)
-{
-       char* label = NULL;
-
-       // change smack label
-       if (smack_getlabel(dllPath.c_str(), &label, SMACK_LABEL_ACCESS) == 0) {
-               if (smack_setlabel(niPath.c_str(), label, SMACK_LABEL_ACCESS) < 0) {
-                       fprintf(stderr, "Fail to set smack label\n");
-               }
-               free(label);
-       }
-
-       // change owner and groups for generated ni file.
-       struct stat info;
-       if (!stat(dllPath.c_str(), &info)) {
-               if (chown(niPath.c_str(), info.st_uid, info.st_gid) == -1)
-                       fprintf(stderr, "Failed to change owner and group name\n");
-       }
-}
-
-static int crossgen(const std::string& dllPath, const std::string& appPath, bool enableR2R)
+static ni_error_e crossgen(const std::string& dllPath, const std::string& appPath, bool enableR2R, bool isAppNI = false)
 {
        if (!isFileExist(dllPath)) {
                fprintf(stderr, "dll file is not exist : %s\n", dllPath.c_str());
-               return -1;
+               return NI_ERROR_NO_SUCH_FILE;
        }
 
        if (!isManagedAssembly(dllPath)) {
                fprintf(stderr, "Input file is not a dll file : %s\n", dllPath.c_str());
-               return -1;
+               return NI_ERROR_INVALID_PARAMETER;
        }
 
        if (niExist(dllPath)) {
                fprintf(stderr, "Already ni file is exist for %s\n", dllPath.c_str());
-               return -1;
+               return NI_ERROR_ALREADY_EXIST;
        }
 
        std::string absDllPath = absolutePath(dllPath);
-       std::string absNiPath = getNiFileName(dllPath);
+       std::string absNiPath = getNiFilePath(dllPath);
        if (absNiPath.empty()) {
                fprintf(stderr, "Fail to get ni file name\n");
-               return -1;
+               return NI_ERROR_UNKNOWN;
+       }
+
+       if (isAppNI) {
+               absNiPath = getAppNIPath(absNiPath);
        }
 
        pid_t pid = fork();
        if (pid == -1)
-               return -1;
+               return NI_ERROR_UNKNOWN;
 
        if (pid > 0) {
                int status;
@@ -165,10 +192,10 @@ static int crossgen(const std::string& dllPath, const std::string& appPath, bool
                        // niEixst() return false for System.Private.Corelib.dll
                        if (isFileExist(absNiPath)) {
                                updateNiFileInfo(absDllPath, absNiPath);
-                               return 0;
+                               return NI_ERROR_NONE;
                        } else {
                                fprintf(stderr, "Fail to create native image for %s\n", dllPath.c_str());
-                               return -1;
+                               return NI_ERROR_NO_SUCH_FILE;
                        }
                }
        } else {
@@ -205,9 +232,44 @@ static int crossgen(const std::string& dllPath, const std::string& appPath, bool
                exit(0);
        }
 
-       return 0;
+       return NI_ERROR_NONE;
 }
 
+static ni_error_e getRootPath(std::string pkgId, std::string& rootPath)
+{
+       int ret = 0;
+       char *path = 0;
+
+       uid_t uid = 0;
+
+       if (pkgmgr_installer_info_get_target_uid(&uid) < 0) {
+               _ERR("Failed to get UID");
+               return NI_ERROR_UNKNOWN;
+       }
+
+       pkgmgrinfo_pkginfo_h handle;
+       if (uid == 0) {
+               ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgId.c_str(), &handle);
+               if (ret != PMINFO_R_OK)
+                       return NI_ERROR_UNKNOWN;
+       } else {
+               ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgId.c_str(), uid, &handle);
+               if (ret != PMINFO_R_OK)
+                       return NI_ERROR_UNKNOWN;
+       }
+
+       ret = pkgmgrinfo_pkginfo_get_root_path(handle, &path);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+               return NI_ERROR_UNKNOWN;
+       }
+       rootPath = path;
+       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+
+       return NI_ERROR_NONE;
+}
+
+// callback function of "pkgmgrinfo_appinfo_metadata_filter_foreach"
 static int appAotCb(pkgmgrinfo_appinfo_h handle, void *userData)
 {
        char *pkgId = NULL;
@@ -256,7 +318,7 @@ static void createCoreLibNI(bool enableR2R)
        }
 }
 
-int initNICommon(NiCommonOption* option)
+ni_error_e initNICommon(NiCommonOption* option)
 {
 #if defined(__arm__)
        // get interval value
@@ -269,19 +331,19 @@ int initNICommon(NiCommonOption* option)
 
        if (initializePluginManager("normal")) {
                fprintf(stderr, "Fail to initialize plugin manager\n");
-               return -1;
+               return NI_ERROR_UNKNOWN;
        }
        if (initializePathManager(option->runtimeDir, option->tizenFXDir, option->extraDirs)) {
                fprintf(stderr, "Fail to initialize path manager\n");
-               return -1;
+               return NI_ERROR_UNKNOWN;
        }
 
        __tpa = getTPA();
 
-       return 0;
+       return NI_ERROR_NONE;
 #else
        fprintf(stderr, "crossgen supports arm architecture only. skip ni file generation\n");
-       return -1;
+       return NI_ERROR_NOT_SUPPORTED;
 #endif
 }
 
@@ -302,13 +364,19 @@ void createNiPlatform(bool enableR2R)
        createNiUnderDirs(platformDirs, 2, enableR2R);
 }
 
-int createNiDll(const std::string& dllPath, bool enableR2R)
+ni_error_e createNiDll(const std::string& dllPath, bool enableR2R)
 {
        createCoreLibNI(enableR2R);
+       // System.Private.CoreLib.dll is generated in the createCoreLibNI function.
+       // Skip if input dll is System.Private.CoreLib.dll
+       if (dllPath.find("System.Private.CoreLib.dll") != std::string::npos) {
+               return NI_ERROR_NONE;
+       }
+
        return crossgen(dllPath, std::string(), enableR2R);
 }
 
-void createNiUnderDirs(const std::string rootPaths[], int count, bool enableR2R)
+void createNiUnderDirs(const std::string rootPaths[], int count, bool enableR2R, bool isAppNI)
 {
        createCoreLibNI(enableR2R);
 
@@ -321,8 +389,8 @@ void createNiUnderDirs(const std::string rootPaths[], int count, bool enableR2R)
        if (appPaths.back() == ':')
                appPaths.pop_back();
 
-       auto convert = [&appPaths, enableR2R](const std::string& path, const char* name) {
-               if (!crossgen(path, appPaths.c_str(), enableR2R)) {
+       auto convert = [&appPaths, enableR2R, isAppNI](const std::string& path, const char* name) {
+               if (!crossgen(path, appPaths.c_str(), enableR2R, isAppNI)) {
                        waitInterval();
                }
        };
@@ -332,12 +400,12 @@ void createNiUnderDirs(const std::string rootPaths[], int count, bool enableR2R)
        }
 }
 
-int createNiUnderPkgRoot(const std::string& pkgId, bool enableR2R)
+ni_error_e createNiUnderPkgRoot(const std::string& pkgId, bool enableR2R)
 {
        std::string pkgRoot;
-       if (getRootPath(pkgId, pkgRoot) < 0) {
+       if (getRootPath(pkgId, pkgRoot) != NI_ERROR_NONE) {
                fprintf(stderr, "Failed to get root path from [%s]\n", pkgId.c_str());
-               return -1;
+               return NI_ERROR_INVALID_PACKAGE;
        }
 
        std::string binDir = concatPath(pkgRoot, "bin");
@@ -345,24 +413,24 @@ int createNiUnderPkgRoot(const std::string& pkgId, bool enableR2R)
        std::string appTAC = concatPath(binDir, ".TAC.Release");
        std::string paths[] = {binDir, libDir, appTAC};
 
-       createNiUnderDirs(paths, 3, enableR2R);
+       createNiUnderDirs(paths, 3, enableR2R, true);
 
-       return 0;
+       return NI_ERROR_NONE;
 }
 
-int createNiDllUnderPkgRoot(const std::string& pkgId, const std::string& dllPath, bool enableR2R)
+ni_error_e createNiDllUnderPkgRoot(const std::string& pkgId, const std::string& dllPath, bool enableR2R)
 {
        std::string pkgRoot;
        if (getRootPath(pkgId, pkgRoot) < 0) {
                fprintf(stderr, "Failed to get root path from [%s]\n", pkgId.c_str());
-               return -1;
+               return NI_ERROR_INVALID_PACKAGE;
        }
 
        std::string binDir = concatPath(pkgRoot, "bin");
        std::string libDir = concatPath(pkgRoot, "lib");
        std::string paths = binDir + ":" + libDir;
 
-       return crossgen(dllPath, paths, enableR2R);
+       return crossgen(dllPath, paths, enableR2R, true);
 }
 
 void removeNiPlatform()
@@ -401,12 +469,12 @@ void removeNiUnderDirs(const std::string rootPaths[], int count)
                scanFilesInDir(rootPaths[i], convert, -1);
 }
 
-int removeNiUnderPkgRoot(const std::string& pkgId)
+ni_error_e removeNiUnderPkgRoot(const std::string& pkgId)
 {
        std::string pkgRoot;
        if (getRootPath(pkgId, pkgRoot) < 0) {
                fprintf(stderr, "Failed to get root path from [%s]\n", pkgId.c_str());
-               return -1;
+               return NI_ERROR_INVALID_PACKAGE;
        }
 
        std::string binDir = concatPath(pkgRoot, "bin");
@@ -415,33 +483,47 @@ int removeNiUnderPkgRoot(const std::string& pkgId)
 
        removeNiUnderDirs(paths, 2);
 
-       return 0;
+       std::string binNIDir = binDir + APP_NI_SUB_DIR;
+       if (isFileExist(binNIDir)) {
+               if (rmdir(binNIDir.c_str()) != 0) {
+                       fprintf(stderr, "Failed to remove app ni dir [%s]\n", binNIDir.c_str());
+               }
+       }
+
+       std::string libNIDir = libDir + APP_NI_SUB_DIR;
+       if (isFileExist(libNIDir)) {
+               if (rmdir(libNIDir.c_str()) != 0) {
+                       fprintf(stderr, "Failed to remove app ni dir [%s]\n", libNIDir.c_str());
+               }
+       }
+
+       return NI_ERROR_NONE;
 }
 
-int regenerateAppNI(bool enableR2R)
+ni_error_e regenerateAppNI(bool enableR2R)
 {
        int ret = 0;
        pkgmgrinfo_appinfo_metadata_filter_h handle;
 
        ret = pkgmgrinfo_appinfo_metadata_filter_create(&handle);
        if (ret != PMINFO_R_OK)
-               return -1;
+               return NI_ERROR_UNKNOWN;
 
-       ret = pkgmgrinfo_appinfo_metadata_filter_add(handle, "http://tizen.org/metadata/prefer_dotnet_aot", "true");
+       ret = pkgmgrinfo_appinfo_metadata_filter_add(handle, AOT_METADATA_KEY, AOT_METADATA_VALUE);
        if (ret != PMINFO_R_OK) {
                pkgmgrinfo_appinfo_metadata_filter_destroy(handle);
-               return -1;
+               return NI_ERROR_UNKNOWN;
        }
 
        ret = pkgmgrinfo_appinfo_metadata_filter_foreach(handle, appAotCb, &enableR2R);
        if (ret != PMINFO_R_OK) {
                fprintf(stderr, "Failed pkgmgrinfo_appinfo_metadata_filter_foreach\n");
                pkgmgrinfo_appinfo_metadata_filter_destroy(handle);
-               return -1;
+               return NI_ERROR_UNKNOWN;
        }
 
        fprintf(stderr, "Success pkgmgrinfo_appinfo_metadata_filter_foreach\n");
 
        pkgmgrinfo_appinfo_metadata_filter_destroy(handle);
-       return 0;
+       return NI_ERROR_NONE;
 }
index 16b6693..9647369 100644 (file)
@@ -70,7 +70,7 @@ int main(int argc, char* argv[])
        bool pkgDllMode = false;
 
        NiCommonOption option = {std::string(), std::string(), std::string()};
-       if (initNICommon(&option) < 0) {
+       if (initNICommon(&option) != NI_ERROR_NONE) {
                fprintf(stderr, "Fail to initialize NI Common\n");
                return -1;
        }
@@ -119,26 +119,47 @@ int main(int argc, char* argv[])
 
        if (pkgMode) {
                for (const std::string pkg : args) {
-                       if (createNiUnderPkgRoot(pkg, enableR2R) != 0) {
+                       // if there is AOTed dlls under package root, that is skiped.
+                       int ret = createNiUnderPkgRoot(pkg, enableR2R);
+                       if (ret == NI_ERROR_INVALID_PACKAGE) {
                                fprintf(stderr, "Failed to get root path from [%s]\n", pkg.c_str());
                                return -1;
+                       } else if (ret != NI_ERROR_NONE) {
+                               fprintf(stderr, "Failed to generate NI file [%s]\n", args[1].c_str());
+                               return -1;
                        }
                }
        } else if (pkgDllMode) {
-               if (createNiDllUnderPkgRoot(args[0], args[1], enableR2R) != 0) {
+               int ret = createNiDllUnderPkgRoot(args[0], args[1], enableR2R);
+               if (ret == NI_ERROR_INVALID_PACKAGE) {
                        fprintf(stderr, "Failed to get root path from [%s]\n", args[0].c_str());
                        return -1;
+               } else if (ret == NI_ERROR_ALREADY_EXIST) {
+                       // skip for already exist case
+                       return -1;
+               } else if (ret != NI_ERROR_NONE) {
+                       fprintf(stderr, "Failed to generate NI file [%s]\n", args[1].c_str());
+                       return -1;
                }
        } else if (rmPkgMode) {
                for (const std::string pkg : args) {
-                       if (removeNiUnderPkgRoot(pkg) != 0) {
+                       int ret = removeNiUnderPkgRoot(pkg);
+                       if (ret == NI_ERROR_INVALID_PACKAGE) {
                                fprintf(stderr, "Failed to get root path from [%s]\n", pkg.c_str());
                                return -1;
+                       } else if (ret != NI_ERROR_NONE) {
+                               fprintf(stderr, "Failed to remove dlls for given package [%s]\n", pkg.c_str());
+                               return -1;
                        }
                }
        } else if (dllMode) {
+               // donot return error code for generation failure.
+               // we have to run crossgen for all input dlls.
                for (const std::string dll : args) {
-                       if (createNiDll(dll, enableR2R) != 0) {
+                       int ret = createNiDll(dll, enableR2R);
+                       if (ret == NI_ERROR_ALREADY_EXIST) {
+                               // skip for already exist case
+                       } else if (ret != NI_ERROR_NONE) {
                                fprintf(stderr, "Failed to generate NI file [%s]\n", dll.c_str());
                        }
                }
index 5065adb..f8f008b 100644 (file)
@@ -22,8 +22,6 @@
 static PluginFunc* __pluginFunc = NULL;
 static void* __pluginLib;
 
-#define PLUGIN_PATH "/usr/share/dotnet.tizen/lib/libdotnet_plugin.so"
-
 int initializePluginManager(const char* mode)
 {
        if (isFileExist(PLUGIN_PATH)) {
index 963475c..1c4cb6f 100644 (file)
@@ -127,6 +127,7 @@ install -m 0644 %{name}.conf %{buildroot}/etc/tmpfiles.d/%{name}.conf
 %post
 mkdir -p /opt/etc/skel/.dotnet
 chsmack -t -a User::App::Shared /opt/etc/skel/.dotnet
+%{_bindir}/nitool --dll %{_runtime_dir}/System.Private.CoreLib.dll
 
 %files
 %manifest dotnet-launcher.manifest