return 0;
}
+static bool isCoreLibPrepared(DWORD flags)
+{
+ if (flags & NI_FLAGS_ENABLER2R) {
+ return true;
+ }
+
+ std::string coreLibBackup = concatPath(getRuntimeDir(), "System.Private.CoreLib.dll.Backup");
+ if (isFileExist(coreLibBackup)) {
+ return true;
+ } else {
+ fprintf(stderr, "The native image of System.Private.CoreLib does not exist\n"
+ "Run the command to create the native image\n"
+ "# dotnettool --ni-dll /usr/share/dotnet.tizen/netcoreapp/System.Private.CoreLib.dll\n\n");
+ return false;
+ }
+}
+
static void createCoreLibNI(DWORD flags)
{
std::string coreLib = concatPath(getRuntimeDir(), "System.Private.CoreLib.dll");
std::string coreLibBackup = concatPath(getRuntimeDir(), "System.Private.CoreLib.dll.Backup");
if (!isFileExist(coreLibBackup)) {
-
if (!crossgen(coreLib, std::string(), flags)) {
if (rename(coreLib.c_str(), coreLibBackup.c_str())) {
fprintf(stderr, "Failed to rename System.Private.CoreLib.dll\n");
}
-void createNiPlatform(DWORD flags)
+ni_error_e createNiPlatform(DWORD flags)
{
+ createCoreLibNI(flags);
+
const std::string platformDirs[] = {getRuntimeDir(), getTizenFXDir()};
- createNiUnderDirs(platformDirs, 2, flags);
+ return createNiUnderDirs(platformDirs, 2, flags);
}
ni_error_e createNiDll(const std::string& dllPath, DWORD flags)
{
- createCoreLibNI(flags);
- // 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;
+ if (!isCoreLibPrepared(flags)) {
+ return NI_ERROR_CORE_NI_FILE;
}
return crossgen(dllPath, std::string(), flags);
ni_error_e createTACPkgRoot(const std::string& pkgId, DWORD flags)
{
+ if (!isCoreLibPrepared(flags)) {
+ return NI_ERROR_CORE_NI_FILE;
+ }
+
std::string pkgRoot;
if (getRootPath(pkgId, pkgRoot) < 0) {
return NI_ERROR_INVALID_PACKAGE;
return NI_ERROR_NONE;
}
-void createNiUnderDirs(const std::string rootPaths[], int count, DWORD flags)
+ni_error_e createNiUnderDirs(const std::string rootPaths[], int count, DWORD flags)
{
- createCoreLibNI(flags);
+ if (!isCoreLibPrepared(flags)) {
+ return NI_ERROR_CORE_NI_FILE;
+ }
std::string appPaths;
for (int i = 0; i < count; i++) {
}
tpaAssemblies.clear();
+ return NI_ERROR_NONE;
}
ni_error_e createNiUnderPkgRoot(const std::string& pkgId, DWORD flags)
std::string paths[] = {binDir, libDir, tacDir};
flags |= NI_FLAGS_APPNI;
- createNiUnderDirs(paths, 3, flags);
-
- return NI_ERROR_NONE;
+ return createNiUnderDirs(paths, 3, flags);
}
ni_error_e createNiDllUnderPkgRoot(const std::string& pkgId, const std::string& dllPath, DWORD flags)
{
+ if (!isCoreLibPrepared(flags)) {
+ return NI_ERROR_CORE_NI_FILE;
+ }
+
std::string pkgRoot;
if (getRootPath(pkgId, pkgRoot) < 0) {
return NI_ERROR_INVALID_PACKAGE;
ni_error_e regenerateAppNI(DWORD flags)
{
+ if (!isCoreLibPrepared(flags)) {
+ return NI_ERROR_CORE_NI_FILE;
+ }
+
int ret = 0;
pkgmgrinfo_appinfo_metadata_filter_h handle;
ni_error_e regenerateTACNI(DWORD flags)
{
+ if (!isCoreLibPrepared(flags)) {
+ return NI_ERROR_CORE_NI_FILE;
+ }
+
const std::string tacDir[] = {__DOTNET_DIR};
removeNiUnderDirs(tacDir, 1);