From: 최종헌/Common Platform Lab(SR)/Engineer/삼성전자 Date: Tue, 26 May 2020 21:32:46 +0000 (+0900) Subject: Fix bugs when generating SPC.ni with --ni-dll option (#235) X-Git-Tag: submit/tizen/20200528.002636~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=592df10d9bdd16508567cf98cf43d84210f6cf98;p=platform%2Fcore%2Fdotnet%2Flauncher.git Fix bugs when generating SPC.ni with --ni-dll option (#235) Change-Id: I7f70ec0bf9b4a227b0f11fe35a4080f7685116a3 --- diff --git a/NativeLauncher/tool/dotnettool.cc b/NativeLauncher/tool/dotnettool.cc index d657f35..4a6eda6 100644 --- a/NativeLauncher/tool/dotnettool.cc +++ b/NativeLauncher/tool/dotnettool.cc @@ -161,18 +161,12 @@ int main(int argc, char* argv[]) std::string pkg = std::string(*it); // if there is AOTed dlls under package root, that is skiped. int ret = createNiUnderPkgRoot(pkg, flags); - if (ret == NI_ERROR_INVALID_PACKAGE) { - fprintf(stderr, "Failed to get root path from [%s]\n", pkg.c_str()); - break; - } else if (ret != NI_ERROR_NONE) { + if (ret != NI_ERROR_NONE) { fprintf(stderr, "Failed to generate NI file [%s]\n", pkg.c_str()); break; } ret = createTACPkgRoot(pkg, flags); - if (ret == NI_ERROR_INVALID_PACKAGE) { - fprintf(stderr, "Failed to get root path from [%s]\n", pkg.c_str()); - break; - } else if (ret != NI_ERROR_NONE) { + if (ret != NI_ERROR_NONE) { fprintf(stderr, "Failed to generate symbolic link file [%s]\n", pkg.c_str()); break; } @@ -189,10 +183,7 @@ int main(int argc, char* argv[]) while (it != args.end()) { std::string dll = std::string(*it); int ret = createNiDllUnderPkgRoot(pkg, dll, flags); - if (ret == NI_ERROR_INVALID_PACKAGE) { - fprintf(stderr, "Failed to get root path from [%s]\n", pkg.c_str()); - break; - } else if (ret != NI_ERROR_NONE) { + if (ret != NI_ERROR_NONE) { fprintf(stderr, "Failed to generate NI file [%s]\n", dll.c_str()); break; } @@ -227,18 +218,12 @@ int main(int argc, char* argv[]) while (it != args.end()) { std::string pkg = std::string(*it); int ret = removeNiUnderPkgRoot(pkg); - if (ret == NI_ERROR_INVALID_PACKAGE) { - fprintf(stderr, "Failed to get root path from [%s]\n", pkg.c_str()); - break; - } else if (ret != NI_ERROR_NONE) { + if (ret != NI_ERROR_NONE) { fprintf(stderr, "Failed to remove dlls for given package [%s]\n", pkg.c_str()); break; } ret = resetTACPackage(pkg); - if (ret == TAC_ERROR_INVALID_PACKAGE) { - fprintf(stderr, "Failed to get root path from [%s]\n", pkg.c_str()); - break; - } else if (ret != TAC_ERROR_NONE) { + if (ret != TAC_ERROR_NONE) { fprintf(stderr, "Failed to remove symlink for given package [%s]\n", pkg.c_str()); break; } @@ -285,10 +270,7 @@ int main(int argc, char* argv[]) while (it != args.end()) { std::string pkg = std::string(*it); int ret = enableTACPackage(pkg); - if (ret == TAC_ERROR_INVALID_PACKAGE) { - fprintf(stderr, "Failed to get root path from [%s]\n", pkg.c_str()); - break; - } else if (ret != TAC_ERROR_NONE) { + if (ret != TAC_ERROR_NONE) { fprintf(stderr, "Failed to enable tac [%s]\n", pkg.c_str()); break; } @@ -303,10 +285,7 @@ int main(int argc, char* argv[]) while (it != args.end()) { std::string pkg = std::string(*it); int ret = disableTACPackage(pkg); - if (ret == TAC_ERROR_INVALID_PACKAGE) { - fprintf(stderr, "Failed to get root path from [%s]\n", pkg.c_str()); - break; - } else if (ret != TAC_ERROR_NONE) { + if (ret != TAC_ERROR_NONE) { fprintf(stderr, "Failed to disable tac [%s]\n", pkg.c_str()); break; } diff --git a/NativeLauncher/tool/ni_common.cc b/NativeLauncher/tool/ni_common.cc index ed30fdb..527a7fd 100644 --- a/NativeLauncher/tool/ni_common.cc +++ b/NativeLauncher/tool/ni_common.cc @@ -404,7 +404,7 @@ static bool isCoreLibPrepared(DWORD flags) } } -static void createCoreLibNI(DWORD flags) +static ni_error_e createCoreLibNI(DWORD flags) { std::string coreLib = concatPath(getRuntimeDir(), "System.Private.CoreLib.dll"); std::string niCoreLib = concatPath(getRuntimeDir(), "System.Private.CoreLib.ni.dll"); @@ -414,14 +414,18 @@ static void createCoreLibNI(DWORD flags) if (!crossgen(coreLib, std::string(), flags)) { if (rename(coreLib.c_str(), coreLibBackup.c_str())) { fprintf(stderr, "Failed to rename System.Private.CoreLib.dll\n"); + return NI_ERROR_CORE_NI_FILE; } if (rename(niCoreLib.c_str(), coreLib.c_str())) { fprintf(stderr, "Failed to rename System.Private.CoreLib.ni.dll\n"); + return NI_ERROR_CORE_NI_FILE; } } else { fprintf(stderr, "Failed to create native image for %s\n", coreLib.c_str()); + return NI_ERROR_CORE_NI_FILE; } } + return NI_ERROR_NONE; } ni_error_e initNICommon(NiCommonOption* option) @@ -466,7 +470,9 @@ void finalizeNICommon() ni_error_e createNiPlatform(DWORD flags) { - createCoreLibNI(flags); + if (createCoreLibNI(flags) != NI_ERROR_NONE) { + return NI_ERROR_CORE_NI_FILE; + } const std::string platformDirs[] = {getRuntimeDir(), getTizenFXDir()}; return createNiUnderDirs(platformDirs, 2, flags); @@ -474,6 +480,10 @@ ni_error_e createNiPlatform(DWORD flags) ni_error_e createNiDll(const std::string& dllPath, DWORD flags) { + if (dllPath.find("System.Private.CoreLib.dll") != std::string::npos) { + return createCoreLibNI(flags); + } + if (!isCoreLibPrepared(flags)) { return NI_ERROR_CORE_NI_FILE; } @@ -512,6 +522,7 @@ ni_error_e createTACPkgRoot(const std::string& pkgId, DWORD flags) std::string pkgRoot; if (getRootPath(pkgId, pkgRoot) < 0) { + fprintf(stderr, "Failed to get root path from [%s]\n", pkgId.c_str()); return NI_ERROR_INVALID_PACKAGE; } @@ -602,6 +613,7 @@ ni_error_e createNiUnderPkgRoot(const std::string& pkgId, DWORD flags) { std::string pkgRoot; if (getRootPath(pkgId, pkgRoot) < 0) { + fprintf(stderr, "Failed to get root path from [%s]\n", pkgId.c_str()); return NI_ERROR_INVALID_PACKAGE; } @@ -622,6 +634,7 @@ ni_error_e createNiDllUnderPkgRoot(const std::string& pkgId, const std::string& std::string pkgRoot; if (getRootPath(pkgId, pkgRoot) < 0) { + fprintf(stderr, "Failed to get root path from [%s]\n", pkgId.c_str()); return NI_ERROR_INVALID_PACKAGE; } @@ -721,6 +734,7 @@ 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 NI_ERROR_INVALID_PACKAGE; } diff --git a/NativeLauncher/tool/tac_common.cc b/NativeLauncher/tool/tac_common.cc index 1846cd8..eba7c17 100644 --- a/NativeLauncher/tool/tac_common.cc +++ b/NativeLauncher/tool/tac_common.cc @@ -221,6 +221,7 @@ tac_error_e resetTACPackage(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 TAC_ERROR_INVALID_PACKAGE; } @@ -256,6 +257,7 @@ tac_error_e disableTACPackage(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 TAC_ERROR_INVALID_PACKAGE; } @@ -302,16 +304,19 @@ tac_error_e enableTACPackage(const std::string& pkgId) { std::string rootPath; if (getRootPath(pkgId, rootPath) < 0) { + fprintf(stderr, "Failed to get root path from [%s]\n", pkgId.c_str()); return TAC_ERROR_INVALID_PACKAGE; } std::string execName; if (getExecName(pkgId, execName) < 0) { + fprintf(stderr, "Failed to get root path from [%s]\n", pkgId.c_str()); return TAC_ERROR_INVALID_PACKAGE; } std::string metaValue; if (getMetadataValue(pkgId, TAC_METADATA_KEY, metaValue) < 0) { + fprintf(stderr, "Failed to get root path from [%s]\n", pkgId.c_str()); return TAC_ERROR_INVALID_PACKAGE; }