From bd5c5f3430720a35e67306bab83e9903bb4803de Mon Sep 17 00:00:00 2001 From: JongHeon Choi Date: Thu, 30 Mar 2017 13:40:14 +0900 Subject: [PATCH 01/16] Remove the Mono profile Change-Id: If5ce5c0b76d626cfd38cfe607f20b277909f32db --- NativeLauncher/CMakeLists.txt | 5 - NativeLauncher/launcher/main.cc | 22 +- NativeLauncher/launcher/mono/mono_launcher.cc | 264 --------------------- NativeLauncher/launcher/mono/mono_launcher.h | 98 -------- README.md | 18 +- Tizen.Runtime/Tizen.Runtime.Mono.csproj | 75 ------ Tizen.Runtime/Tizen.Runtime.Mono.project.json | 11 - .../Tizen.Runtime.Mono/AssemblyManager.cs | 169 ------------- packaging/dotnet-launcher.spec | 9 - 9 files changed, 12 insertions(+), 659 deletions(-) delete mode 100644 NativeLauncher/launcher/mono/mono_launcher.cc delete mode 100644 NativeLauncher/launcher/mono/mono_launcher.h delete mode 100644 Tizen.Runtime/Tizen.Runtime.Mono.csproj delete mode 100644 Tizen.Runtime/Tizen.Runtime.Mono.project.json delete mode 100644 Tizen.Runtime/Tizen.Runtime.Mono/AssemblyManager.cs diff --git a/NativeLauncher/CMakeLists.txt b/NativeLauncher/CMakeLists.txt index 6799712..0d4e53b 100755 --- a/NativeLauncher/CMakeLists.txt +++ b/NativeLauncher/CMakeLists.txt @@ -22,10 +22,6 @@ IF(DEFINED 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 MONO_LAUNCHER_ASSEMBLY_PATH) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DMONO_LAUNCHER_ASSEMBLY_PATH=${MONO_LAUNCHER_ASSEMBLY_PATH}") -ENDIF(DEFINED MONO_LAUNCHER_ASSEMBLY_PATH) - IF(DEFINED DEVICE_API_DIR) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DDEVICE_API_DIR=${DEVICE_API_DIR}") ENDIF(DEFINED DEVICE_API_DIR) @@ -65,7 +61,6 @@ SET(${DOTNET_LAUNCHER}_SOURCE_FILES util/utils.cc launcher/launcher.cc launcher/dotnet/dotnet_launcher.cc - launcher/mono/mono_launcher.cc ) ADD_EXECUTABLE(${DOTNET_LAUNCHER} ${${DOTNET_LAUNCHER}_SOURCE_FILES}) SET_TARGET_PROPERTIES(${DOTNET_LAUNCHER} PROPERTIES COMPILE_FLAGS "-fPIE") diff --git a/NativeLauncher/launcher/main.cc b/NativeLauncher/launcher/main.cc index 5c1ba49..c39b3e8 100644 --- a/NativeLauncher/launcher/main.cc +++ b/NativeLauncher/launcher/main.cc @@ -15,7 +15,6 @@ */ #include "dotnet/dotnet_launcher.h" -#include "mono/mono_launcher.h" #include "utils.h" #include "log.h" @@ -90,24 +89,9 @@ int main(int argc, char *argv[]) using tizen::runtime::AppInfo; std::unique_ptr runtime; - bool useMono = !FileNotExist("/etc/.use_mono"); - - if (!useMono) - { - using tizen::runtime::dotnetcore::CoreRuntime; - std::unique_ptr coreRuntime(new CoreRuntime()); - runtime = std::move(coreRuntime); - - _DBG("##### CoreCLR Launcher ######"); - } - else - { - using tizen::runtime::mono::MonoRuntime; - std::unique_ptr monoRuntime(new MonoRuntime()); - runtime = std::move(monoRuntime); - - _DBG("##### Mono Launcher ######"); - } + using tizen::runtime::dotnetcore::CoreRuntime; + std::unique_ptr coreRuntime(new CoreRuntime()); + runtime = std::move(coreRuntime); if (standalone) { diff --git a/NativeLauncher/launcher/mono/mono_launcher.cc b/NativeLauncher/launcher/mono/mono_launcher.cc deleted file mode 100644 index 97813b3..0000000 --- a/NativeLauncher/launcher/mono/mono_launcher.cc +++ /dev/null @@ -1,264 +0,0 @@ -/* - * 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. - */ - - -#include "mono_launcher.h" -#include "utils.h" -#include "log.h" - -#include -#include - -namespace tizen { -namespace runtime { -namespace mono { - -static const char* DOMAIN_NAME = "tizen_mono_domain"; -static const char* LIBMONO = "/usr/lib/libmono-2.0.so.1"; - -MonoRuntime::MonoRuntime() : - monolib(nullptr), - domain(nullptr), - launch(nullptr) -{ - -#define __XSTR(x) #x -#define __STR(x) __XSTR(x) - -#ifdef MONO_LAUNCHER_ASSEMBLY_PATH - launcherAssemblyPath = __STR(MONO_LAUNCHER_ASSEMBLY_PATH); -#endif - -#ifdef DEVICE_API_DIR - deviceAPIDirectory = __STR(DEVICE_API_DIR); -#endif -#ifdef RUNTIME_DIR - runtimeDirectory = __STR(RUNTIME_DIR); -#endif - -#undef __STR -#undef __XSTR -} - -MonoRuntime::~MonoRuntime() -{ - Dispose(); -} - -int MonoRuntime::Initialize(bool standalone) -{ - if (standalone) - { - const char *_deviceapi_directory = getenv("DeviceAPIDirectory"); - const char *_runtime_directory = getenv("RuntimeDirectory"); - const char *_launcher_assembly = getenv("LauncherAssembly"); - if (_deviceapi_directory != nullptr) - deviceAPIDirectory = _deviceapi_directory; - if (_runtime_directory != nullptr) - runtimeDirectory = _runtime_directory; - if (_launcher_assembly != nullptr) - launcherAssemblyPath = _launcher_assembly; - } - - if (FileNotExist(LIBMONO)) - { - _DBG("mono is not exist in %s", LIBMONO); - return 1; - } - - monolib = dlopen(LIBMONO, RTLD_LAZY); -#define MONOLIB_RETURN_IF_NOSYM(type, variable, name) \ - do { \ - variable = (type)dlsym(monolib, name); \ - if (variable == nullptr) { \ - _ERR(name " is not found in libmono"); \ - return 1; \ - }} while(0) - - MONOLIB_RETURN_IF_NOSYM(mono_set_dirs_ptr, SetDirs, "mono_set_dirs"); - MONOLIB_RETURN_IF_NOSYM(mono_set_assemblies_path_ptr, SetAssembliesPath, "mono_set_assemblies_path"); - MONOLIB_RETURN_IF_NOSYM(mono_jit_init_ptr, JitInit, "mono_jit_init"); - MONOLIB_RETURN_IF_NOSYM(mono_domain_assembly_open_ptr, DomainAssemblyOpen, "mono_domain_assembly_open"); - MONOLIB_RETURN_IF_NOSYM(mono_assembly_get_image_ptr, AssemblyGetImage, "mono_assembly_get_image"); - MONOLIB_RETURN_IF_NOSYM(mono_class_from_name_ptr, ClassFromName, "mono_class_from_name"); - MONOLIB_RETURN_IF_NOSYM(mono_runtime_invoke_ptr, RuntimeInvoke, "mono_runtime_invoke"); - MONOLIB_RETURN_IF_NOSYM(mono_class_get_method_from_name_ptr, ClassGetMethodFromName, "mono_class_get_method_from_name"); - MONOLIB_RETURN_IF_NOSYM(mono_object_to_string_ptr, ObjectToString, "mono_object_to_string"); - MONOLIB_RETURN_IF_NOSYM(mono_string_to_utf8_ptr, StringToUtf8, "mono_string_to_utf8"); - MONOLIB_RETURN_IF_NOSYM(mono_string_new_ptr, NewString, "mono_string_new"); - MONOLIB_RETURN_IF_NOSYM(mono_get_string_class_ptr, GetStringClass, "mono_get_string_class"); - MONOLIB_RETURN_IF_NOSYM(mono_array_new_ptr, ArrayNew, "mono_array_new"); - MONOLIB_RETURN_IF_NOSYM(mono_array_addr_with_size_ptr, ArrayAddrWithSize, "mono_array_addr_with_size"); - MONOLIB_RETURN_IF_NOSYM(mono_jit_cleanup_ptr, DomainCleanup, "mono_jit_cleanup"); - MONOLIB_RETURN_IF_NOSYM(mono_jit_exec_ptr, AssemblyExec, "mono_jit_exec"); - -#undef MONOLIB_RETURN_IF_NOSYM - - _DBG("libmono dlopen and dlsym success"); - - return 0; -} - -void MonoRuntime::Dispose() -{ - if (domain != nullptr) - { - DomainCleanup(domain); - } - if (monolib != nullptr && dlclose(monolib) != 0) - { - _ERR("libmono close failed"); - } - monolib = nullptr; -} - -int MonoRuntime::RunManagedLauncher() -{ - if (FileNotExist(launcherAssemblyPath.c_str())) - { - _ERR("Launcher Assembly is not exist in %s", launcherAssemblyPath.c_str()); - return 1; - } - -// _DBG("mono_set_dirs(\"%s\", nullptr);", runtimeDirectory.c_str()); -// _DBG("mono_set_assemblies_path(\"%s\");", deviceAPIDirectory.c_str()); - -// SetDirs(runtimeDirectory.c_str(), nullptr); -/* - std::string assembliesPath = runtimeDirectory+":"+deviceAPIDirectory; - _DBG("assembliesPath : %s", assembliesPath.c_str()); - SetAssembliesPath(assembliesPath.c_str()); - */ - SetAssembliesPath(deviceAPIDirectory.c_str()); - - domain = JitInit(DOMAIN_NAME); - if (domain == nullptr) - { - _ERR("Failed to init mono jit"); - return 1; - } - - launcherAssembly = DomainAssemblyOpen(domain, launcherAssemblyPath.c_str()); - if (launcherAssembly == nullptr) - { - _ERR("Failed to Load Launcher Assembly"); - return 1; - } - - monoImage = AssemblyGetImage(launcherAssembly); - if (monoImage == nullptr) - { - _ERR("Failed to get image from launcher assembly"); - return 1; - } - - assemblyManagerClass = ClassFromName(monoImage, "Tizen.Runtime.Mono", "AssemblyManager"); - if (assemblyManagerClass == nullptr) - { - _ERR("Failed to get AssemblyManager class in namespace Tizen.Runtime.Mono from launcher image"); - return 1; - } - - prepareLaunch = ClassGetMethodFromName(assemblyManagerClass, "Prepared", 0); - if (prepareLaunch == nullptr) - { - _ERR("Failed to get Prepared() method from Tizen.Runtime.Mono.AssemblyManager"); - return 1; - } - MonoObject* exception = nullptr; - RuntimeInvoke(prepareLaunch, nullptr, nullptr, &exception); - if (exception != nullptr) - { - MonoString * exceptionMsg = ObjectToString(exception, nullptr); - char* cstringMsg = StringToUtf8(exceptionMsg); - _ERR("Failed to invoke method in runtime"); - _ERR("%s", cstringMsg); - free(cstringMsg); - return 1; - } - - launch = ClassGetMethodFromName(assemblyManagerClass, "Launch", 4); - - return 0; -} - -#define ArrayAddr(array,type,index) ((type*)(void*) ArrayAddrWithSize (array, sizeof (type), index)) -#define ArraySet(array,type,index,value) \ - do { \ - type *__p = (type *) ArrayAddr ((array), type, (index)); \ - *__p = (value); \ - } while (0) - -int MonoRuntime::Launch(const char* root, const char* path, int argc, char* argv[]) -{ - if (domain == nullptr) - { - domain = JitInit(DOMAIN_NAME); - if (domain == nullptr) - { - _ERR("Failed to init mono jit"); - return 1; - } - } - if (launch != nullptr) - { - MonoString *rootMonoString = NewString(domain, root); - MonoString *pathMonoString = NewString(domain, path); - MonoArray *argvMonoArray = ArrayNew(domain, GetStringClass(), argc); - for (int i=0; i - - - - Debug - AnyCPU - library - Tizen.Runtime.Mono - v4.5 - - - - true - full - bin/ - DEBUG;TRACE - - - - pdbonly - true - bin/ - TRACE - - - - - - $(DefineConstants);CLOG - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_Parameter1>PreloadPath=$(PreloadPath) - - - - - - - - - diff --git a/Tizen.Runtime/Tizen.Runtime.Mono.project.json b/Tizen.Runtime/Tizen.Runtime.Mono.project.json deleted file mode 100644 index 710ecfa..0000000 --- a/Tizen.Runtime/Tizen.Runtime.Mono.project.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "dependencies": { - }, - "frameworks": { - "net45": {} - }, - "runtimes": { - "win": {} - } -} - diff --git a/Tizen.Runtime/Tizen.Runtime.Mono/AssemblyManager.cs b/Tizen.Runtime/Tizen.Runtime.Mono/AssemblyManager.cs deleted file mode 100644 index 441317a..0000000 --- a/Tizen.Runtime/Tizen.Runtime.Mono/AssemblyManager.cs +++ /dev/null @@ -1,169 +0,0 @@ -/* - * 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. - */ - -using System; -using System.IO; -using System.Collections.Generic; -using System.Reflection; -using System.Runtime.InteropServices; -using Tizen.Runtime; - -namespace Tizen.Runtime.Mono -{ - public static class AssemblyManager - { - - private static SortedSet ResolveDirectories = new SortedSet(); - private static SortedSet ResolveFiles = new SortedSet(); - - public static bool Launch( - [In] string rootPath, - [In] string path, - [In] int argc, - [MarshalAs(UnmanagedType.LPArray, SizeParamIndex=2)] - [In] string[] argv) - { - ALog.Debug($"Application Launch path : {path}"); - try - { - DirectoryInfo bindir = new DirectoryInfo(Path.Combine(rootPath, "bin")); - DirectoryInfo libdir = new DirectoryInfo(Path.Combine(rootPath, "lib")); - if (Directory.Exists(bindir.FullName)) - { - ResolveDirectories.Add(bindir.FullName); - } - if (Directory.Exists(libdir.FullName)) - { - ResolveDirectories.Add(libdir.FullName); - } - ResolveFiles.Add(path); - Execute(path, argv); - } - catch(Exception e) - { - ALog.Debug("Exception in Launch()"); - PrintException(e); - return false; - } - - return true; - } - - static readonly string[] assemblyExtensions = {".dll", ".exe"}; - - public static Assembly AssemblyResolverHandler(object sender, ResolveEventArgs args) - { - // find dll name + ext in paths for resolving - foreach (string path in ResolveDirectories) - { - foreach (string ext in assemblyExtensions) - { - string assemblyPath = Path.Combine(path, new AssemblyName(args.Name).Name + ext); - if (File.Exists(assemblyPath)) - { - Assembly assembly = Assembly.LoadFrom(assemblyPath); - return assembly; - } - } - } - - return null; - } - - public static void Prepared() - { - try - { - string preloadPath = ""; - ICustomAttributeProvider assembly = typeof(AssemblyManager).GetTypeInfo().Assembly; - var attributes = assembly.GetCustomAttributes(typeof(DefaultConfigAttribute), false); - foreach (DefaultConfigAttribute dca in attributes) - { - ALog.Debug($"{dca.Key} = {dca.Value}"); - if (dca.Key == "PreloadPath") - { - preloadPath = dca.Value; - } - } - - if (!Initialize(preloadPath)) - { - ALog.Debug($"Failed to Initialized with {preloadPath}"); - } - - AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolverHandler; - } - catch(Exception e) - { - ALog.Debug("Exception at Preparing"); - PrintException(e); - } - } - - private static void PrintException(Exception exception) - { - while (exception != null) - { - ALog.Debug(exception.ToString()); - exception = exception.InnerException; - } - } - - public static bool Initialize(string preloadDirectory) - { - try - { - if (!string.IsNullOrEmpty(preloadDirectory)) - { - ALog.Debug($"Load from [{preloadDirectory}]"); - DirectoryInfo d = new DirectoryInfo(preloadDirectory); - if (Directory.Exists(d.FullName)) - { - ResolveDirectories.Add(d.FullName); - } - } - } - catch (Exception e) - { - ALog.Debug("Exception on Initialized"); - PrintException(e); - return false; - } - return true; - } - - - public static void Execute(string dllPath, string[] argv) - { - try - { - FileInfo f = new FileInfo(dllPath); - if (File.Exists(f.FullName)) - { - Assembly asm = Assembly.LoadFile(f.FullName); - if (asm.EntryPoint == null) throw new ArgumentException($"{f.FullName} did not have EntryPoint"); - asm.EntryPoint.Invoke(null, new object[]{argv}); - } - } - catch (Exception e) - { - ALog.Debug("Exception on Execute"); - PrintException(e); - } - } - - } -} diff --git a/packaging/dotnet-launcher.spec b/packaging/dotnet-launcher.spec index 4ce5d38..78ca701 100755 --- a/packaging/dotnet-launcher.spec +++ b/packaging/dotnet-launcher.spec @@ -71,7 +71,6 @@ cmake \ -DRUNTIME_DIR=%{_runtime_dir} \ -DCROSSGEN_PATH=%{_device_api_dir}/crossgen \ -DCORECLR_LAUNCHER_ASSEMBLY_PATH=%{_bindir}/Tizen.Runtime.Coreclr.dll \ - -DMONO_LAUNCHER_ASSEMBLY_PATH=%{_bindir}/Tizen.Runtime.Mono.dll \ -DINSTALL_PLUGIN_DIR=%{_install_plugin_dir} \ -DINSTALL_MDPLUGIN_DIR=%{_install_mdplugin_dir} \ -DVERSION=%{version} \ @@ -85,17 +84,10 @@ xbuild \ /p:Configuration=%{_dotnet_build_conf} \ Tizen.Runtime/Tizen.Runtime.Coreclr.csproj -nuget restore Tizen.Runtime/Tizen.Runtime.Mono.project.json - -xbuild \ - /p:Configuration=%{_dotnet_build_conf} \ - Tizen.Runtime/Tizen.Runtime.Mono.csproj - %install rm -rf %{buildroot} %make_install install -p -m 644 Tizen.Runtime/bin/Tizen.Runtime.Coreclr.dll %{buildroot}%{_bindir} -install -p -m 644 Tizen.Runtime/bin/Tizen.Runtime.Mono.dll %{buildroot}%{_bindir} %files %manifest dotnet-launcher.manifest @@ -107,7 +99,6 @@ install -p -m 644 Tizen.Runtime/bin/Tizen.Runtime.Mono.dll %{buildroot}%{_bindir %caps(cap_mac_admin,cap_setgid=ei) %{_install_plugin_dir}/libui-application.so %caps(cap_mac_admin,cap_setgid=ei) %{_install_mdplugin_dir}/libprefer_dotnet_aot_plugin.so %caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/Tizen.Runtime.Coreclr.dll -%caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/Tizen.Runtime.Mono.dll %files -n scd-launcher %caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/scd-launcher -- 2.7.4 From 8ce95e61e681a02e1e9aa9d4c7bafa3cf7b573f5 Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Mon, 10 Apr 2017 17:39:15 +0900 Subject: [PATCH 02/16] refactoring launcher Change-Id: Ic2912985e0bf5e21d823bcf34280bd2aea2f7a54 --- NativeLauncher/CMakeLists.txt | 16 +- NativeLauncher/launcher/dotnet/dotnet_launcher.cc | 96 ++++--- NativeLauncher/launcher/dotnet/dotnet_launcher.h | 7 +- NativeLauncher/launcher/dotnet/scd_launcher.cc | 5 +- NativeLauncher/launcher/launcher.cc | 4 +- NativeLauncher/launcher/launcher.h | 4 +- NativeLauncher/launcher/main.cc | 33 +-- NativeLauncher/launcher/waiter/waiter.cc | 311 --------------------- NativeLauncher/launcher/waiter/waiter.h | 93 ------ NativeLauncher/util/utils.cc | 2 + .../Tizen.Runtime.Coreclr/AssemblyLoader.cs | 18 -- .../Tizen.Runtime.Coreclr/AssemblyManager.cs | 58 +--- packaging/dotnet-launcher.spec | 18 ++ 13 files changed, 108 insertions(+), 557 deletions(-) delete mode 100644 NativeLauncher/launcher/waiter/waiter.cc delete mode 100644 NativeLauncher/launcher/waiter/waiter.h diff --git a/NativeLauncher/CMakeLists.txt b/NativeLauncher/CMakeLists.txt index 0d4e53b..f8a1697 100755 --- a/NativeLauncher/CMakeLists.txt +++ b/NativeLauncher/CMakeLists.txt @@ -38,6 +38,20 @@ IF(DEFINED 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}") +ENDIF(DEFINED NATIVE_LIB_DIR) + +IF(USE_MANAGED_LAUNCHER STREQUAL "ENABLE") + 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") +ENDIF(NOT_USE_FUNCTION) + + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -pthread -std=c++11 -Wl,--no-as-needed -ggdb") SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs" ) #SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden") @@ -47,7 +61,7 @@ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -D_FILE_OFFSET_BITS=64") #SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DLAUNCHING_TIME_MEASURE") SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") -SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") +SET(CMAKE_CXX_FLAGS_DEBUG "-O2 -g") SET(CMAKE_CXX_FLAGS_RELEASE "-O2") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc index cb9fcd0..15b74c9 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc @@ -50,9 +50,15 @@ CoreRuntime::CoreRuntime() : #ifdef RUNTIME_DIR RuntimeDirectory = __STR(RUNTIME_DIR); #endif +#ifdef NATIVE_LIB_DIR + NativeLibDirectory = __STR(NATIVE_LIB_DIR); +#endif + +#ifdef USE_MANAGED_LAUNCHER #ifdef CORECLR_LAUNCHER_ASSEMBLY_PATH LauncherAssembly = __STR(CORECLR_LAUNCHER_ASSEMBLY_PATH); #endif +#endif #undef __STR #undef __XSTR @@ -72,13 +78,16 @@ int CoreRuntime::Initialize(bool standalone) { const char *_deviceapi_directory = getenv("DeviceAPIDirectory"); const char *_runtime_directory = getenv("RuntimeDirectory"); - const char *_launcher_assembly = getenv("LauncherAssembly"); if (_deviceapi_directory != nullptr) DeviceAPIDirectory = _deviceapi_directory; if (_runtime_directory != nullptr) RuntimeDirectory = _runtime_directory; + +#ifdef USE_MANAGED_LAUNCHER + const char *_launcher_assembly = getenv("LauncherAssembly"); if (_launcher_assembly != nullptr) LauncherAssembly = _launcher_assembly; +#endif } if (DeviceAPIDirectory.empty()) @@ -90,6 +99,7 @@ int CoreRuntime::Initialize(bool standalone) { DeviceAPIDirectory = AbsolutePath(DeviceAPIDirectory); } + if (RuntimeDirectory.empty()) { _ERR("Empty Runtime Directory"); @@ -99,6 +109,8 @@ int CoreRuntime::Initialize(bool standalone) { RuntimeDirectory = AbsolutePath(RuntimeDirectory); } + +#ifdef USE_MANAGED_LAUNCHER if (LauncherAssembly.empty()) { _ERR("Empty Launcher Assembly"); @@ -108,6 +120,7 @@ int CoreRuntime::Initialize(bool standalone) { LauncherAssembly = AbsolutePath(LauncherAssembly); } +#endif std::string libcoreclr(ConcatPath(RuntimeDirectory, "libcoreclr.so")); @@ -143,15 +156,11 @@ int CoreRuntime::Initialize(bool standalone) return 0; } -bool CoreRuntime::InitializeCoreClr(const char* assembly_probe_paths, const char* pinvoke_probe_paths) +bool CoreRuntime::InitializeCoreClr(const char* app_id, + const char* assembly_probe_paths, + const char* pinvoke_probe_paths, + const char* tpa_list) { - std::vector platformDirectories = { - RuntimeDirectory, DeviceAPIDirectory - }; - - std::string trusted_assemblies; - AssembliesInDirectory(platformDirectories, trusted_assemblies); - const char *propertyKeys[] = { "TRUSTED_PLATFORM_ASSEMBLIES", @@ -163,7 +172,7 @@ bool CoreRuntime::InitializeCoreClr(const char* assembly_probe_paths, const char const char *propertyValues[] = { - trusted_assemblies.c_str(), + tpa_list, assembly_probe_paths, assembly_probe_paths, pinvoke_probe_paths, @@ -174,7 +183,7 @@ bool CoreRuntime::InitializeCoreClr(const char* assembly_probe_paths, const char int st = InitializeClr( selfPath.c_str(), - "dotnet-launcher", + app_id, sizeof(propertyKeys) / sizeof(propertyKeys[0]), propertyKeys, propertyValues, @@ -191,7 +200,7 @@ bool CoreRuntime::InitializeCoreClr(const char* assembly_probe_paths, const char return true; } -int CoreRuntime::RunManagedLauncher() +int CoreRuntime::RunManagedLauncher(const char* app_id, const char* app_base, const char* tpa_list) { if (FileNotExist(LauncherAssembly)) { @@ -199,24 +208,13 @@ int CoreRuntime::RunManagedLauncher() return 1; } - std::string launcherDir = Basename(LauncherAssembly); - std::vector searchDirectories = { - RuntimeDirectory, DeviceAPIDirectory - }; - - std::string trusted_directories = JoinStrings(searchDirectories, ":"); - - _DBG("coreclr_dir : %s", RuntimeDirectory.c_str()); - _DBG("native_so_search_dir : %s", trusted_directories.c_str()); - _DBG("launcher_assembly : %s", LauncherAssembly.c_str()); - _DBG("launcher_dir : %s", launcherDir.c_str()); - - if (!InitializeCoreClr(launcherDir.c_str(), launcherDir.c_str())) + if (!InitializeCoreClr(app_id, app_base, app_base, tpa_list)) { _ERR("Failed to initialize coreclr"); return 1; } +#ifdef USE_MANAGED_LAUNCHER void *preparedFunctionDelegate; int st = CreateDelegate(hostHandle, domainId, "Tizen.Runtime.Coreclr", @@ -245,7 +243,7 @@ int CoreRuntime::RunManagedLauncher() return 1; } LaunchFunction = reinterpret_cast(launchFunctionDelegate); - +#endif return 0; } @@ -269,7 +267,7 @@ void CoreRuntime::Dispose() _DBG("Dotnet runtime disposed"); } -int CoreRuntime::Launch(const char* root, const char* path, int argc, char* argv[]) +int CoreRuntime::Launch(const char* app_id, const char* root, const char* path, int argc, char* argv[]) { if (path == nullptr) { @@ -295,6 +293,25 @@ int CoreRuntime::Launch(const char* root, const char* path, int argc, char* argv return 1; } + std::vector searchDirectories = { + RuntimeDirectory, DeviceAPIDirectory +#ifdef USE_MANAGED_LAUNCHER + , Basename(LauncherAssembly) +#endif + }; + + //std::string trusted_directories = JoinStrings(searchDirectories, ":"); + std::string tpa; + AssembliesInDirectory(searchDirectories, tpa); + + std::string appRoot = root; + std::string appBin = ConcatPath(appRoot, "bin"); + std::string appLib = ConcatPath(appRoot, "lib"); + std::string probePath = appBin + ":" + appLib + ":" + NativeLibDirectory; + +#ifdef USE_MANAGED_LAUNCHER + RunManagedLauncher(app_id, probePath.c_str(), tpa.c_str()); + bool success = false; if (LaunchFunction != nullptr) { @@ -307,20 +324,19 @@ int CoreRuntime::Launch(const char* root, const char* path, int argc, char* argv } else { - std::string appRoot = root; - std::string appBin = ConcatPath(appRoot, "bin"); - std::string appLib = ConcatPath(appRoot, "lib"); - std::string probePath = appBin + ":" + appLib; - - int st = InitializeCoreClr(probePath.c_str(), probePath.c_str()); - unsigned int ret = 0; - st = ExecuteAssembly(hostHandle, domainId, argc, (const char**)argv, path, &ret); - if (st < 0) - { - _ERR("Failed to Execute Assembly %s (0x%08x)", path, st); - } - return ret; + _ERR("Failed to find launch function"); + return 1; } +#else + int st = InitializeCoreClr(app_id, probePath.c_str(), probePath.c_str(), tpa.c_str()); + unsigned int ret = 0; + st = ExecuteAssembly(hostHandle, domainId, argc, (const char**)argv, path, &ret); + if (st < 0) + { + _ERR("Failed to Execute Assembly %s (0x%08x)", path, st); + } + return ret; +#endif } } // namespace dotnetcore diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.h b/NativeLauncher/launcher/dotnet/dotnet_launcher.h index 31a8c4a..27d1298 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.h +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.h @@ -62,11 +62,11 @@ class CoreRuntime : public tizen::runtime::LauncherInterface ~CoreRuntime(); int Initialize(bool standalone) override; void Dispose() override; - int RunManagedLauncher() override; - int Launch(const char* root, const char* path, int argc, char* argv[]) override; + int RunManagedLauncher(const char* app_id, const char* app_base, const char* tpa_list) override; + int Launch(const char* app_id, const char* root, const char* path, int argc, char* argv[]) override; private: - bool InitializeCoreClr(const char* assembly_probe_paths, const char* pinvoke_probe_paths); + bool InitializeCoreClr(const char* app_id, const char* assembly_probe_paths, const char* pinvoke_probe_paths, const char* tpa); coreclr_initialize_ptr InitializeClr; coreclr_execute_assembly_ptr ExecuteAssembly; coreclr_shutdown_ptr Shutdown; @@ -74,6 +74,7 @@ class CoreRuntime : public tizen::runtime::LauncherInterface std::string DeviceAPIDirectory; std::string RuntimeDirectory; std::string LauncherAssembly; + std::string NativeLibDirectory; void* coreclrLib; void* hostHandle; unsigned int domainId; diff --git a/NativeLauncher/launcher/dotnet/scd_launcher.cc b/NativeLauncher/launcher/dotnet/scd_launcher.cc index 9c573e8..2959b19 100644 --- a/NativeLauncher/launcher/dotnet/scd_launcher.cc +++ b/NativeLauncher/launcher/dotnet/scd_launcher.cc @@ -208,7 +208,7 @@ void AddFilesFromDirectoryToTpaList(const char* directory, std::string& tpaList) // Walk the directory for each extension separately so that we first get files with .ni.dll extension, // then files with .dll extension, etc. - for (int extIndex = 0; extIndex < sizeof(tpaExtensions) / sizeof(tpaExtensions[0]); extIndex++) + for (unsigned int extIndex = 0; extIndex < sizeof(tpaExtensions) / sizeof(tpaExtensions[0]); extIndex++) { const char* ext = tpaExtensions[extIndex]; int extLength = strlen(ext); @@ -590,6 +590,9 @@ int main(const int argc, const char* argv[]) const char** new_args = &vargs[0]; setenv("SECONDPASS", "1", 1); status = execvp(new_args[0], (char *const *)new_args); + if (status == -1) { + dlog_print(DLOG_ERROR,"dotnet","execvp error"); + } dlog_print(DLOG_INFO,"dotnet","something wrong errno: %d\n",errno); } /// service_app_end diff --git a/NativeLauncher/launcher/launcher.cc b/NativeLauncher/launcher/launcher.cc index c2d1ce4..63fd652 100644 --- a/NativeLauncher/launcher/launcher.cc +++ b/NativeLauncher/launcher/launcher.cc @@ -44,8 +44,6 @@ struct FdHandler static int __argc; static char **__argv; static Evas_Object *__win; -static Evas_Object *__bg; -static Evas_Object *__conform; class LaunchpadAdapterImpl : public LaunchpadAdapter { @@ -155,7 +153,7 @@ static void PreloadLibsAndWindow(bundle *extra, int type, void *user_data) for (i = 0; i < len; i++) { handle = dlopen(so_array[i], RTLD_NOW); - _DBG("preload %s# - handle : %x\n", so_array[i], handle); + _DBG("preload %s# - handle : %x", so_array[i], handle); } // Precreate window diff --git a/NativeLauncher/launcher/launcher.h b/NativeLauncher/launcher/launcher.h index 4d87457..66c3aaa 100644 --- a/NativeLauncher/launcher/launcher.h +++ b/NativeLauncher/launcher/launcher.h @@ -28,8 +28,8 @@ class LauncherInterface public: virtual int Initialize(bool standalone) = 0; virtual void Dispose() = 0; - virtual int RunManagedLauncher() = 0; - virtual int Launch(const char* root, const char* path, int argc, char* argv[]) = 0; + virtual int RunManagedLauncher(const char* app_id, const char* app_base, const char* tpa_list) = 0; + virtual int Launch(const char* app_id, const char* root, const char* path, int argc, char* argv[]) = 0; }; struct AppInfo diff --git a/NativeLauncher/launcher/main.cc b/NativeLauncher/launcher/main.cc index c39b3e8..9bd024c 100644 --- a/NativeLauncher/launcher/main.cc +++ b/NativeLauncher/launcher/main.cc @@ -37,14 +37,12 @@ static std::string VersionOption("--version"); static std::string StandaloneOption("--standalone"); -static std::string NativeOption("--native"); int main(int argc, char *argv[]) { int i; bool standalone = false; const char* standalonePath = nullptr; - bool nativeOnly = false; std::vector vargs; @@ -68,22 +66,12 @@ int main(int argc, char *argv[]) i++; standalonePath = argv[i]; } - else if (NativeOption.compare(argv[i]) == 0) - { - nativeOnly = true; - } else { vargs.push_back(argv[i]); } } - if (!standalone && nativeOnly) - { - fprintf(stderr, "\"--native\" option must be use with \"--standalone\"\n"); - return 1; - } - using tizen::runtime::LauncherInterface; using tizen::runtime::Launchpad; using tizen::runtime::AppInfo; @@ -117,15 +105,9 @@ int main(int argc, char *argv[]) return 1; } - if (!nativeOnly && runtime->RunManagedLauncher() != 0) - { - _ERR("Failed to run managed launcher"); - return 1; - } - int args_len = vargs.size(); char** args = &vargs[0]; - if (runtime->Launch(approot.c_str(), standalonePath, args_len, args)) + if (runtime->Launch(appid, approot.c_str(), standalonePath, args_len, args)) { _ERR("Failed to launch"); return 0; @@ -141,16 +123,7 @@ int main(int argc, char *argv[]) } else { - auto idle_task = [](void *data) -> Eina_Bool - { - LauncherInterface* runtime = static_cast(data); - if (runtime->RunManagedLauncher() != 0) - { - _ERR("Failed to run managed launcher"); - } - return ECORE_CALLBACK_CANCEL; - }; - ecore_idler_add(idle_task, runtime.get()); + _DBG("Success to initialized"); } }; @@ -164,7 +137,7 @@ int main(int argc, char *argv[]) // The launchpad pass the name of exe file to the first argument. // For the C# spec, we have to skip this first argument. - if (runtime->Launch(info.root.c_str(), info.path.c_str(), argc-1, argv+1)) + if (runtime->Launch(info.id.c_str(), info.root.c_str(), info.path.c_str(), argc-1, argv+1)) { _ERR("Failed to launch"); } diff --git a/NativeLauncher/launcher/waiter/waiter.cc b/NativeLauncher/launcher/waiter/waiter.cc deleted file mode 100644 index 02fa3bf..0000000 --- a/NativeLauncher/launcher/waiter/waiter.cc +++ /dev/null @@ -1,311 +0,0 @@ -/* - * 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. - */ - - -#include - -#ifndef NO_TIZEN -#include -#include -#endif - -#include -#include -#include -#include - -#include - -#include "waiter.h" -#include "log.h" - -namespace dotnet { -namespace runtime { - -struct FdHandler -{ - pollfd *info; - Receiver receiver; -}; - -static volatile bool Waiting_; -static std::vector Fdlist_; -static std::map Handlers_; -static Waiter::AppInfo AppInfo_; - -void Waiter::OnPrepared() -{ - if (!context.Prepare()) - { - _DBG("Fail to Prepare..."); - } -} - -void Waiter::OnRequested(const AppInfo& info) -{ - // do some job on user id is still system - - if (!context.Request()) - { - _DBG("Fail to Request..."); - } -} - -void Waiter::OnExecuted(const char *path, const char *app_root, int argc, char *argv[]) -{ - if (!context.Execute(path, app_root, argc, argv)) - { - _DBG("Fail to Execute..."); - } -} - -void Waiter::OnWaiting() -{ - // Start the loop - Waiting_ = true; - - _DBG("start polling..."); - while (Waiting_) - { - if (poll(Fdlist_.data(), Fdlist_.size(), -1) < 0) - continue; - - for (auto &p : Fdlist_) - { - if ( (p.revents | POLLIN) != 0 ) - Handlers_[p.fd].receiver(p.fd); - } - } - _DBG("end polling..."); -} - -void Waiter::Stop() -{ - // Stop the loop - - Waiting_ = false; -} - - -void Waiter::RegisterFd(int fd, Receiver receiver) -{ - // register fd should be caught in event loop - - _DBG("Register fd %d", fd); - - pollfd info; - info.fd = fd; - info.events = POLLIN; - info.revents = 0; - - FdHandler handler; - Fdlist_.push_back(info); - handler.info = &Fdlist_.back(); - handler.receiver = receiver; - - Handlers_[fd] = handler; -} - -void Waiter::DeregisterFd(int fd) -{ - // deregister fd should be caught in event loop - - pollfd *info = Handlers_[fd].info; - Fdlist_.erase(Fdlist_.begin() - (info - &Fdlist_.front())); - Handlers_.erase(fd); -} - -int Waiter::WaitToLaunching(int argc, char *argv[]) -{ -#ifndef NO_TIZEN - auto on_create = [](bundle *extra, int type, void *user_data) - { - _DBG("on_create..."); // XXX - Waiter* waiter = static_cast(user_data); - waiter->OnPrepared(); - }; - - auto on_launch = [](int argc, char **argv, const char *app_path, - const char *appid, const char *pkgid, - const char *pkg_type, void *user_data) -> int - { - _DBG("on_launch..."); // XXX - Waiter* waiter = static_cast(user_data); - - _DBG ("app path : %s", app_path); - _DBG ("app id : %s", appid); - _DBG ("pkg id : %s", pkgid); - _DBG ("pkg type : %s", pkg_type); - - AppInfo info = { - AppPath : app_path, - AppId : appid, - PkgId : pkgid, - PkgType : pkg_type - }; - - waiter->OnRequested(info); - return 0; - }; - - auto on_terminate = [](int argc, char **argv, void *user_data) -> int - { - _DBG("on_terminate..."); // XXX - - string app_root(aul_get_app_root_path()); - Waiter* waiter = static_cast(user_data); - waiter->OnExecuted(argv[0], app_root.c_str(), argc, argv); - return 0; - }; - - auto on_start_loop = [](void *user_data) - { - _DBG("on_start_loop..."); // XXX - Waiter* waiter = static_cast(user_data); - waiter->OnWaiting(); - }; - - auto on_quit_loop = [](void *user_data) - { - _DBG("on_quit_loop..."); // XXX - Waiter* waiter = static_cast(user_data); - waiter->Stop(); - }; - - auto on_add_fd = [](void *user_data, int fd, loader_receiver_cb receiver) - { - _DBG("on_add_fd..."); // XXX - Waiter* waiter = static_cast(user_data); - waiter->RegisterFd(fd, receiver); - }; - - auto on_remove_fd = [](void *user_data, int fd) - { - _DBG("on_remove_fd..."); // XXX - Waiter* waiter = static_cast(user_data); - waiter->DeregisterFd(fd); - }; - - _DBG("launcher wait..."); // XXX - loader_lifecycle_callback_s callbacks = { - .create = on_create, - .launch = on_launch, - .terminate = on_terminate - }; - - loader_adapter_s adapter = { - .loop_begin = on_start_loop, - .loop_quit = on_quit_loop, - .add_fd = on_add_fd, - .remove_fd = on_remove_fd - }; - - return launchpad_loader_main(argc, argv, &callbacks, &adapter, this); -#else - if (argc < 2) - { - _DBG("not enough args : %d", argc); - return -1; - } - _DBG("argv[1] = %s", argv[1]); - std::string app_path(argv[1]); - std::string app_root; - auto pos = app_path.find_last_of('/'); - if (pos != std::string::npos) - app_root = app_path.substr(0, pos); - else - app_root = "."; - - this->OnPrepared(); - AppInfo info = { - AppPath : argv[1], - AppId : "", - PkgId : "", - PkgType : "" - }; - this->OnRequested(info); - this->OnExecuted(app_path.c_str(), app_root.c_str(), argc, argv); -#endif -} - -void Waiter::SetContext(WaiterContext ctx) -{ - context = ctx; -} - -WaiterContext::WaiterContext() -{ - Step = Status::Started; -} - -bool WaiterContext::Prepare() -{ - if (Step == Status::Started && Prepared != nullptr && Prepared(Data) == 0) - { - Step = Status::Prepared; - return true; - } - return false; -} - -bool WaiterContext::Request() -{ - if (Step == Status::Prepared && Requested != nullptr && Requested(Data) == 0) - { - Step = Status::Requested; - return true; - } - return false; -} - -bool WaiterContext::Execute(const char *path, const char *app_root, int argc, char *argv[]) -{ - if (Step == Status::Requested && Executed != nullptr && - Executed(path, app_root, argc, argv, Data) == 0) - { - Step = Status::Executed; - return true; - } - return false; -} - -} // namespace runtime -} // namespace dotnet - -using dotnet::runtime::Waiter; -using dotnet::runtime::WaiterContext; - -static Waiter waiter; - -void register_launching_callback(prepared_callback prepared, - requested_callback requested, executed_callback executed, void *data) -{ - WaiterContext context; - context.Prepared = prepared; - context.Requested = requested; - context.Executed = executed; - context.Data = data; - - waiter.SetContext(context); -} - -void wait_for_launching(int argc, char *argv[]) -{ - _DBG("wait_for_launching..."); - - waiter.WaitToLaunching(argc, argv); -} - diff --git a/NativeLauncher/launcher/waiter/waiter.h b/NativeLauncher/launcher/waiter/waiter.h deleted file mode 100644 index bd3be5f..0000000 --- a/NativeLauncher/launcher/waiter/waiter.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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. - */ - -#include -#include - -#include - -extern "C" { - typedef int (*prepared_callback)(void *data); - typedef int (*requested_callback)(void *data); - typedef int (*executed_callback)(const char* path, const char* app_root, int argc, char *argv[], void *data); - - void register_launching_callback(prepared_callback prepared, - requested_callback requested, executed_callback executed, void *data); - void wait_for_launching(int argc, char *argv[]); -} - -namespace dotnet { -namespace runtime { - -using std::string; -using Receiver = std::function; - -enum Status -{ - Started, - Prepared, - Requested, - Executed -}; - -class WaiterContext -{ - public: - prepared_callback Prepared; - requested_callback Requested; - executed_callback Executed; - - void *Data; - - WaiterContext(); - bool Prepare(); - bool Request(); - bool Execute(const char *path, const char *app_root, int argc, char *argv[]); - - private: - Status Step; -}; - -class Waiter -{ - public: - struct AppInfo - { - string AppPath; - string AppId; - string PkgId; - string PkgType; - }; - - int WaitToLaunching(int argc, char *argv[]); - void Stop(); - - void RegisterFd(int fd, Receiver receiver); - void DeregisterFd(int fd); - void SetContext(WaiterContext ctx); - - protected: - void OnPrepared(); - void OnRequested(const AppInfo&); - void OnWaiting(); - void OnExecuted(const char *path, const char *app_root, int argc, char *argv[]); - - private: - WaiterContext context; -}; - -} // namespace runtime -} // namespace dotnet diff --git a/NativeLauncher/util/utils.cc b/NativeLauncher/util/utils.cc index 75dbcec..1019db4 100755 --- a/NativeLauncher/util/utils.cc +++ b/NativeLauncher/util/utils.cc @@ -151,6 +151,7 @@ bool FileNotExist(const std::string& path) return stat(path.c_str(), &sb) != 0; } +#ifdef NOT_USE_FUNCTION static bool ExtCheckAndGetFileNameIfExist(const std::string& dir, const std::string& ext, struct dirent* entry, std::string& filename) { std::string fname(entry->d_name); @@ -177,6 +178,7 @@ static bool ExtCheckAndGetFileNameIfExist(const std::string& dir, const std::st return true; } +#endif std::string StripNIDLL(const std::string& path) { diff --git a/Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyLoader.cs b/Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyLoader.cs index dd96abf..3423d80 100755 --- a/Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyLoader.cs +++ b/Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyLoader.cs @@ -40,12 +40,6 @@ namespace Tizen.Runtime.Coreclr private HashSet _assemblyCache = new HashSet(); - private Dictionary _unmanagedDictionary = new Dictionary() - { - {"sqlite3", "/lib/libsqlite3.so.0"}, - {"libsqlite3.so", "/lib/libsqlite3.so.0"} - }; - public AssemblyLoader() { AssemblyLoadContext.Default.Resolving += OnResolving; @@ -112,18 +106,6 @@ namespace Tizen.Runtime.Coreclr protected override IntPtr LoadUnmanagedDll(string unmanagedDllName) { - if (_unmanagedDictionary.ContainsKey(unmanagedDllName)) - { - if (File.Exists(_unmanagedDictionary[unmanagedDllName])) - { - unmanagedDllName = _unmanagedDictionary[unmanagedDllName]; - } - else - { - unmanagedDllName = _unmanagedDictionary[unmanagedDllName].Replace("/lib/", "/lib64/"); - } - } - IntPtr native = base.LoadUnmanagedDll(unmanagedDllName); if (native == IntPtr.Zero) { diff --git a/Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyManager.cs b/Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyManager.cs index de0b293..afd6fd4 100644 --- a/Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyManager.cs +++ b/Tizen.Runtime/Tizen.Runtime.Coreclr/AssemblyManager.cs @@ -61,21 +61,9 @@ namespace Tizen.Runtime.Coreclr { try { - string preloadPath = ""; - ICustomAttributeProvider assembly = typeof(AssemblyManager).GetTypeInfo().Assembly; - var attributes = assembly.GetCustomAttributes(typeof(DefaultConfigAttribute), false); - foreach (DefaultConfigAttribute dca in attributes) + if (!Initialize()) { - ALog.Debug($"{dca.Key} = {dca.Value}"); - if (dca.Key == "PreloadPath") - { - preloadPath = dca.Value; - } - } - - if (!Initialize(preloadPath)) - { - ALog.Debug($"Failed to Initialized with {preloadPath}"); + ALog.Debug($"Failed to Initialized"); } } catch(Exception e) @@ -105,7 +93,7 @@ namespace Tizen.Runtime.Coreclr PrintException(e); } - public static bool Initialize(string preloadFile) + public static bool Initialize() { try { @@ -120,7 +108,6 @@ namespace Tizen.Runtime.Coreclr Delegate handler = handlerInfo.CreateDelegate(unhandledException.EventHandlerType); var addMethod = unhandledException.GetAddMethod(true); addMethod.Invoke(appdomain, new[] {handler}); - } catch (Exception e) { @@ -131,45 +118,6 @@ namespace Tizen.Runtime.Coreclr try { CurrentAssemblyLoaderContext = new AssemblyLoader(); - - if (!string.IsNullOrEmpty(preloadFile)) - { - ALog.Debug($"Load from [{preloadFile}]"); - FileInfo f = new FileInfo(preloadFile); - if (File.Exists(f.FullName)) - { - using (StreamReader sr = File.OpenText(f.FullName)) - { - string s = String.Empty; - while ((s = sr.ReadLine()) != null) - { - ALog.Debug($"preload dll : {s}"); - try - { - Assembly asm = CurrentAssemblyLoaderContext.LoadFromPath(s); - - // this works strange, vm can't load types except loaded in here. - // so user code spit out not found exception. - /* - if (asm != null) - { - foreach (TypeInfo t in asm.DefinedTypes) - { - ALog.Debug("===> TYPE : " + t.FullName); - GC.KeepAlive(t.AsType()); - } - } - */ - } - catch (Exception e) - { - ALog.Debug("Exception on preload"); - PrintException(e); - } - } - } - } - } } catch (Exception e) { diff --git a/packaging/dotnet-launcher.spec b/packaging/dotnet-launcher.spec index 78ca701..63235b0 100755 --- a/packaging/dotnet-launcher.spec +++ b/packaging/dotnet-launcher.spec @@ -43,6 +43,7 @@ Requires(preun): /usr/bin/systemctl %define _runtime_dir /usr/share/dotnet/shared/Microsoft.NETCore.App/1.0.0 %define _install_plugin_dir /usr/etc/package-manager/parserlib %define _install_mdplugin_dir /etc/package-manager/parserlib/metadata +%define _native_lib_dir /usr/share/dotnet.tizen/lib ExcludeArch: aarch64 @@ -58,6 +59,11 @@ launching dotnet apps without dotent runtime installed %prep %setup -q +%define use_managed_launcher 0 +%if %{use_managed_launcher} + %define USE_MANAGED_LAUNCHER ENABLE +%endif + %build cmake \ -DCMAKE_INSTALL_PREFIX=%{_prefix} \ @@ -70,10 +76,14 @@ cmake \ -DDEVICE_API_DIR=%{_device_api_dir} \ -DRUNTIME_DIR=%{_runtime_dir} \ -DCROSSGEN_PATH=%{_device_api_dir}/crossgen \ +%if %{use_managed_launcher} -DCORECLR_LAUNCHER_ASSEMBLY_PATH=%{_bindir}/Tizen.Runtime.Coreclr.dll \ +%endif -DINSTALL_PLUGIN_DIR=%{_install_plugin_dir} \ -DINSTALL_MDPLUGIN_DIR=%{_install_mdplugin_dir} \ -DVERSION=%{version} \ + -DUSE_MANAGED_LAUNCHER=%{?USE_MANAGED_LAUNCHER:%USE_MANAGED_LAUNCHER} \ + -DNATIVE_LIB_DIR=%{_native_lib_dir} \ NativeLauncher make %{?jobs:-j%jobs} VERBOSE=1 @@ -87,18 +97,26 @@ xbuild \ %install rm -rf %{buildroot} %make_install +%if %{use_managed_launcher} install -p -m 644 Tizen.Runtime/bin/Tizen.Runtime.Coreclr.dll %{buildroot}%{_bindir} +%endif + +mkdir -p %{buildroot}%{_native_lib_dir} +ln -sf %{_libdir}/libsqlite3.so.0 %{buildroot}%{_native_lib_dir}/libsqlite3.so %files %manifest dotnet-launcher.manifest %{_loaderdir}/dotnet.loader %{_loaderdir}/dotnet.launcher %{_loaderdir}/dotnet.debugger +%{_native_lib_dir}/libsqlite3.so %caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/dotnet-launcher %caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/nitool %caps(cap_mac_admin,cap_setgid=ei) %{_install_plugin_dir}/libui-application.so %caps(cap_mac_admin,cap_setgid=ei) %{_install_mdplugin_dir}/libprefer_dotnet_aot_plugin.so +%if %{use_managed_launcher} %caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/Tizen.Runtime.Coreclr.dll +%endif %files -n scd-launcher %caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/scd-launcher -- 2.7.4 From 4c75b87bbc21e78e864e4df0f0a7483bf9c3854a Mon Sep 17 00:00:00 2001 From: JongHeon Choi Date: Mon, 10 Apr 2017 18:52:51 +0900 Subject: [PATCH 03/16] [Release] dotnet-launcher 1.1.0-1 Change-Id: I8f1e6b57964b86b59a64dea9943f63ae3519bd5d --- packaging/dotnet-launcher.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/dotnet-launcher.spec b/packaging/dotnet-launcher.spec index 63235b0..c16117a 100755 --- a/packaging/dotnet-launcher.spec +++ b/packaging/dotnet-launcher.spec @@ -1,7 +1,7 @@ Name: dotnet-launcher Summary: Launchpad plugin for dotnet apps -Version: 1.0.1 -Release: 2 +Version: 1.1.0 +Release: 1 Group: Application Framework/Application State Management License: Apache-2.0 Source0: %{name}-%{version}.tar.gz -- 2.7.4 From 3cf211da1beb8cafd4ad8a94f3827caa673a63bf Mon Sep 17 00:00:00 2001 From: JongHeon Choi Date: Mon, 10 Apr 2017 19:37:33 +0900 Subject: [PATCH 04/16] ExecuteAssembly not permit native image path Change-Id: I76f11eb94bef7574a4495aec12ac864ed986e84c --- NativeLauncher/launcher/dotnet/dotnet_launcher.cc | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc index 15b74c9..4aabf42 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc @@ -275,18 +275,6 @@ int CoreRuntime::Launch(const char* app_id, const char* root, const char* path, return 1; } - std::string cpppath(path); - - if (IsManagedAssembly(cpppath) && !IsNativeImage(cpppath)) - { - size_t extindex = cpppath.size() - 4; - cpppath = cpppath.substr(0, extindex) + ".ni" + cpppath.substr(extindex, 4); - if (!FileNotExist(cpppath)) - { - path = cpppath.c_str(); - } - } - if (FileNotExist(path)) { _ERR("File not exist : %s", path); @@ -315,6 +303,18 @@ int CoreRuntime::Launch(const char* app_id, const char* root, const char* path, bool success = false; if (LaunchFunction != nullptr) { + std::string cpppath(path); + + if (IsManagedAssembly(cpppath) && !IsNativeImage(cpppath)) + { + size_t extindex = cpppath.size() - 4; + cpppath = cpppath.substr(0, extindex) + ".ni" + cpppath.substr(extindex, 4); + if (!FileNotExist(cpppath)) + { + path = cpppath.c_str(); + } + } + success = LaunchFunction(root, path, argc, argv); if (!success) { -- 2.7.4 From 2cb2f43727ac65ecff5a9725feb132c9f9619291 Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Tue, 11 Apr 2017 10:18:16 +0900 Subject: [PATCH 05/16] change smack and owner for generated ni file Change-Id: Ia4c992b2984fe0b87e77bb06b031c67dcbbb8c9c --- NativeLauncher/installer-plugin/common.cc | 37 +++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/NativeLauncher/installer-plugin/common.cc b/NativeLauncher/installer-plugin/common.cc index 5d1306c..d2c9c3f 100644 --- a/NativeLauncher/installer-plugin/common.cc +++ b/NativeLauncher/installer-plugin/common.cc @@ -29,6 +29,11 @@ #include #include +#include +#include +#include +#include + #include "common.h" #ifdef LOG_TAG @@ -58,7 +63,7 @@ static const char* JITPath = __STR(RUNTIME_DIR)"/libclrjit.so"; #undef __XSTR static void crossgen(const char* dll_path, const char* app_path); -static void smack_(const char* dll_path); +static void smack_(const char* dll_path, const char* label); std::string Replace(std::string &str, const std::string& from, const std::string& to) { @@ -79,14 +84,14 @@ void create_ni_platform() if (FileNotExist(nicorlib)) { crossgen(corlib.c_str(), nullptr); - smack_(nicorlib.c_str()); + smack_(nicorlib.c_str(), "_"); } const char* platform_dirs[] = {RuntimeDir, DeviceAPIDir, "/usr/bin"}; const char* ignores[] = {corlib.c_str()}; create_ni_under_dirs(platform_dirs, 3, ignores, 1, [](const char* ni){ - smack_(ni); + smack_(ni, "_"); }); } @@ -98,7 +103,7 @@ void create_ni_select(const char* dll_path) if (FileNotExist(nicorlib)) { crossgen(corlib.c_str(), nullptr); - smack_(nicorlib.c_str()); + smack_(nicorlib.c_str(), "_"); } if (!FileNotExist(dll_path)) @@ -109,11 +114,11 @@ void create_ni_select(const char* dll_path) crossgen(dll_path, nullptr); else printf("Already [%s] file is exist\n", ni_path.c_str()); - smack_(ni_path.c_str()); + smack_(ni_path.c_str(), "_"); } } -static void smack_(const char* dll_path) +static void smack_(const char* dll_path, const char* label) { static const char* CHKSMACK = "/usr/bin/chsmack"; pid_t pid = fork(); @@ -135,7 +140,7 @@ static void smack_(const char* dll_path) { const char* args[] = { CHKSMACK, - "-a", "_", + "-a", label, dll_path, nullptr }; @@ -259,7 +264,8 @@ static int get_root_path(const char *pkgid, std::string& root_path) static bool NIExist(const std::string& path, std::string& ni) { static const char* possible_exts[] = { - ".ni.dll", ".NI.dll", ".NI.DLL", ".ni.DLL" + ".ni.dll", ".NI.dll", ".NI.DLL", ".ni.DLL", + ".ni.exe", ".NI.exe", ".NI.EXE", ".ni.EXE" }; std::string fname = path.substr(0, path.size() - 4); @@ -302,6 +308,14 @@ void create_ni_under_dirs(const char* root_paths[], int count, const char* ignor crossgen(path, app_paths.c_str()); if (NIExist(path, ni)) { + // 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) { + _ERR("Failed to change owner and group name"); + } + } + if (cb != nullptr) { cb(ni.c_str()); @@ -346,7 +360,12 @@ int create_ni_under_pkg_root(const char* pkg_name) bindir.c_str(), libdir.c_str() }; - create_ni_under_dirs(paths, 2); + + // change smack label for generated ni file. + std::string label = "User::Pkg::" + std::string(pkg_name) + "::RO"; + create_ni_under_dirs(paths, 2, [label](const char* ni){ + smack_(ni, label.c_str()); + }); return 0; } -- 2.7.4 From ab3ea98c523da53a674a94684dd3aca3e216ff6f Mon Sep 17 00:00:00 2001 From: Hyungju Lee Date: Wed, 12 Apr 2017 16:57:06 +0900 Subject: [PATCH 06/16] Remove unnecessary executable flag Change-Id: I19365bad8aa330455d69ef0cdde6a35a0261fa2c Signed-off-by: Hyungju Lee --- NativeLauncher/util/utils.cc | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 NativeLauncher/util/utils.cc diff --git a/NativeLauncher/util/utils.cc b/NativeLauncher/util/utils.cc old mode 100755 new mode 100644 -- 2.7.4 From a19b340492caefe190285e142541a920e1e5c9c1 Mon Sep 17 00:00:00 2001 From: JongHeon Choi Date: Wed, 12 Apr 2017 18:34:56 +0900 Subject: [PATCH 07/16] [SVACE] Modified to initialize class members Change-Id: I284e901bec4adc73cd83fc149e469d13a3fb6ee0 --- NativeLauncher/launcher/launcher.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/NativeLauncher/launcher/launcher.cc b/NativeLauncher/launcher/launcher.cc index 63fd652..fe163ee 100644 --- a/NativeLauncher/launcher/launcher.cc +++ b/NativeLauncher/launcher/launcher.cc @@ -48,7 +48,12 @@ static Evas_Object *__win; class LaunchpadAdapterImpl : public LaunchpadAdapter { public: - LaunchpadAdapterImpl() : isLaunched(false) { } + LaunchpadAdapterImpl() : + callbacks(), + adapter(), + launcher(nullptr), + isLaunched(false) + { } void LoaderMain(int argc, char* argv[]) override; std::map Handlers; -- 2.7.4 From eaa814cf3d9cc7c8fd28a997d2797e7fdbff08ad Mon Sep 17 00:00:00 2001 From: JongHeon Choi Date: Thu, 13 Apr 2017 09:52:52 +0900 Subject: [PATCH 08/16] 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 + - - - - - - + + + + + + - - - + + + - + - - - $(DefineConstants);CLOG - - - - - - - - - - - - - - - - - - - - - - - <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory) - <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory) - true - - - - - - <_Parameter1>PreloadPath=$(PreloadPath) - - - - - - - - - diff --git a/Tizen.Runtime/Tizen.Runtime.Coreclr.project.json b/Tizen.Runtime/Tizen.Runtime.Coreclr.project.json deleted file mode 100644 index ff2957d..0000000 --- a/Tizen.Runtime/Tizen.Runtime.Coreclr.project.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "dependencies": { - "NETStandard.Library": "1.6.0", - "System.Runtime.Loader": "4.0.0" - }, - "frameworks": { - "netstandard1.5": {} - } -} - diff --git a/Tizen.Runtime/Tizen.Runtime.csproj b/Tizen.Runtime/Tizen.Runtime.csproj new file mode 100644 index 0000000..a232a3a --- /dev/null +++ b/Tizen.Runtime/Tizen.Runtime.csproj @@ -0,0 +1,11 @@ + + + + netstandard1.6 + + + + + + + \ No newline at end of file diff --git a/Tizen.Runtime/Tizen.Runtime.snk b/Tizen.Runtime/Tizen.Runtime.snk deleted file mode 100644 index d09238fad5d4ac1671b141956034cca2ec3ce802..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 599 zcmV-d0;v550ssI2Bme+XQ$aES1ONaL0002(DGq5;*iDNmD`i!-W57Gx1KS<*(EK%3 zW@B-ZpEPiJ0fkn2_41G@5}84M{UB8~_RT4uZL3`+#TA8&{$_d&u>Cb>&i6riJ-$y6 zuB_`PSeaKUOC)MY%xjZE{2`Isnfaoi?2(H)pBE z1Xh7WLmh?%QqZWwun;}Hx8_jq>#heY*CApiQ7I;cFK6G8`TMr8Z3sO>Wwq|_K-Z%s z;P2$CvTD;C!#sg|0ZrX&h=RkOfW+@t$YU^?)jC{*p+dsOx(-o({!dOjgKh^tw<7&{ z^sgy+GVAnmKDer~rk7Zm#LdH!jI)4Kj{d`zc1@zij|;CUgc zs)cT0>q!UX)fhEr+O7o*w=R?B2l~UYrKC^NL#vc1x}(U-r^19lSv0>Kgc^?*0drAG z7}{#(d}nE8Q=U!@B$^Uvm?guBL0Go+c|JBw)sYMoiSvhE_YrZ`zgZ~WT0o17&E=O# zQU}2^(7;Ny6{||(84$e=!b`svpBzxi!5| Date: Tue, 25 Apr 2017 13:10:08 +0900 Subject: [PATCH 13/16] fix standalone crash issue Change-Id: I62c0a302248bdd0f6a304300f6ba535604acf39d --- NativeLauncher/launcher/main.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/NativeLauncher/launcher/main.cc b/NativeLauncher/launcher/main.cc index 5754589..2bbda72 100644 --- a/NativeLauncher/launcher/main.cc +++ b/NativeLauncher/launcher/main.cc @@ -83,9 +83,12 @@ int main(int argc, char *argv[]) const char* appRootPath = aul_get_app_root_path(); if (appRootPath != nullptr) appRoot = std::string(appRootPath); + } else { + appId = "dotnet-launcher"; } + if (appRoot.empty()) - appRoot = baseName(standalonePath); + appRoot = baseName(baseName(standalonePath)); if (runtime->initialize(true) != 0) { _ERR("Failed to initialize"); return 1; -- 2.7.4 From 3b7059d73a89354e085156eda18af02892ecc828 Mon Sep 17 00:00:00 2001 From: Inhwan Lee Date: Tue, 25 Apr 2017 13:55:35 +0900 Subject: [PATCH 14/16] set env UNW_ARM_UNWIND_METHOD value on ARM platform Change-Id: Iab10502bc55f5bea33cf553a14838bdb56f6afd2 --- NativeLauncher/launcher/dotnet/dotnet_launcher.cc | 14 ++++++++++++++ NativeLauncher/launcher/dotnet/scd_launcher.cc | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc index d3df80e..c0b5300 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc @@ -73,6 +73,20 @@ CoreRuntime::~CoreRuntime() int CoreRuntime::initialize(bool standalone) { +#ifdef __arm__ + // libunwind library is used to unwind stack frame, but libunwind for ARM + // does not support ARM vfpv3/NEON registers in DWARF format correctly. + // Therefore let's disable stack unwinding using DWARF information + // See https://github.com/dotnet/coreclr/issues/6698 + // + // libunwind use following methods to unwind stack frame. + // UNW_ARM_METHOD_ALL 0xFF + // UNW_ARM_METHOD_DWARF 0x01 + // UNW_ARM_METHOD_FRAME 0x02 + // UNW_ARM_METHOD_EXIDX 0x04 + putenv(const_cast("UNW_ARM_UNWIND_METHOD=6")); +#endif // __arm__ + if (standalone) { const char *deviceApiDirectory = getenv("__deviceAPIDirectory"); const char *runtimeDirectory = getenv("__runtimeDirectory"); diff --git a/NativeLauncher/launcher/dotnet/scd_launcher.cc b/NativeLauncher/launcher/dotnet/scd_launcher.cc index 029e93c..7bbd883 100644 --- a/NativeLauncher/launcher/dotnet/scd_launcher.cc +++ b/NativeLauncher/launcher/dotnet/scd_launcher.cc @@ -266,7 +266,7 @@ int executeManagedAssembly(const char* currentExeAbsolutePath, // Indicates failure int exitCode = -1; -#ifdef _ARM_ +#ifdef __arm__ // libunwind library is used to unwind stack frame, but libunwind for ARM // does not support ARM vfpv3/NEON registers in DWARF format correctly. // Therefore let's disable stack unwinding using DWARF information @@ -278,7 +278,7 @@ int executeManagedAssembly(const char* currentExeAbsolutePath, // UNW_ARM_METHOD_FRAME 0x02 // UNW_ARM_METHOD_EXIDX 0x04 putenv(const_cast("UNW_ARM_UNWIND_METHOD=6")); -#endif // _ARM_ +#endif // __arm__ std::string coreClrDllPath(clrFilesAbsolutePath); coreClrDllPath.append("/"); -- 2.7.4 From 323150bea27f1ebada1399e51ceba0c01b0606ed Mon Sep 17 00:00:00 2001 From: JongHeon Choi Date: Tue, 25 Apr 2017 17:26:05 +0900 Subject: [PATCH 15/16] Bug fixed for performance_test Change-Id: I7e3e42defbd9cf25da8d605c2d8dc8cc75267a18 --- tools/performance_test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/performance_test.sh b/tools/performance_test.sh index 37b7950..43b7962 100755 --- a/tools/performance_test.sh +++ b/tools/performance_test.sh @@ -145,7 +145,7 @@ execute_time_stamp_auto_memory () echo "[>] Start performance test that applciation launching memory" echo "" sdb shell "dlogutil -c" - sdb shell "dlogutil -v time AUL APP_CORE|grep -E 'app_request_to_launchpad_for_uid.*[SECURE_LOG].*launch.*request|__show_cb.*[EVENT_TEST][EVENT]'" >> $STREAM_LOG_FILE & + sdb shell "dlogutil -v time AUL APP_CORE_UI_BASE|grep -E 'app_request_to_launchpad_for_uid.*[SECURE_LOG].*launch.*request|appcore_ui_base_window_on_show.*[EVENT_TEST][EVENT]'" >> $STREAM_LOG_FILE & DLOG_STREAMER_PID=$! #execute timestamp /bin/bash ./timestamp.sh $STREAM_LOG_FILE $RESULT_LOG_FILE & @@ -202,7 +202,7 @@ execute_time_stamp_manual_memory () rm $STREAM_LOG_FILE touch $STREAM_LOG_FILE sdb shell "dlogutil -c" - sdb shell "dlogutil -v time AUL APP_CORE|grep -E 'app_request_to_launchpad_for_uid.*[SECURE_LOG].*launch.*request|__show_cb.*[EVENT_TEST][EVENT]'" >> $STREAM_LOG_FILE & + sdb shell "dlogutil -v time AUL APP_CORE_UI_BASE|grep -E 'app_request_to_launchpad_for_uid.*[SECURE_LOG].*launch.*request|appcore_ui_base_window_on_show.*[EVENT_TEST][EVENT]'" >> $STREAM_LOG_FILE & DLOG_STREAMER_PID=$! #execute timestamp /bin/bash ./timestamp.sh $STREAM_LOG_FILE $RESULT_LOG_FILE & -- 2.7.4 From 7f481bb69fb6d1a11ed2d88461d74bfb0f5d22d6 Mon Sep 17 00:00:00 2001 From: JongHeon Choi Date: Wed, 26 Apr 2017 08:36:35 +0900 Subject: [PATCH 16/16] crossgen bug fixed Change-Id: Ia8632e7b66cabbfd2d1c780d85db52462e1db38e --- NativeLauncher/installer-plugin/common.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NativeLauncher/installer-plugin/common.cc b/NativeLauncher/installer-plugin/common.cc index e53cff3..9cd2109 100644 --- a/NativeLauncher/installer-plugin/common.cc +++ b/NativeLauncher/installer-plugin/common.cc @@ -175,7 +175,7 @@ static void crossgen(const char* dllPath, const char* appPath) std::vector argv = { __CROSSGEN_PATH, "/Trusted_Platform_Assemblies", tpa.c_str(), - "/__JIT_PATH", __JIT_PATH, + "/JITPath", __JIT_PATH, "/FragileNonVersionable" }; if (appPath != nullptr) { -- 2.7.4