From d864d641984681445948f588235047ff89d3dee8 Mon Sep 17 00:00:00 2001 From: "j-h.choi" Date: Wed, 1 Apr 2020 10:12:49 +0900 Subject: [PATCH] Support for preload of ElmSharp and preload.list file Change-Id: I1da11acef01294963950d0f2027791c8b70f6063 --- Managed/Managed.sln | 15 +- Managed/Tizen.Init/Tizen.Init.cs | 221 --------------------- Managed/Tizen.Runtime/Tizen.Runtime.cs | 99 +++++++++ .../Tizen.Runtime.csproj} | 0 NativeLauncher/CMakeLists.txt | 5 + NativeLauncher/Dotnet.Launcher.preload | 38 ++++ NativeLauncher/inc/ni_common.h | 3 + NativeLauncher/inc/path_manager.h | 2 +- .../installer-plugin/prefer_nuget_cache_plugin.cc | 4 +- NativeLauncher/launcher/exec/loader.cc | 12 +- NativeLauncher/launcher/lib/dotnet_launcher.cc | 26 +-- NativeLauncher/launcher/lib/dotnet_launcher.h | 3 +- NativeLauncher/util/log_manager.cc | 1 - packaging/dotnet-launcher.spec | 9 +- 14 files changed, 183 insertions(+), 255 deletions(-) delete mode 100644 Managed/Tizen.Init/Tizen.Init.cs create mode 100644 Managed/Tizen.Runtime/Tizen.Runtime.cs rename Managed/{Tizen.Init/Tizen.Init.csproj => Tizen.Runtime/Tizen.Runtime.csproj} (100%) create mode 100644 NativeLauncher/Dotnet.Launcher.preload diff --git a/Managed/Managed.sln b/Managed/Managed.sln index ee5743e..150e748 100644 --- a/Managed/Managed.sln +++ b/Managed/Managed.sln @@ -1,11 +1,10 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.136 +# Visual Studio 16 +VisualStudioVersion = 16.0.29306.81 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dotnet.Launcher", "Dotnet.Launcher\Dotnet.Launcher.csproj", "{92F481F9-A099-40D7-9DD7-BE1B64C010D1}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Init", "Tizen.Init\Tizen.Init.csproj", "{E43E299B-DA9A-4FE3-87EC-0E4511EA4679}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Runtime", "Tizen.Runtime\Tizen.Runtime.csproj", "{10904A32-26EB-4135-B012-8F123A63E29D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -17,10 +16,10 @@ Global {92F481F9-A099-40D7-9DD7-BE1B64C010D1}.Debug|Any CPU.Build.0 = Debug|Any CPU {92F481F9-A099-40D7-9DD7-BE1B64C010D1}.Release|Any CPU.ActiveCfg = Release|Any CPU {92F481F9-A099-40D7-9DD7-BE1B64C010D1}.Release|Any CPU.Build.0 = Release|Any CPU - {E43E299B-DA9A-4FE3-87EC-0E4511EA4679}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E43E299B-DA9A-4FE3-87EC-0E4511EA4679}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E43E299B-DA9A-4FE3-87EC-0E4511EA4679}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E43E299B-DA9A-4FE3-87EC-0E4511EA4679}.Release|Any CPU.Build.0 = Release|Any CPU + {10904A32-26EB-4135-B012-8F123A63E29D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {10904A32-26EB-4135-B012-8F123A63E29D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {10904A32-26EB-4135-B012-8F123A63E29D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {10904A32-26EB-4135-B012-8F123A63E29D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Managed/Tizen.Init/Tizen.Init.cs b/Managed/Tizen.Init/Tizen.Init.cs deleted file mode 100644 index 904c48f..0000000 --- a/Managed/Tizen.Init/Tizen.Init.cs +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (c) 2019 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.Reflection; -using System.Runtime.Loader; -using System.Collections.Generic; - -namespace Tizen.Init { - - class TypeLoader - { - // key : assembly name, value : list of types - static IDictionary> assem_type = new Dictionary> - { - {"ElmSharp", new List(){ - "ElmSharp.Box", - "ElmSharp.Button", - "ElmSharp.Check", - "ElmSharp.Color", - "ElmSharp.Conformant", - "ElmSharp.DateTimeSelector", - "ElmSharp.DisplayRotation", - "ElmSharp.EdjeObject", - "ElmSharp.EdjeObject+SignalData", - "ElmSharp.EdjeTextPartObject", - "ElmSharp.Elementary", - "ElmSharp.Entry", - "ElmSharp.EvasKeyEventArgs", - "ElmSharp.EvasMap", - "ElmSharp.EvasObject", - "ElmSharp.FocusDirection", - "ElmSharp.GenList", - "ElmSharp.GestureLayer+GestureType", - "ElmSharp.IInvalidatable", - "ElmSharp.Image", - "ElmSharp.ItemObject+SignalData", - "ElmSharp.Label", - "ElmSharp.Layout", - "ElmSharp.Naviframe", - "ElmSharp.NaviItem", - "ElmSharp.Point3D", - "ElmSharp.ProgressBar", - "ElmSharp.Radio", - "ElmSharp.Rect", - "ElmSharp.Rectangle", - "ElmSharp.Scroller", - "ElmSharp.Size", - "ElmSharp.Slider", - "ElmSharp.Spinner", - "ElmSharp.Widget", - "ElmSharp.Window", - "ElmSharp.WrapType", - "Interop"}}, - {"ElmSharp.Wearable", new List(){ - "ElmSharp.Wearable.CircleDateTimeSelector", - "ElmSharp.Wearable.CircleGenList", - "ElmSharp.Wearable.CircleScroller", - "ElmSharp.Wearable.CircleSpinner", - "ElmSharp.Wearable.ICircleWidget", - "ElmSharp.Wearable.IRotaryActionWidget", - "Interop"}}, - {"System.IO.FileSystem", new List(){ - "Interop", - "", - "System.IO.File"}}, - {"System.Security.Cryptography.Algorithms", new List(){ - "Interop", - "System.Security.Cryptography.MD5"}}, - {"System.Collections", new List(){ - "", - "System.Collections.Generic.HashSet`1", - "System.Collections.Generic.Queue`1"}}, - {"System.Private.Uri", new List(){ - "", - "System.Uri"}}, - {"System.Private.Xml", new List(){ - "", - "System.Xml.IXmlLineInfo", - "System.Xml.IXmlNamespaceResolver"}}, - {"System.Runtime", new List(){ - "System.Collections.Generic.ISet`1", - "System.Reflection.RuntimeReflectionExtensions"}}, - {"System.ObjectModel", new List(){ - "System.Collections.ObjectModel.ObservableCollection`1", - "System.Collections.Specialized.INotifyCollectionChanged", - "System.Collections.Specialized.NotifyCollectionChangedAction", - "System.Collections.Specialized.NotifyCollectionChangedEventArgs", - "System.Collections.Specialized.NotifyCollectionChangedEventHandler", - "System.ComponentModel.INotifyPropertyChanged", - "System.ComponentModel.PropertyChangedEventArgs", - "System.ComponentModel.PropertyChangedEventHandler", - "System.Windows.Input.ICommand"}}, - {"System.ComponentModel", new List(){ - "System.IServiceProvider"}}, - {"System.Linq", new List(){ - "System.Linq.Enumerable", - "System.Linq.EnumerableSorter`1", - "System.Linq.IIListProvider`1", - "System.Linq.IOrderedEnumerable`1", - "System.Linq.IPartition`1", - "System.Linq.OrderedEnumerable`1"}}, - {"System.Linq.Expressions", new List(){ - "System.Linq.Expressions.ExpressionVisitor"}}, - {"System.Security.Cryptography.Primitives", new List(){ - "System.Security.Cryptography.HashAlgorithm"}}, - {"Tizen.Applications.Common", new List(){ - "Interop", - "Tizen.Applications.Application", - "Tizen.Applications.CoreApplication", - "Tizen.Applications.CoreBackend.EventType", - "Tizen.Applications.TizenSynchronizationContext"}}, - {"Tizen.Applications.UI", new List(){ - "Tizen.Applications.CoreUIApplication", - "Interop"}}, - {"Tizen", new List(){ - "Interop"}}, - {"Tizen.Log", new List(){ - "Interop", - "Tizen.Log"}}, - {"Tizen.System.Information", new List(){ - "Tizen.System.Information"}} - }; - - static void PreloadEnd() - { - assem_type = null; - GC.Collect(); - GC.WaitForPendingFinalizers(); - } - - static void PreloadTypes() - { - foreach (KeyValuePair> item in assem_type) - { - Assembly asm = LoadAssembly(item.Key); - if (asm != null) { - foreach (string t in item.Value) - { - LoadType(asm, t); - } - } - } - - PreloadLibICU(); - PreloadTizenFX(); - - PreloadEnd(); - } - - static Assembly LoadAssembly(string name) - { - var context = AssemblyLoadContext.Default; - Assembly ret = null; - - try - { - ret = context.LoadFromAssemblyName(new AssemblyName(name)); - } - catch (Exception e) - { - Console.WriteLine(e.ToString()); - return null; - } - - return ret; - } - - static void LoadType(Assembly assem, string typeName) - { - try - { - var tp = assem.GetType(typeName); - } - catch - { - Console.WriteLine("Tizen.Init.TypeLoader.PreloadTypes can't load type " + typeName + " from assembly " + assem.ToString()); - } - } - - static void PreloadLibICU() - { - // Simple workaround for preloading libICU. - if ("A".ToLower() != "a") - { - Console.WriteLine("Unreachable."); - } - } - - static void PreloadTizenFX() - { - try - { - Assembly assem = LoadAssembly("ElmSharp"); - var type = assem.GetType("ElmSharp.Window"); - type.GetMethod("Preload", BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, null); - - assem = LoadAssembly("Tizen.System.Information"); - type = assem.GetType("Tizen.System.Information"); - type.GetMethod("TryGetValue", BindingFlags.Public | BindingFlags.Static).MakeGenericMethod(typeof(int)).Invoke(null, new object[] { "http://tizen.org/feature/screen.width", null }); - } - catch (Exception e) - { - Console.WriteLine(e.ToString()); - Console.WriteLine("Fail to preload TizenFX"); - } - } - } -} diff --git a/Managed/Tizen.Runtime/Tizen.Runtime.cs b/Managed/Tizen.Runtime/Tizen.Runtime.cs new file mode 100644 index 0000000..e88aadb --- /dev/null +++ b/Managed/Tizen.Runtime/Tizen.Runtime.cs @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2019 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.Reflection; +using System.Runtime.Loader; + +namespace Tizen.Runtime +{ + class Preloader + { + const string preloadPath = "/usr/share/dotnet.tizen/preload/"; + public static void Preload() + { + DirectoryInfo directory = new DirectoryInfo(preloadPath); + foreach (FileInfo file in directory.GetFiles()) + { + if (file.Extension.CompareTo(".preload") != 0) + continue; + + try + { + BindingFlags bindingFlag = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; + foreach (string line in File.ReadLines(file.FullName)) + { + if (line.StartsWith('#') || !line.Contains(".dll") || !line.Contains(' ')) + continue; + + string[] getWord = line.Split(' '); + if (getWord.Length != 2) + continue; + + string assemblyStr = getWord[0].Replace(".dll", ""); + string typenameStr = getWord[1]; + string methodStr = ""; + string parenthesis = "()"; + + if (line.Contains(parenthesis)) + { + string [] getMethod = typenameStr.Split('.'); + methodStr = getMethod[getMethod.Length - 1].Replace(parenthesis, ""); + typenameStr = typenameStr.Replace("." + methodStr + parenthesis, ""); + } + + try + { + if (assemblyStr == "") + continue; + + Assembly asm = AssemblyLoadContext.Default.LoadFromAssemblyName(new AssemblyName(assemblyStr)); + if (asm == null || typenameStr == "") + continue; + + Type type = asm.GetType(typenameStr); + if (type == null || methodStr == "") + continue; + + MethodInfo method = type.GetMethod(methodStr, bindingFlag); + if (method == null) + continue; + + method.Invoke(null, null); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + Console.WriteLine("[ERROR] Failed to '" + line + "' preload"); + } + } + } + catch (IOException e) + { + Console.WriteLine(e.ToString()); + Console.WriteLine("[ERROR] Failed to " + file.FullName + " file open"); + } + finally + { + Console.WriteLine("Success to preload : " + file.Name); + } + } + + GC.Collect(); + GC.WaitForPendingFinalizers(); + } + } +} diff --git a/Managed/Tizen.Init/Tizen.Init.csproj b/Managed/Tizen.Runtime/Tizen.Runtime.csproj similarity index 100% rename from Managed/Tizen.Init/Tizen.Init.csproj rename to Managed/Tizen.Runtime/Tizen.Runtime.csproj diff --git a/NativeLauncher/CMakeLists.txt b/NativeLauncher/CMakeLists.txt index 37d1e3f..73af492 100644 --- a/NativeLauncher/CMakeLists.txt +++ b/NativeLauncher/CMakeLists.txt @@ -51,6 +51,10 @@ IF(DEFINED DOTNET_DIR) SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -DDOTNET_DIR=${DOTNET_DIR}") ENDIF(DEFINED DOTNET_DIR) +IF(DEFINED TIZEN_PRELOAD_DIR) + SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -DTIZEN_PRELOAD_DIR=${TIZEN_PRELOAD_DIR}") +ENDIF(DEFINED TIZEN_PRELOAD_DIR) + IF(DEFINED USE_DEFAULT_BASE_ADDR) SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -DUSE_DEFAULT_BASE_ADDR") ENDIF(DEFINED USE_DEFAULT_BASE_ADDR) @@ -255,3 +259,4 @@ INSTALL(FILES inc/tac_common.h DESTINATION ${INCLUDEDIR}) INSTALL(FILES ../dotnet-launcher.pc DESTINATION ${LIBDIR}/pkgconfig) INSTALL(FILES dotnet-launcher.info DESTINATION /usr/share/parser-plugins) INSTALL(FILES dotnet.preload.list DESTINATION ${LOADERDIR}) +INSTALL(FILES Dotnet.Launcher.preload DESTINATION ${TIZEN_PRELOAD_DIR}) diff --git a/NativeLauncher/Dotnet.Launcher.preload b/NativeLauncher/Dotnet.Launcher.preload new file mode 100644 index 0000000..a7fe2d2 --- /dev/null +++ b/NativeLauncher/Dotnet.Launcher.preload @@ -0,0 +1,38 @@ +########################################### +## AssemblyName.dll TypeName ## +## AssemblyName.dll TypeName.Preload() ## +## The methods must not have parameters. ## +########################################### +System.IO.FileSystem.dll Interop +System.IO.FileSystem.dll +System.IO.FileSystem.dll System.IO.File +System.Security.Cryptography.Algorithms.dll Interop +System.Security.Cryptography.Algorithms.dll System.Security.Cryptography.MD5 +System.Collections.dll +System.Collections.dll System.Collections.Generic.HashSet`1 +System.Collections.dll System.Collections.Generic.Queue`1 +System.Private.Uri.dll +System.Private.Uri.dll System.Uri +System.Private.Xml.dll +System.Private.Xml.dll System.Xml.IXmlLineInfo +System.Private.Xml.dll System.Xml.IXmlNamespaceResolver +System.Runtime.dll System.Collections.Generic.ISet`1 +System.Runtime.dll System.Reflection.RuntimeReflectionExtensions +System.ObjectModel.dll System.Collections.ObjectModel.ObservableCollection`1 +System.ObjectModel.dll System.Collections.Specialized.INotifyCollectionChanged +System.ObjectModel.dll System.Collections.Specialized.NotifyCollectionChangedAction +System.ObjectModel.dll System.Collections.Specialized.NotifyCollectionChangedEventArgs +System.ObjectModel.dll System.Collections.Specialized.NotifyCollectionChangedEventHandler +System.ObjectModel.dll System.ComponentModel.INotifyPropertyChanged +System.ObjectModel.dll System.ComponentModel.PropertyChangedEventArgs +System.ObjectModel.dll System.ComponentModel.PropertyChangedEventHandler +System.ObjectModel.dll System.Windows.Input.ICommand +System.ComponentModel.dll System.IServiceProvider +System.Linq.dll System.Linq.Enumerable +System.Linq.dll System.Linq.EnumerableSorter`1 +System.Linq.dll System.Linq.IIListProvider`1 +System.Linq.dll System.Linq.IOrderedEnumerable`1 +System.Linq.dll System.Linq.IPartition`1 +System.Linq.dll System.Linq.OrderedEnumerable`1 +System.Linq.Expressions.dll System.Linq.Expressions.ExpressionVisitor +System.Security.Cryptography.Primitives.dll System.Security.Cryptography.HashAlgorithm diff --git a/NativeLauncher/inc/ni_common.h b/NativeLauncher/inc/ni_common.h index 31a679a..f33ddcc 100644 --- a/NativeLauncher/inc/ni_common.h +++ b/NativeLauncher/inc/ni_common.h @@ -91,6 +91,7 @@ void createNiUnderTAC(const std::string rootPaths[], int count, DWORD flags); /** * @brief creates a symbolic link file, the native image of TAC for specific package. * @param[i] pkgId package ID + * @param[i] flags additional flags for the image generator * @return ni_error_e */ ni_error_e createTACPkgRoot(const std::string& pkgId, DWORD flags); @@ -114,6 +115,7 @@ ni_error_e createNiUnderPkgRoot(const std::string& pkgId, DWORD flags); /** * @brief create a native image for a single dll in a package * @param[i] pkgId package ID + * @param[i] dllPath path to input DLL * @param[i] flags additional flags for the image generator * @return ni_error_e */ @@ -147,6 +149,7 @@ ni_error_e regenerateAppNI(DWORD flags); /** * @brief regenerate native image of TAC for all shared assembly. + * @param[i] flags additional flags for the image generator * @return ni_error_e */ ni_error_e regenerateTACNI(DWORD flags); diff --git a/NativeLauncher/inc/path_manager.h b/NativeLauncher/inc/path_manager.h index 72dc042..2d6c1b7 100644 --- a/NativeLauncher/inc/path_manager.h +++ b/NativeLauncher/inc/path_manager.h @@ -27,4 +27,4 @@ std::string getExtraDirs(); std::string getTPA(); -#endif /* __DLL_PATH_MANAGER_H__ */ \ No newline at end of file +#endif /* __DLL_PATH_MANAGER_H__ */ diff --git a/NativeLauncher/installer-plugin/prefer_nuget_cache_plugin.cc b/NativeLauncher/installer-plugin/prefer_nuget_cache_plugin.cc index 0d87f66..8ae9e00 100644 --- a/NativeLauncher/installer-plugin/prefer_nuget_cache_plugin.cc +++ b/NativeLauncher/installer-plugin/prefer_nuget_cache_plugin.cc @@ -294,7 +294,7 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *app } if (tacDB.empty()) { - _INFO("Not exist .deps.json file"); + _INFO("Not exist data for TAC in %s", pkgId); return 0; } @@ -447,6 +447,8 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_UPGRADE(const char *pkgId, const char *app if (updateTacDB(tac_db) < 0) { return -1; } + _INFO("Not exist data for TAC in %s", pkgId); + return 0; } else { for (auto& np : tacDB) { std::string tac_name = np.substr(0, np.find('/')); diff --git a/NativeLauncher/launcher/exec/loader.cc b/NativeLauncher/launcher/exec/loader.cc index 27602b8..a42eedc 100644 --- a/NativeLauncher/launcher/exec/loader.cc +++ b/NativeLauncher/launcher/exec/loader.cc @@ -91,7 +91,7 @@ static void __adapter_add_fd(void *user_data, int fd, __fd_handler = ecore_main_fd_handler_add(fd, static_cast(ECORE_FD_READ | ECORE_FD_ERROR), __process_fd_handler, NULL, NULL, NULL); - + if (__fd_handler == NULL) { _ERR("fd_handler is NULL"); close(fd); @@ -125,7 +125,7 @@ static void __loader_create_cb(bundle *extra, int type, void *user_data) _ERR("Failed to initialized"); } else { _INFO("Success to initialized"); - } + } } static int __loader_launch_cb(int argc, char **argv, const char *app_path, @@ -143,7 +143,7 @@ static int __loader_launch_cb(int argc, char **argv, const char *app_path, return 0; } - + static int __loader_terminate_cb(int argc, char **argv, void *user_data) { CoreRuntime* runtime = (CoreRuntime*)user_data; @@ -152,7 +152,7 @@ static int __loader_terminate_cb(int argc, char **argv, void *user_data) // 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(__appInfo.appid.c_str(), __appInfo.root.c_str(), + if (runtime->launch(__appInfo.appid.c_str(), __appInfo.root.c_str(), __appInfo.app_path.c_str(), argc - 1, argv + 1)) { _ERR("Failed to launch"); } @@ -165,7 +165,7 @@ static int __loader_terminate_cb(int argc, char **argv, void *user_data) extern "C" int realMain(int argc, char *argv[], const char* mode) { _INFO("##### Run in candidate mode #####"); - + CoreRuntime* runtime = new CoreRuntime(mode); // change cmdline from dotnet-hydra-loader to dotnet-loader @@ -189,7 +189,7 @@ extern "C" int realMain(int argc, char *argv[], const char* mode) .add_fd = __adapter_add_fd, .remove_fd = __adapter_remove_fd }; - + int ret = launchpad_loader_main(argc, argv, &callbacks, &adapter, runtime); delete runtime; diff --git a/NativeLauncher/launcher/lib/dotnet_launcher.cc b/NativeLauncher/launcher/lib/dotnet_launcher.cc index 7ed7f39..80ce717 100644 --- a/NativeLauncher/launcher/lib/dotnet_launcher.cc +++ b/NativeLauncher/launcher/lib/dotnet_launcher.cc @@ -272,28 +272,28 @@ static void setLang() free(lang); } -void CoreRuntime::preloadTypes() +void CoreRuntime::preload() { - const static std::string initDllPath = concatPath(__FRAMEWORK_DIR, "Tizen.Init.dll"); - if (!isFileExist(initDllPath)) { - _ERR("Failed to locate Tizen.Init.dll"); + const static std::string dllPath = concatPath(__FRAMEWORK_DIR, "Tizen.Runtime.dll"); + if (!isFileExist(dllPath)) { + _ERR("Failed to locate Tizen.Runtime.dll"); return; } - typedef void (*InitDelegate)(); - InitDelegate initDelegate; + typedef void (*PreloadDelegate)(); + PreloadDelegate preloadDelegate; int ret = createDelegate(__hostHandle, __domainId, - "Tizen.Init", - "Tizen.Init.TypeLoader", - "PreloadTypes", - (void**)&initDelegate); + "Tizen.Runtime", + "Tizen.Runtime.Preloader", + "Preload", + (void**)&preloadDelegate); if (ret < 0) { - _ERR("Failed to create delegate for PreloadTypes (0x%08x)", ret); + _ERR("Failed to create delegate for Tizen.Runtime Preload (0x%08x)", ret); } else { - initDelegate(); + preloadDelegate(); } } @@ -480,7 +480,7 @@ int CoreRuntime::initialize(LaunchMode launchMode) __initialized = true; if (launchMode == LaunchMode::loader) { - preloadTypes(); // Preload common managed code + preload(); // Preload common managed code } _INFO("CoreRuntime initialize success"); diff --git a/NativeLauncher/launcher/lib/dotnet_launcher.h b/NativeLauncher/launcher/lib/dotnet_launcher.h index 53c8bfb..ddaabd6 100644 --- a/NativeLauncher/launcher/lib/dotnet_launcher.h +++ b/NativeLauncher/launcher/lib/dotnet_launcher.h @@ -43,7 +43,7 @@ class CoreRuntime private: bool initializeCoreClr(const char* appId, const char* assemblyProbePaths, const char* NIProbePaths, const char* pinvokeProbePaths, const char* tpaList); - void preloadTypes(); + void preload(); coreclr_initialize_ptr initializeClr; coreclr_execute_assembly_ptr executeAssembly; coreclr_shutdown_ptr shutdown; @@ -56,7 +56,6 @@ class CoreRuntime int __fd; bool __initialized; bool __isProfileMode; - }; } // dotnetcore diff --git a/NativeLauncher/util/log_manager.cc b/NativeLauncher/util/log_manager.cc index 6caedf0..b1c8dd0 100644 --- a/NativeLauncher/util/log_manager.cc +++ b/NativeLauncher/util/log_manager.cc @@ -111,4 +111,3 @@ int redirectFD() return 0; } - diff --git a/packaging/dotnet-launcher.spec b/packaging/dotnet-launcher.spec index de66b4f..3e08edb 100644 --- a/packaging/dotnet-launcher.spec +++ b/packaging/dotnet-launcher.spec @@ -56,6 +56,7 @@ Requires(preun): /usr/bin/systemctl %define _native_lib_dir /usr/share/dotnet.tizen/lib %define _dotnet_dir /opt/usr/dotnet %define _system_base_addr_file /opt/usr/dotnet.system.base.addr +%define _tizen_preload_dir /usr/share/dotnet.tizen/preload %define _default_base_addr_start 0x3000000 @@ -109,6 +110,7 @@ cmake \ -DCROSSGEN_PATH=%{_runtime_dir}/crossgen \ -DINSTALL_MDPLUGIN_DIR=%{_install_mdplugin_dir} \ -DDOTNET_DIR=%{_dotnet_dir} \ + -DTIZEN_PRELOAD_DIR=%{_tizen_preload_dir} \ -DVERSION=%{version} \ -DNATIVE_LIB_DIR=%{_native_lib_dir} \ %ifarch %{arm} @@ -127,7 +129,7 @@ make %{?jobs:-j%jobs} VERBOSE=1 rm -rf %{buildroot} %make_install mkdir -p %{buildroot}%{_framework_dir} -mv Managed/Tizen.Init/bin/Release/Tizen.Init.dll %{buildroot}%{_framework_dir} +mv Managed/Tizen.Runtime/bin/Release/Tizen.Runtime.dll %{buildroot}%{_framework_dir} mv Managed/Dotnet.Launcher/bin/Release/Dotnet.Launcher.dll %{buildroot}%{_framework_dir} mkdir -p %{buildroot}%{_dotnet_dir} @@ -137,6 +139,8 @@ ln -sf %{_libdir}/libsqlite3.so.0 %{buildroot}%{_native_lib_dir}/libsqlite3.so mkdir -p %{buildroot}/etc/tmpfiles.d install -m 0644 %{name}.conf %{buildroot}/etc/tmpfiles.d/%{name}.conf +mkdir -p %{buildroot}%{_tizen_preload_dir} + %post mkdir -p /opt/etc/skel/.dotnet chsmack -t -a User::App::Shared /opt/etc/skel/.dotnet @@ -164,9 +168,10 @@ chsmack -t -a User::App::Shared /opt/etc/skel/.dotnet %{_libdir}/libtac_common.so /etc/tmpfiles.d/%{name}.conf /usr/share/parser-plugins/dotnet-launcher.info -%{_framework_dir}/Tizen.Init.dll %{_framework_dir}/Dotnet.Launcher.dll +%{_framework_dir}/Tizen.Runtime.dll %{_dotnet_dir} +%{_tizen_preload_dir} %files devel %manifest dotnet-launcher.manifest -- 2.7.4