Merge branch 'tizen' into tac_env
author최종헌/Common Platform Lab(SR)/Engineer/삼성전자 <j-h.choi@samsung.com>
Thu, 4 Jul 2019 00:44:57 +0000 (09:44 +0900)
committerj-h.choi <j-h.choi@samsung.com>
Thu, 4 Jul 2019 00:52:28 +0000 (09:52 +0900)
Init/Init.cs
Init/Tizen.Init.csproj
NativeLauncher/tool/ni_common.cc

index 5658226..97eeeeb 100644 (file)
@@ -18,168 +18,187 @@ using System;
 using System.Reflection;
 using System.Runtime.Loader;
 using System.IO;
+using System.Collections.Generic;
 
 namespace Tizen.Init {
 
     class TypeLoader
     {
-        static string[,] assem_type = new string[,] 
+        // key : assembly name, value : list of types
+        static IDictionary<string, List<string>> assem_type = new Dictionary<string, List<string>>
         {
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.Box"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.Button"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.Check"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.Color"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.Conformant"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.DateTimeSelector"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.DisplayRotation"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.EdjeObject"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.EdjeObject+SignalData"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.EdjeTextPartObject"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.Elementary"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.Entry"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.EvasKeyEventArgs"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.EvasMap"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.EvasObject"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.FocusDirection"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.GenList"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.GestureLayer+GestureType"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.IInvalidatable"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.Image"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.ItemObject+SignalData"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.Label"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.Layout"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.Naviframe"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.NaviItem"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.Point3D"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.ProgressBar"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.Radio"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.Rect"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.Rectangle"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.Scroller"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.Size"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.Slider"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.Spinner"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.Widget"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.Window"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "ElmSharp.WrapType"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.dll", "Interop"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.Wearable.dll", "ElmSharp.Wearable.CircleDateTimeSelector"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.Wearable.dll", "ElmSharp.Wearable.CircleGenList"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.Wearable.dll", "ElmSharp.Wearable.CircleScroller"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.Wearable.dll", "ElmSharp.Wearable.CircleSpinner"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.Wearable.dll", "ElmSharp.Wearable.ICircleWidget"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.Wearable.dll", "ElmSharp.Wearable.IRotaryActionWidget"},
-            {"/usr/share/dotnet.tizen/framework/ElmSharp.Wearable.dll", "Interop"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.IO.FileSystem.dll", "Interop"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.IO.FileSystem.dll", "<PrivateImplementationDetails>"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.IO.FileSystem.dll", "System.IO.File"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.Security.Cryptography.Algorithms.dll", "Interop"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.Security.Cryptography.Algorithms.dll", "System.Security.Cryptography.MD5"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.Collections.dll", "<PrivateImplementationDetails>"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.Collections.dll", "System.Collections.Generic.HashSet`1"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.Collections.dll", "System.Collections.Generic.Queue`1"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.Private.Uri.dll", "<PrivateImplementationDetails>"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.Private.Uri.dll", "System.Uri"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.Private.Xml.dll", "<PrivateImplementationDetails>"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.Private.Xml.dll", "System.Xml.IXmlLineInfo"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.Private.Xml.dll", "System.Xml.IXmlNamespaceResolver"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.Runtime.dll", "System.Collections.Generic.ISet`1"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.Runtime.dll", "System.Reflection.RuntimeReflectionExtensions"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.ObjectModel.dll", "System.Collections.ObjectModel.ObservableCollection`1"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.ObjectModel.dll", "System.Collections.Specialized.INotifyCollectionChanged"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.ObjectModel.dll", "System.Collections.Specialized.NotifyCollectionChangedAction"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.ObjectModel.dll", "System.Collections.Specialized.NotifyCollectionChangedEventArgs"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.ObjectModel.dll", "System.Collections.Specialized.NotifyCollectionChangedEventHandler"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.ObjectModel.dll", "System.ComponentModel.INotifyPropertyChanged"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.ObjectModel.dll", "System.ComponentModel.PropertyChangedEventArgs"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.ObjectModel.dll", "System.ComponentModel.PropertyChangedEventHandler"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.ObjectModel.dll", "System.Windows.Input.ICommand"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.ComponentModel.dll", "System.IServiceProvider"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.Linq.dll", "System.Linq.Enumerable"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.Linq.dll", "System.Linq.EnumerableSorter`1"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.Linq.dll", "System.Linq.IIListProvider`1"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.Linq.dll", "System.Linq.IOrderedEnumerable`1"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.Linq.dll", "System.Linq.IPartition`1"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.Linq.dll", "System.Linq.OrderedEnumerable`1"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.Linq.Expressions.dll", "System.Linq.Expressions.ExpressionVisitor"},
-            {"/usr/share/dotnet.tizen/netcoreapp/System.Security.Cryptography.Primitives.dll", "System.Security.Cryptography.HashAlgorithm"},
-            {"/usr/share/dotnet.tizen/framework/Tizen.Applications.Common.dll", "Interop"},
-            {"/usr/share/dotnet.tizen/framework/Tizen.Applications.Common.dll", "Tizen.Applications.Application"},
-            {"/usr/share/dotnet.tizen/framework/Tizen.Applications.Common.dll", "Tizen.Applications.CoreApplication"},
-            {"/usr/share/dotnet.tizen/framework/Tizen.Applications.Common.dll", "Tizen.Applications.CoreBackend.EventType"},
-            {"/usr/share/dotnet.tizen/framework/Tizen.Applications.Common.dll", "Tizen.Applications.TizenSynchronizationContext"},
-            {"/usr/share/dotnet.tizen/framework/Tizen.Applications.UI.dll", "Tizen.Applications.CoreUIApplication"},
-            {"/usr/share/dotnet.tizen/framework/Tizen.Applications.UI.dll", "Interop"},
-            {"/usr/share/dotnet.tizen/framework/Tizen.dll", "Interop"},
-            {"/usr/share/dotnet.tizen/framework/Tizen.Log.dll", "Interop"},
-            {"/usr/share/dotnet.tizen/framework/Tizen.Log.dll", "Tizen.Log"},
-            {"/usr/share/dotnet.tizen/framework/Tizen.System.Information.dll", "Tizen.System.Information"}
+            {"ElmSharp", new List<string>(){
+                "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<string>(){
+                "ElmSharp.Wearable.CircleDateTimeSelector",
+                "ElmSharp.Wearable.CircleGenList",
+                "ElmSharp.Wearable.CircleScroller",
+                "ElmSharp.Wearable.CircleSpinner",
+                "ElmSharp.Wearable.ICircleWidget",
+                "ElmSharp.Wearable.IRotaryActionWidget",
+                "Interop"}},
+            {"System.IO.FileSystem", new List<string>(){
+                "Interop",
+                "<PrivateImplementationDetails>",
+                "System.IO.File"}},
+            {"System.Security.Cryptography.Algorithms", new List<string>(){
+                "Interop",
+                "System.Security.Cryptography.MD5"}},
+            {"System.Collections", new List<string>(){
+                "<PrivateImplementationDetails>",
+                "System.Collections.Generic.HashSet`1",
+                "System.Collections.Generic.Queue`1"}},
+            {"System.Private.Uri", new List<string>(){
+                "<PrivateImplementationDetails>",
+                "System.Uri"}},
+            {"System.Private.Xml", new List<string>(){
+                "<PrivateImplementationDetails>",
+                "System.Xml.IXmlLineInfo",
+                "System.Xml.IXmlNamespaceResolver"}},
+            {"System.Runtime", new List<string>(){
+                "System.Collections.Generic.ISet`1",
+                "System.Reflection.RuntimeReflectionExtensions"}},
+            {"System.ObjectModel", new List<string>(){
+                "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<string>(){
+                "System.IServiceProvider"}},
+            {"System.Linq", new List<string>(){
+                "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<string>(){
+                "System.Linq.Expressions.ExpressionVisitor"}},
+            {"System.Security.Cryptography.Primitives", new List<string>(){
+                "System.Security.Cryptography.HashAlgorithm"}},
+            {"Tizen.Applications.Common", new List<string>(){
+                "Interop",
+                "Tizen.Applications.Application",
+                "Tizen.Applications.CoreApplication",
+                "Tizen.Applications.CoreBackend.EventType",
+                "Tizen.Applications.TizenSynchronizationContext"}},
+            {"Tizen.Applications.UI", new List<string>(){
+                "Tizen.Applications.CoreUIApplication",
+                "Interop"}},
+            {"Tizen", new List<string>(){
+                "Interop"}},
+            {"Tizen.Log", new List<string>(){
+                "Interop",
+                "Tizen.Log"}},
+            {"Tizen.System.Information", new List<string>(){
+                "Tizen.System.Information"}}
         };
 
-       static void PreloadEnd()
-       {
-               GC.Collect();
-               GC.WaitForPendingFinalizers();
-       }
+        static void PreloadEnd()
+        {
+            assem_type = null;
+            GC.Collect();
+            GC.WaitForPendingFinalizers();
+        }
+
+        static void PreloadTypes()
+        {
+            foreach (KeyValuePair<string, List<string>> item in assem_type)
+            {
+                Assembly asm = LoadAssembly(item.Key);
+                if (asm != null) {
+                    foreach (string t in item.Value)
+                    {
+                        LoadType(asm, t);
+                    }
+                }
+            }
 
-       static int PreloadTypes()
-       {
-               string loaded_assem_name = new string("");
-               Assembly loaded_assem = null;
-               for (int i = 0; i < assem_type.GetLength(0); i++)
-               {
-                       if (assem_type[i,0] != loaded_assem_name)
-                       {
-                               loaded_assem_name = assem_type[i,0];
-                               loaded_assem = LoadAssembly(loaded_assem_name);
-                       }
-                       if (loaded_assem != null)
-                       {
-                               LoadType(loaded_assem, assem_type[i,1]);
-                       }
-               }
-               PreloadEnd();
+            PreloadLibICU();
 
-               return 0;
-       }
-       static Assembly LoadAssembly(string path)
-       {
-               var context = AssemblyLoadContext.Default;
-               Assembly ret = null;
+            PreloadEnd();
+        }
 
-               try
-               {
-                       if (File.Exists(path.Replace(".dll", ".ni.dll")))
-                       {
-                               ret = context.LoadFromNativeImagePath(path.Replace(".dll", ".ni.dll"), path);
-                       } else
-                       {//by concept LoadFromNativeImagePath has to do fallbacks to
-                        //properly passed IL asms, but it does not
-                               ret = context.LoadFromAssemblyPath(path);
-                       }
-               }
-               catch (Exception e) 
-               {
-                       Console.WriteLine(e.ToString());
+        static Assembly LoadAssembly(string name)
+        {
+            var context = AssemblyLoadContext.Default;
+            Assembly ret = null;
 
-                       return null;
-               }
+            try
+            {
+                ret = context.LoadFromAssemblyName(new AssemblyName(name));
+            }
+            catch (Exception e)
+            {
+                Console.WriteLine(e.ToString());
+                return null;
+            }
 
-               return ret;
-       }
-       static int 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());
-                       return 1;
-               }
+            return ret;
+        }
 
