From eaa814cf3d9cc7c8fd28a997d2797e7fdbff08ad Mon Sep 17 00:00:00 2001 From: JongHeon Choi Date: Thu, 13 Apr 2017 09:52:52 +0900 Subject: Code style refactorting Change-Id: I5a2eb4db8edcdfa3074212c476fecd7506d11e45 --- NativeLauncher/CMakeLists.txt | 86 +-- NativeLauncher/dotnet.launcher | 8 +- NativeLauncher/dotnet.loader | 30 +- NativeLauncher/installer-plugin/common.cc | 6 +- .../installer-plugin/prefer_dotnet_aot_plugin.cc | 46 +- NativeLauncher/launcher/dotnet/dotnet_launcher.cc | 1 - NativeLauncher/launcher/dotnet/scd_launcher.cc | 590 ++++++++++----------- NativeLauncher/launcher/launcher.cc | 35 +- NativeLauncher/launcher/main.cc | 4 +- Tizen.Runtime/Tizen.Runtime.Coreclr.csproj | 96 ++-- Tizen.Runtime/Tizen.Runtime.Coreclr.project.json | 14 +- .../Tizen.Runtime.Coreclr/AssemblyManager.cs | 2 +- Tizen.Runtime/Tizen.Runtime.snk | Bin 596 -> 599 bytes dotnet-launcher.manifest | 6 +- 14 files changed, 464 insertions(+), 460 deletions(-) diff --git a/NativeLauncher/CMakeLists.txt b/NativeLauncher/CMakeLists.txt index f8a1697..4107d05 100755 --- a/NativeLauncher/CMakeLists.txt +++ b/NativeLauncher/CMakeLists.txt @@ -4,51 +4,51 @@ PROJECT("dotnet-tools") MESSAGE("CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") IF(DEFINED NO_TIZEN) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DNO_TIZEN") + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DNO_TIZEN") ELSE(DEFINED NO_TIZEN) - INCLUDE(FindPkgConfig) - PKG_CHECK_MODULES(${PROJECT_NAME} REQUIRED aul pkgmgr-info pkgmgr-installer dlog ecore bundle dlog launchpad elementary glib-2.0 capi-appfw-app-control capi-appfw-service-application) + INCLUDE(FindPkgConfig) + PKG_CHECK_MODULES(${PROJECT_NAME} REQUIRED aul pkgmgr-info pkgmgr-installer dlog ecore bundle dlog launchpad elementary glib-2.0 capi-appfw-app-control capi-appfw-service-application) ENDIF(DEFINED NO_TIZEN) FOREACH(flag ${${PROJECT_NAME}_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) IF(DEFINED LAUNCHER_CONFIG_PATH) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DLAUNCHER_CONFIG_PATH=${LAUNCHER_CONFIG_PATH}") + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DLAUNCHER_CONFIG_PATH=${LAUNCHER_CONFIG_PATH}") ENDIF(DEFINED LAUNCHER_CONFIG_PATH) IF(DEFINED CORECLR_LAUNCHER_ASSEMBLY_PATH) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DCORECLR_LAUNCHER_ASSEMBLY_PATH=${CORECLR_LAUNCHER_ASSEMBLY_PATH}") + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DCORECLR_LAUNCHER_ASSEMBLY_PATH=${CORECLR_LAUNCHER_ASSEMBLY_PATH}") ENDIF(DEFINED CORECLR_LAUNCHER_ASSEMBLY_PATH) IF(DEFINED DEVICE_API_DIR) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DDEVICE_API_DIR=${DEVICE_API_DIR}") + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DDEVICE_API_DIR=${DEVICE_API_DIR}") ENDIF(DEFINED DEVICE_API_DIR) IF(DEFINED RUNTIME_DIR) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DRUNTIME_DIR=${RUNTIME_DIR}") + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DRUNTIME_DIR=${RUNTIME_DIR}") ENDIF(DEFINED RUNTIME_DIR) IF(DEFINED CROSSGEN_PATH) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DCROSSGEN_PATH=${CROSSGEN_PATH}") + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DCROSSGEN_PATH=${CROSSGEN_PATH}") ENDIF(DEFINED CROSSGEN_PATH) IF(DEFINED VERSION) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DVERSION=${VERSION}") + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DVERSION=${VERSION}") ENDIF(DEFINED VERSION) IF(DEFINED NATIVE_LIB_DIR) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DNATIVE_LIB_DIR=${NATIVE_LIB_DIR}") + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DNATIVE_LIB_DIR=${NATIVE_LIB_DIR}") ENDIF(DEFINED NATIVE_LIB_DIR) IF(USE_MANAGED_LAUNCHER STREQUAL "ENABLE") - ADD_DEFINITIONS("-DUSE_MANAGED_LAUNCHER") + ADD_DEFINITIONS("-DUSE_MANAGED_LAUNCHER") ENDIF(USE_MANAGED_LAUNCHER) OPTION(NOT_USE_FUNCTION "Remove build warning" OFF) IF(NOT_USE_FUNCTION) - ADD_DEFINITIONS("-DNOT_USE_FUNCTION") + ADD_DEFINITIONS("-DNOT_USE_FUNCTION") ENDIF(NOT_USE_FUNCTION) @@ -71,77 +71,77 @@ INCLUDE_DIRECTORIES(inc launcher util) SET(DOTNET_LAUNCHER "dotnet-launcher") SET(${DOTNET_LAUNCHER}_SOURCE_FILES - launcher/main.cc - util/utils.cc - launcher/launcher.cc - launcher/dotnet/dotnet_launcher.cc + launcher/main.cc + util/utils.cc + launcher/launcher.cc + launcher/dotnet/dotnet_launcher.cc ) ADD_EXECUTABLE(${DOTNET_LAUNCHER} ${${DOTNET_LAUNCHER}_SOURCE_FILES}) -SET_TARGET_PROPERTIES(${DOTNET_LAUNCHER} PROPERTIES COMPILE_FLAGS "-fPIE") +SET_TARGET_PROPERTIES(${DOTNET_LAUNCHER} PROPERTIES COMPILE_FLAGS "-fPIE") SET(SCD_LAUNCHER "scd-launcher") SET(${SCD_LAUNCHER}_SOURCE_FILES - launcher/dotnet/scd_launcher.cc + launcher/dotnet/scd_launcher.cc ) ADD_EXECUTABLE(${SCD_LAUNCHER} ${${SCD_LAUNCHER}_SOURCE_FILES}) -SET_TARGET_PROPERTIES(${SCD_LAUNCHER} PROPERTIES COMPILE_FLAGS "-fPIE") +SET_TARGET_PROPERTIES(${SCD_LAUNCHER} PROPERTIES COMPILE_FLAGS "-fPIE") IF(NOT DEFINED NO_TIZEN) - TARGET_LINK_LIBRARIES(${SCD_LAUNCHER} capi-appfw-app-control dlog appcore-agent) + TARGET_LINK_LIBRARIES(${SCD_LAUNCHER} capi-appfw-app-control dlog appcore-agent) ENDIF(NOT DEFINED NO_TIZEN) TARGET_LINK_LIBRARIES(${SCD_LAUNCHER} ${${PROJECT_NAME}_LDFLAGS} "-pie -ldl -lpthread") IF(NOT DEFINED NO_TIZEN) - TARGET_LINK_LIBRARIES(${DOTNET_LAUNCHER} aul) + TARGET_LINK_LIBRARIES(${DOTNET_LAUNCHER} aul) ENDIF(NOT DEFINED NO_TIZEN) TARGET_LINK_LIBRARIES(${DOTNET_LAUNCHER} ${${PROJECT_NAME}_LDFLAGS} "-pie -ldl -lpthread") SET_TARGET_PROPERTIES(${DOTNET_LAUNCHER} - PROPERTIES SKIP_BUILD_RPATH TRUE + PROPERTIES SKIP_BUILD_RPATH TRUE ) # remove rpath option that is automatically generated by cmake. SET(NITOOL "nitool") SET(${NITOOL}_SOURCE_FILES - util/utils.cc - installer-plugin/common.cc - installer-plugin/nitool.cc + util/utils.cc + installer-plugin/common.cc + installer-plugin/nitool.cc ) ADD_EXECUTABLE(${NITOOL} ${${NITOOL}_SOURCE_FILES}) -SET_TARGET_PROPERTIES(${NITOOL} PROPERTIES COMPILE_FLAGS "-fPIE") +SET_TARGET_PROPERTIES(${NITOOL} PROPERTIES COMPILE_FLAGS "-fPIE") TARGET_LINK_LIBRARIES(${NITOOL} ${${PROJECT_NAME}_LDFLAGS} "-pie") SET(INSTALLER_PLUGIN "ui-application") SET(${INSTALLER_PLUGIN}_SOURCE_FILES - util/utils.cc - installer-plugin/common.cc - installer-plugin/ui-application.cc + util/utils.cc + installer-plugin/common.cc + installer-plugin/ui-application.cc ) ADD_LIBRARY(${INSTALLER_PLUGIN} SHARED ${${INSTALLER_PLUGIN}_SOURCE_FILES}) -SET_TARGET_PROPERTIES(${INSTALLER_PLUGIN} PROPERTIES COMPILE_FLAGS "-fPIC") +SET_TARGET_PROPERTIES(${INSTALLER_PLUGIN} PROPERTIES COMPILE_FLAGS "-fPIC") TARGET_LINK_LIBRARIES(${INSTALLER_PLUGIN} ${${PROJECT_NAME}_LDFLAGS}) SET(PREFER_DOTNET_AOT_PLUGIN "prefer_dotnet_aot_plugin") SET(${PREFER_DOTNET_AOT_PLUGIN}_SOURCE_FILES - util/utils.cc - installer-plugin/common.cc - installer-plugin/prefer_dotnet_aot_plugin.cc + util/utils.cc + installer-plugin/common.cc + installer-plugin/prefer_dotnet_aot_plugin.cc ) ADD_LIBRARY(${PREFER_DOTNET_AOT_PLUGIN} SHARED ${${PREFER_DOTNET_AOT_PLUGIN}_SOURCE_FILES}) -SET_TARGET_PROPERTIES(${PREFER_DOTNET_AOT_PLUGIN} PROPERTIES COMPILE_FLAGS "-fPIC") +SET_TARGET_PROPERTIES(${PREFER_DOTNET_AOT_PLUGIN} PROPERTIES COMPILE_FLAGS "-fPIC") TARGET_LINK_LIBRARIES(${PREFER_DOTNET_AOT_PLUGIN} ${${PROJECT_NAME}_LDFLAGS}) IF(NOT DEFINED NO_TIZEN) - INSTALL(TARGETS ${DOTNET_LAUNCHER} DESTINATION ${BINDIR}) - INSTALL(TARGETS ${SCD_LAUNCHER} DESTINATION ${BINDIR}) - INSTALL(TARGETS ${NITOOL} DESTINATION ${BINDIR}) - INSTALL(TARGETS ${INSTALLER_PLUGIN} DESTINATION ${INSTALL_PLUGIN_DIR}) - INSTALL(TARGETS ${PREFER_DOTNET_AOT_PLUGIN} DESTINATION ${INSTALL_MDPLUGIN_DIR}) - INSTALL(FILES dotnet.loader DESTINATION ${LOADERDIR}) - INSTALL(FILES dotnet.launcher DESTINATION ${LOADERDIR}) - INSTALL(FILES dotnet.debugger DESTINATION ${LOADERDIR}) + INSTALL(TARGETS ${DOTNET_LAUNCHER} DESTINATION ${BINDIR}) + INSTALL(TARGETS ${SCD_LAUNCHER} DESTINATION ${BINDIR}) + INSTALL(TARGETS ${NITOOL} DESTINATION ${BINDIR}) + INSTALL(TARGETS ${INSTALLER_PLUGIN} DESTINATION ${INSTALL_PLUGIN_DIR}) + INSTALL(TARGETS ${PREFER_DOTNET_AOT_PLUGIN} DESTINATION ${INSTALL_MDPLUGIN_DIR}) + INSTALL(FILES dotnet.loader DESTINATION ${LOADERDIR}) + INSTALL(FILES dotnet.launcher DESTINATION ${LOADERDIR}) + INSTALL(FILES dotnet.debugger DESTINATION ${LOADERDIR}) ENDIF(NOT DEFINED NO_TIZEN) diff --git a/NativeLauncher/dotnet.launcher b/NativeLauncher/dotnet.launcher index 846e372..7a96952 100644 --- a/NativeLauncher/dotnet.launcher +++ b/NativeLauncher/dotnet.launcher @@ -1,6 +1,6 @@ [LAUNCHER] -NAME dotnet-launcher -EXE /usr/bin/dotnet-launcher -APP_TYPE dotnet -EXTRA_ARG --standalone +NAME dotnet-launcher +EXE /usr/bin/dotnet-launcher +APP_TYPE dotnet +EXTRA_ARG --standalone diff --git a/NativeLauncher/dotnet.loader b/NativeLauncher/dotnet.loader index 57b547d..78bb74f 100644 --- a/NativeLauncher/dotnet.loader +++ b/NativeLauncher/dotnet.loader @@ -1,16 +1,16 @@ [LOADER] -NAME dotnet-launcher -EXE /usr/bin/dotnet-launcher -APP_TYPE dotnet -DETECTION_METHOD TIMEOUT|DEMAND -TIMEOUT 5000 -EXTRA_ARRAY preload -EXTRA_ARRAY_VAL /usr/lib/libappcore-efl.so.1 -EXTRA_ARRAY_VAL /usr/lib/libappcore-common.so.1 -EXTRA_ARRAY_VAL /usr/lib/libcapi-appfw-application.so.0 -EXTRA_ARRAY_VAL /usr/lib/ecore_imf/modules/wayland/v-1.16/libwltextinputmodule.so -EXTRA_ARRAY_VAL /usr/lib/libdali-toolkit.so -EXTRA_ARRAY_VAL /usr/lib/libcairo.so.2 -EXTRA_ARRAY_VAL /usr/lib/libefl-assist.so.0 -EXTRA_ARRAY_VAL /usr/lib/libcapi-media-player.so.0 -EXTRA_ARRAY_VAL /usr/lib/libcapi-media-camera.so.0 +NAME dotnet-launcher +EXE /usr/bin/dotnet-launcher +APP_TYPE dotnet +DETECTION_METHOD TIMEOUT|DEMAND +TIMEOUT 5000 +EXTRA_ARRAY preload +EXTRA_ARRAY_VAL /usr/lib/libappcore-efl.so.1 +EXTRA_ARRAY_VAL /usr/lib/libappcore-common.so.1 +EXTRA_ARRAY_VAL /usr/lib/libcapi-appfw-application.so.0 +EXTRA_ARRAY_VAL /usr/lib/ecore_imf/modules/wayland/v-1.16/libwltextinputmodule.so +EXTRA_ARRAY_VAL /usr/lib/libdali-toolkit.so +EXTRA_ARRAY_VAL /usr/lib/libcairo.so.2 +EXTRA_ARRAY_VAL /usr/lib/libefl-assist.so.0 +EXTRA_ARRAY_VAL /usr/lib/libcapi-media-player.so.0 +EXTRA_ARRAY_VAL /usr/lib/libcapi-media-camera.so.0 diff --git a/NativeLauncher/installer-plugin/common.cc b/NativeLauncher/installer-plugin/common.cc index d2c9c3f..6473dc8 100644 --- a/NativeLauncher/installer-plugin/common.cc +++ b/NativeLauncher/installer-plugin/common.cc @@ -310,8 +310,10 @@ void create_ni_under_dirs(const char* root_paths[], int count, const char* ignor { // change owner and groups for generated ni file. struct stat info; - if (!stat(path, &info)) { - if (chown(ni.c_str(), info.st_uid, info.st_gid) == -1) { + if (!stat(path, &info)) + { + if (chown(ni.c_str(), info.st_uid, info.st_gid) == -1) + { _ERR("Failed to change owner and group name"); } } diff --git a/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc b/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc index f180739..a9c940b 100755 --- a/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc +++ b/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc @@ -37,30 +37,34 @@ const std::string VALUE_TRUE = "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; - bool mdValue = false; - Metadata *mdInfo = NULL; - tag = g_list_first(list); - while (tag) { - mdInfo = (Metadata*)tag->data; - if(mdInfo->key == mdKey && mdInfo->value == VALUE_TRUE) { - _DBG("Prefer dotnet application AOT set TRUE"); - mdValue = true; - } - tag = g_list_next(tag); + GList *tag = NULL; + bool mdValue = false; + Metadata *mdInfo = NULL; + tag = g_list_first(list); + while (tag) + { + mdInfo = (Metadata*)tag->data; + if(mdInfo->key == mdKey && mdInfo->value == VALUE_TRUE) + { + _DBG("Prefer dotnet application AOT set TRUE"); + mdValue = true; } + tag = g_list_next(tag); + } - if (mdValue) { - if (create_ni_under_pkg_root(pkgid) != 0) - { - _ERR("Failed to get root path from [%s]", pkgid); - return -1; - } else { - _DBG("Complete make application to native image"); - } + if (mdValue) + { + if (create_ni_under_pkg_root(pkgid) != 0) + { + _ERR("Failed to get root path from [%s]", pkgid); + return -1; + } + else + { + _DBG("Complete make application to native image"); } - return 0; + } + return 0; } extern "C" int PKGMGR_MDPARSER_PLUGIN_UPGRADE (const char *pkgid, const char *appid, GList *list) diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc index 4aabf42..5f40771 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc @@ -73,7 +73,6 @@ CoreRuntime::~CoreRuntime() int CoreRuntime::Initialize(bool standalone) { - if (standalone) { const char *_deviceapi_directory = getenv("DeviceAPIDirectory"); diff --git a/NativeLauncher/launcher/dotnet/scd_launcher.cc b/NativeLauncher/launcher/dotnet/scd_launcher.cc index 2959b19..138d9f4 100644 --- a/NativeLauncher/launcher/dotnet/scd_launcher.cc +++ b/NativeLauncher/launcher/dotnet/scd_launcher.cc @@ -49,7 +49,6 @@ using namespace std; - bool isDebugMode = false; char *coreclr_gdbjit[PATH_MAX]; char *root_path; @@ -73,12 +72,15 @@ void service_app_control(app_control_h app_control, void *data) char* buf[82]; int ret = app_control_get_extra_data(app_control, "_SCD_DEBUG_", buf); - if (ret == APP_CONTROL_ERROR_NONE) { - if(strcmp(*buf, "1") == 0) { + if (ret == APP_CONTROL_ERROR_NONE) + { + if(strcmp(*buf, "1") == 0) + { isDebugMode = true; } } - if (isDebugMode) { + if (isDebugMode) + { ret = app_control_get_extra_data(app_control, "_SCD_CORECLR_GDBJIT_", coreclr_gdbjit); } @@ -116,15 +118,15 @@ bool GetEntrypointExecutableAbsolutePath(std::string& entrypointExecutable) char exe[PATH_MAX]; ssize_t res = readlink(symlinkEntrypointExecutable, exe, PATH_MAX - 1); if (res != -1) - { - exe[res] = '\0'; - entrypointExecutable.assign(exe); - result = true; - } + { + exe[res] = '\0'; + entrypointExecutable.assign(exe); + result = true; + } else - { - result = false; - } + { + result = false; + } return result; } @@ -135,28 +137,26 @@ bool GetAbsolutePath(const char* path, std::string& absolutePath) char realPath[PATH_MAX]; if (realpath(path, realPath) != nullptr && realPath[0] != '\0') - { - absolutePath.assign(realPath); - // realpath should return canonicalized path without the trailing slash - assert(absolutePath.back() != '/'); + { + absolutePath.assign(realPath); + // realpath should return canonicalized path without the trailing slash + assert(absolutePath.back() != '/'); - result = true; - } + result = true; + } return result; } - - bool GetDirectory(const char* absolutePath, std::string& directory) { directory.assign(absolutePath); size_t lastSlash = directory.rfind('/'); if (lastSlash != std::string::npos) - { - directory.erase(lastSlash); - return true; - } + { + directory.erase(lastSlash); + return true; + } return false; } @@ -166,25 +166,25 @@ bool GetClrFilesAbsolutePath(const char* currentExePath, const char* clrFilesPat std::string clrFilesRelativePath; const char* clrFilesPathLocal = clrFilesPath; if (clrFilesPathLocal == nullptr) + { + // There was no CLR files path specified, use the folder of the corerun/coreconsole + if (!GetDirectory(currentExePath, clrFilesRelativePath)) { - // There was no CLR files path specified, use the folder of the corerun/coreconsole - if (!GetDirectory(currentExePath, clrFilesRelativePath)) - { - perror("Failed to get directory from argv[0]"); - return false; - } + perror("Failed to get directory from argv[0]"); + return false; + } - clrFilesPathLocal = clrFilesRelativePath.c_str(); + clrFilesPathLocal = clrFilesRelativePath.c_str(); - // TODO: consider using an env variable (if defined) as a fall-back. - // The windows version of the corerun uses core_root env variable - } + // TODO: consider using an env variable (if defined) as a fall-back. + // The windows version of the corerun uses core_root env variable + } if (!GetAbsolutePath(clrFilesPathLocal, clrFilesAbsolutePath)) - { - perror("Failed to convert CLR files path to absolute path"); - return false; - } + { + perror("Failed to convert CLR files path to absolute path"); + return false; + } return true; } @@ -200,96 +200,93 @@ void AddFilesFromDirectoryToTpaList(const char* directory, std::string& tpaList) DIR* dir = opendir(directory); if (dir == nullptr) - { - return; - } + { + return; + } std::set addedAssemblies; // Walk the directory for each extension separately so that we first get files with .ni.dll extension, // then files with .dll extension, etc. for (unsigned int extIndex = 0; extIndex < sizeof(tpaExtensions) / sizeof(tpaExtensions[0]); extIndex++) - { - const char* ext = tpaExtensions[extIndex]; - int extLength = strlen(ext); + { + const char* ext = tpaExtensions[extIndex]; + int extLength = strlen(ext); + + struct dirent* entry; - struct dirent* entry; + // For all entries in the directory + while ((entry = readdir(dir)) != nullptr) + { + // We are interested in files only + switch (entry->d_type) + { + case DT_REG: + break; - // For all entries in the directory - while ((entry = readdir(dir)) != nullptr) + // Handle symlinks and file systems that do not support d_type + case DT_LNK: + case DT_UNKNOWN: { - // We are interested in files only - switch (entry->d_type) + std::string fullFilename; + + fullFilename.append(directory); + fullFilename.append("/"); + fullFilename.append(entry->d_name); + + struct stat sb; + if (stat(fullFilename.c_str(), &sb) == -1) { - case DT_REG: - break; - - // Handle symlinks and file systems that do not support d_type - case DT_LNK: - case DT_UNKNOWN: - { - std::string fullFilename; - - fullFilename.append(directory); - fullFilename.append("/"); - fullFilename.append(entry->d_name); - - struct stat sb; - if (stat(fullFilename.c_str(), &sb) == -1) - { - continue; - } - - if (!S_ISREG(sb.st_mode)) - { - continue; - } - } - break; - - default: continue; } - std::string filename(entry->d_name); - - // Check if the extension matches the one we are looking for - int extPos = filename.length() - extLength; - if ((extPos <= 0) || (filename.compare(extPos, extLength, ext) != 0)) + if (!S_ISREG(sb.st_mode)) { continue; } + } + break; - std::string filenameWithoutExt(filename.substr(0, extPos)); + default: + continue; + } - // Make sure if we have an assembly with multiple extensions present, - // we insert only one version of it. - if (addedAssemblies.find(filenameWithoutExt) == addedAssemblies.end()) - { - addedAssemblies.insert(filenameWithoutExt); + std::string filename(entry->d_name); - tpaList.append(directory); - tpaList.append("/"); - tpaList.append(filename); - tpaList.append(":"); - } - } + // Check if the extension matches the one we are looking for + int extPos = filename.length() - extLength; + if ((extPos <= 0) || (filename.compare(extPos, extLength, ext) != 0)) + { + continue; + } + + std::string filenameWithoutExt(filename.substr(0, extPos)); - // Rewind the directory stream to be able to iterate over it for the next extension - rewinddir(dir); + // Make sure if we have an assembly with multiple extensions present, + // we insert only one version of it. + if (addedAssemblies.find(filenameWithoutExt) == addedAssemblies.end()) + { + addedAssemblies.insert(filenameWithoutExt); + + tpaList.append(directory); + tpaList.append("/"); + tpaList.append(filename); + tpaList.append(":"); + } } + // Rewind the directory stream to be able to iterate over it for the next extension + rewinddir(dir); + } + closedir(dir); } - - -int ExecuteManagedAssembly( - const char* currentExeAbsolutePath, - const char* clrFilesAbsolutePath, - const char* managedAssemblyAbsolutePath, - int managedAssemblyArgc, - const char** managedAssemblyArgv) +int ExecuteManagedAssembly(const char* currentExeAbsolutePath, + const char* clrFilesAbsolutePath, + const char* managedAssemblyAbsolutePath, + int managedAssemblyArgc, + const char** managedAssemblyArgv) { // Indicates failure int exitCode = -1; @@ -313,10 +310,10 @@ int ExecuteManagedAssembly( coreClrDllPath.append(coreClrDll); if (coreClrDllPath.length() >= PATH_MAX) - { - fprintf(stderr, "Absolute path to libcoreclr.so too long\n"); - return -1; - } + { + fprintf(stderr, "Absolute path to libcoreclr.so too long\n"); + return -1; + } // Get just the path component of the managed assembly path std::string appPath; @@ -327,14 +324,14 @@ int ExecuteManagedAssembly( std::string nativeDllSearchDirs(appPath); char *coreLibraries = getenv("CORE_LIBRARIES"); if (coreLibraries) + { + nativeDllSearchDirs.append(":"); + nativeDllSearchDirs.append(coreLibraries); + if (std::strcmp(coreLibraries, clrFilesAbsolutePath) != 0) { - nativeDllSearchDirs.append(":"); - nativeDllSearchDirs.append(coreLibraries); - if (std::strcmp(coreLibraries, clrFilesAbsolutePath) != 0) - { - AddFilesFromDirectoryToTpaList(coreLibraries, tpaList); - } + AddFilesFromDirectoryToTpaList(coreLibraries, tpaList); } + } nativeDllSearchDirs.append(":"); nativeDllSearchDirs.append(clrFilesAbsolutePath); @@ -342,123 +339,121 @@ int ExecuteManagedAssembly( void* coreclrLib = dlopen(coreClrDllPath.c_str(), RTLD_NOW | RTLD_LOCAL); if (coreclrLib != nullptr) - { - coreclr_initialize_ptr initializeCoreCLR = (coreclr_initialize_ptr)dlsym(coreclrLib, "coreclr_initialize"); - coreclr_execute_assembly_ptr executeAssembly = (coreclr_execute_assembly_ptr)dlsym(coreclrLib, "coreclr_execute_assembly"); - coreclr_shutdown_ptr shutdownCoreCLR = (coreclr_shutdown_ptr)dlsym(coreclrLib, "coreclr_shutdown"); + { + coreclr_initialize_ptr initializeCoreCLR = (coreclr_initialize_ptr)dlsym(coreclrLib, "coreclr_initialize"); + coreclr_execute_assembly_ptr executeAssembly = (coreclr_execute_assembly_ptr)dlsym(coreclrLib, "coreclr_execute_assembly"); + coreclr_shutdown_ptr shutdownCoreCLR = (coreclr_shutdown_ptr)dlsym(coreclrLib, "coreclr_shutdown"); - if (initializeCoreCLR == nullptr) - { - fprintf(stderr, "Function coreclr_initialize not found in the libcoreclr.so\n"); - } - else if (executeAssembly == nullptr) - { - fprintf(stderr, "Function coreclr_execute_assembly not found in the libcoreclr.so\n"); - } - else if (shutdownCoreCLR == nullptr) - { - fprintf(stderr, "Function coreclr_shutdown not found in the libcoreclr.so\n"); - } + if (initializeCoreCLR == nullptr) + { + fprintf(stderr, "Function coreclr_initialize not found in the libcoreclr.so\n"); + } + else if (executeAssembly == nullptr) + { + fprintf(stderr, "Function coreclr_execute_assembly not found in the libcoreclr.so\n"); + } + else if (shutdownCoreCLR == nullptr) + { + fprintf(stderr, "Function coreclr_shutdown not found in the libcoreclr.so\n"); + } + else + { + // Check whether we are enabling server GC (off by default) + const char* useServerGc = std::getenv(serverGcVar); + if (useServerGc == nullptr) + { + useServerGc = "0"; + } + + // CoreCLR expects strings "true" and "false" instead of "1" and "0". + useServerGc = std::strcmp(useServerGc, "1") == 0 ? "true" : "false"; + + // Allowed property names: + // APPBASE + // - The base path of the application from which the exe and other assemblies will be loaded + // + // TRUSTED_PLATFORM_ASSEMBLIES + // - The list of complete paths to each of the fully trusted assemblies + // + // APP_PATHS + // - The list of paths which will be probed by the assembly loader + // + // APP_NI_PATHS + // - The list of additional paths that the assembly loader will probe for ngen images + // + // NATIVE_DLL_SEARCH_DIRECTORIES + // - The list of paths that will be probed for native DLLs called by PInvoke + // + const char *propertyKeys[] = { + "TRUSTED_PLATFORM_ASSEMBLIES", + "APP_PATHS", + "APP_NI_PATHS", + "NATIVE_DLL_SEARCH_DIRECTORIES", + "System.GC.Server", + }; + const char *propertyValues[] = { + // TRUSTED_PLATFORM_ASSEMBLIES + tpaList.c_str(), + // APP_PATHS + appPath.c_str(), + // APP_NI_PATHS + appPath.c_str(), + // NATIVE_DLL_SEARCH_DIRECTORIES + nativeDllSearchDirs.c_str(), + // System.GC.Server + useServerGc, + }; + + void* hostHandle; + unsigned int domainId; + + int st = initializeCoreCLR(currentExeAbsolutePath, + "unixcorerun", + sizeof(propertyKeys) / sizeof(propertyKeys[0]), + propertyKeys, + propertyValues, + &hostHandle, + &domainId); + + if (!SUCCEEDED(st)) + { + fprintf(stderr, "coreclr_initialize failed - status: 0x%08x\n", st); + exitCode = -1; + } else + { + st = executeAssembly(hostHandle, + domainId, + managedAssemblyArgc, + managedAssemblyArgv, + managedAssemblyAbsolutePath, + (unsigned int*)&exitCode); + + if (!SUCCEEDED(st)) { - // Check whether we are enabling server GC (off by default) - const char* useServerGc = std::getenv(serverGcVar); - if (useServerGc == nullptr) - { - useServerGc = "0"; - } - - // CoreCLR expects strings "true" and "false" instead of "1" and "0". - useServerGc = std::strcmp(useServerGc, "1") == 0 ? "true" : "false"; - - // Allowed property names: - // APPBASE - // - The base path of the application from which the exe and other assemblies will be loaded - // - // TRUSTED_PLATFORM_ASSEMBLIES - // - The list of complete paths to each of the fully trusted assemblies - // - // APP_PATHS - // - The list of paths which will be probed by the assembly loader - // - // APP_NI_PATHS - // - The list of additional paths that the assembly loader will probe for ngen images - // - // NATIVE_DLL_SEARCH_DIRECTORIES - // - The list of paths that will be probed for native DLLs called by PInvoke - // - const char *propertyKeys[] = { - "TRUSTED_PLATFORM_ASSEMBLIES", - "APP_PATHS", - "APP_NI_PATHS", - "NATIVE_DLL_SEARCH_DIRECTORIES", - "System.GC.Server", - }; - const char *propertyValues[] = { - // TRUSTED_PLATFORM_ASSEMBLIES - tpaList.c_str(), - // APP_PATHS - appPath.c_str(), - // APP_NI_PATHS - appPath.c_str(), - // NATIVE_DLL_SEARCH_DIRECTORIES - nativeDllSearchDirs.c_str(), - // System.GC.Server - useServerGc, - }; - - void* hostHandle; - unsigned int domainId; - - int st = initializeCoreCLR( - currentExeAbsolutePath, - "unixcorerun", - sizeof(propertyKeys) / sizeof(propertyKeys[0]), - propertyKeys, - propertyValues, - &hostHandle, - &domainId); - - if (!SUCCEEDED(st)) - { - fprintf(stderr, "coreclr_initialize failed - status: 0x%08x\n", st); - exitCode = -1; - } - else - { - st = executeAssembly( - hostHandle, - domainId, - managedAssemblyArgc, - managedAssemblyArgv, - managedAssemblyAbsolutePath, - (unsigned int*)&exitCode); - - if (!SUCCEEDED(st)) - { - fprintf(stderr, "coreclr_execute_assembly failed - status: 0x%08x\n", st); - exitCode = -1; - } - - st = shutdownCoreCLR(hostHandle, domainId); - if (!SUCCEEDED(st)) - { - fprintf(stderr, "coreclr_shutdown failed - status: 0x%08x\n", st); - exitCode = -1; - } - } + fprintf(stderr, "coreclr_execute_assembly failed - status: 0x%08x\n", st); + exitCode = -1; } - if (dlclose(coreclrLib) != 0) + st = shutdownCoreCLR(hostHandle, domainId); + if (!SUCCEEDED(st)) { - fprintf(stderr, "Warning - dlclose failed\n"); + fprintf(stderr, "coreclr_shutdown failed - status: 0x%08x\n", st); + exitCode = -1; } + } } - else + + if (dlclose(coreclrLib) != 0) { - const char* error = dlerror(); - fprintf(stderr, "dlopen failed to open the libcoreclr.so with error %s\n", error); + fprintf(stderr, "Warning - dlclose failed\n"); } + } + else + { + const char* error = dlerror(); + fprintf(stderr, "dlopen failed to open the libcoreclr.so with error %s\n", error); + } return exitCode; } @@ -467,8 +462,7 @@ int ExecuteManagedAssembly( // Display the help text void DisplayUsage() { - fprintf( - stderr, + fprintf(stderr, "Runs executables on CoreCLR\n\n" "Usage: [OPTIONS] [ARGUMENTS]\n" "Runs .dll on CoreCLR.\n\n" @@ -492,52 +486,52 @@ bool ParseArguments( *managedAssemblyArgc = 0; for (int i = 1; i < argc; i++) + { + // Check for options. Options to the Unix coreconsole are prefixed with '-_' to match the convention + // used in the Windows version of coreconsole. + if (strncmp(argv[i], "-_", 2) == 0) { - // Check for options. Options to the Unix coreconsole are prefixed with '-_' to match the convention - // used in the Windows version of coreconsole. - if (strncmp(argv[i], "-_", 2) == 0) + // Path to the libcoreclr.so and the managed CLR assemblies + if (strcmp(argv[i], "-_c") == 0) + { + i++; + if (i < argc) { - // Path to the libcoreclr.so and the managed CLR assemblies - if (strcmp(argv[i], "-_c") == 0) - { - i++; - if (i < argc) - { - *clrFilesPath = argv[i]; - } - else - { - fprintf(stderr, "Option %s: missing path\n", argv[i - 1]); - success = false; - break; - } - } - else if (strcmp(argv[i], "-_h") == 0) - { - DisplayUsage(); - success = false; - break; - } - else - { - fprintf(stderr, "Unknown option %s\n", argv[i]); - success = false; - break; - } + *clrFilesPath = argv[i]; } - else + else { - // We treat everything starting from the first non-option argument as arguments - // to the managed assembly. - *managedAssemblyArgc = argc - i; - if (*managedAssemblyArgc != 0) - { - *managedAssemblyArgv = &argv[i]; - } - + fprintf(stderr, "Option %s: missing path\n", argv[i - 1]); + success = false; break; } + } + else if (strcmp(argv[i], "-_h") == 0) + { + DisplayUsage(); + success = false; + break; + } + else + { + fprintf(stderr, "Unknown option %s\n", argv[i]); + success = false; + break; + } + } + else + { + // We treat everything starting from the first non-option argument as arguments + // to the managed assembly. + *managedAssemblyArgc = argc - i; + if (*managedAssemblyArgc != 0) + { + *managedAssemblyArgv = &argv[i]; + } + + break; } + } return success; } @@ -550,7 +544,8 @@ int main(const int argc, const char* argv[]) // This routine check whether _SCD_DEBUG_ flag is set(1) or not. // In second pass, this routine is skipped. - if (second_pass == NULL) { + if (second_pass == NULL) + { // run service_app routine to extract _SCD_DEBUG_ char ad[50] = {0,}; service_app_lifecycle_callback_s event_callback; @@ -564,7 +559,8 @@ int main(const int argc, const char* argv[]) vector vargs; int status = 0; - if (isDebugMode) { + if (isDebugMode) + { dlog_print(DLOG_INFO,"dotnet","debugmode on\n"); setenv("CORECLR_GDBJIT", *coreclr_gdbjit, 1); @@ -583,37 +579,37 @@ int main(const int argc, const char* argv[]) vargs.push_back(buf); // Pass app argument to lldb-server as it is - for (int i=1; i Handlers; @@ -134,31 +139,31 @@ static void Fd_Remove(void *data, int fd) static void PreloadLibsAndWindow(bundle *extra, int type, void *user_data) { - int elm_init_cnt = 0; + int elm_init_cnt = 0; const char **so_array; int len = 0; int i; void *handle = NULL; // Preload native libraries - if (extra == NULL) { - _DBG("No extra data"); - return; - } + if (extra == NULL) { + _DBG("No extra data"); + return; + } - so_array = bundle_get_str_array(extra, "preload", &len); + so_array = bundle_get_str_array(extra, "preload", &len); - if (!so_array) - return; + if (!so_array) + return; - for (i = 0; i < len; i++) { - handle = dlopen(so_array[i], RTLD_NOW); - _DBG("preload %s# - handle : %x", so_array[i], handle); - } + for (i = 0; i < len; i++) { + handle = dlopen(so_array[i], RTLD_NOW); + _DBG("preload %s# - handle : %x", so_array[i], handle); + } // Precreate window - elm_init_cnt = elm_init(__argc, __argv); - _DBG("[candidate] elm init, returned: %d", elm_init_cnt); + elm_init_cnt = elm_init(__argc, __argv); + _DBG("[candidate] elm init, returned: %d", elm_init_cnt); elm_config_accel_preference_set("hw"); diff --git a/NativeLauncher/launcher/main.cc b/NativeLauncher/launcher/main.cc index 9bd024c..a25eaae 100644 --- a/NativeLauncher/launcher/main.cc +++ b/NativeLauncher/launcher/main.cc @@ -109,8 +109,8 @@ int main(int argc, char *argv[]) char** args = &vargs[0]; if (runtime->Launch(appid, approot.c_str(), standalonePath, args_len, args)) { - _ERR("Failed to launch"); - return 0; + _ERR("Failed to launch"); + return 0; } } else diff --git a/Tizen.Runtime/Tizen.Runtime.Coreclr.csproj b/Tizen.Runtime/Tizen.Runtime.Coreclr.csproj index 6bf5754..c08b73f 100644 --- a/Tizen.Runtime/Tizen.Runtime.Coreclr.csproj +++ b/Tizen.Runtime/Tizen.Runtime.Coreclr.csproj @@ -1,12 +1,12 @@ - - - Debug - AnyCPU - library - Tizen.Runtime.Coreclr - + + + Debug + AnyCPU + library + Tizen.Runtime.Coreclr + .NETStandard @@ -17,47 +17,47 @@ $(NoWarn);1701;1702 - - true - full - bin/ - DEBUG;TRACE - + + true + full + bin/ + DEBUG;TRACE + - - pdbonly - true - bin/ + + pdbonly + true + bin/ TRACE - + - - $(DefineConstants);CLOG - + + $(DefineConstants);CLOG + - - - - - - + + + + + + - - - + + + - +