-               return 0;
-       }
+        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());
+            }
+        }
+
+        // CU loading makes launching time much slower.
+        // To prevent that kind of overhead, preload ICU by calling String.ToLower()
+        static void PreloadLibICU()
+        {
+            // to preinitialize icu, do string compare
+            if ("A".ToLower() != "a") {
+                Console.WriteLine("Failed to String.ToLower()");
+            }
+        }
     }
 }
index 6becf02..447dcb6 100644 (file)
@@ -5,16 +5,4 @@
            <NoWin32Manifest>True</NoWin32Manifest>
            <Configuration>Release</Configuration>
     </PropertyGroup>
-
-    <ItemGroup>
-       <Reference Include="System.Runtime">
-       </Reference>
-       <Reference Include="System.Runtime.Loader">
-       </Reference>
-       <Reference Include="System.Console">
-       </Reference>
-       <Reference Include="System.IO.FileSystem">
-       </Reference>
-    </ItemGroup>
-
 </Project>
index ceba067..182720d 100644 (file)
@@ -85,15 +85,20 @@ static std::string getNiFilePath(const std::string& dllPath)
 
 static std::string getAppNIPath(const std::string& niPath)
 {
+       std::string fileName;
+       std::string niDirPath;
+       std::string prevPath;
+
        size_t index = niPath.find_last_of("/");
-       if (index == std::string::npos) {
-               fprintf(stderr, "dllPath doesnot contains path info\n");
-               return "";
+       if (index != std::string::npos) {
+               prevPath = niPath.substr(0, index);
+               fileName = niPath.substr(index + 1, niPath.length());
+       } else {
+               prevPath = ".";
+               fileName = niPath;
        }
 
-       std::string prevPath = niPath.substr(0, index);
-       std::string fileName = niPath.substr(index, niPath.length());
-       std::string niDirPath = concatPath(prevPath, APP_NI_SUB_DIR);
+       niDirPath = concatPath(prevPath, APP_NI_SUB_DIR);
 
        if (!isFileExist(niDirPath)) {
                if (mkdir(niDirPath.c_str(), 0755) == 0) {
@@ -103,7 +108,7 @@ static std::string getAppNIPath(const std::string& niPath)
                }
        }
 
-       return niDirPath + fileName;
+       return concatPath(niDirPath, fileName);
 }
 
 static bool niExist(const std::string& path)
@@ -371,7 +376,8 @@ ni_error_e createNiDllUnderPkgRoot(const std::string& pkgId, const std::string&
 
        std::string binDir = concatPath(pkgRoot, "bin");
        std::string libDir = concatPath(pkgRoot, "lib");
-       std::string paths = binDir + ":" + libDir;
+       std::string appTAC = concatPath(binDir, ".TAC.Release");
+       std::string paths = binDir + ":" + libDir + ":" + appTAC;
 
        return crossgen(dllPath, paths, enableR2R, true);
 }