Integrate managed code into Tizen.Runtime (#228)
author최종헌/Common Platform Lab(SR)/Engineer/삼성전자 <j-h.choi@samsung.com>
Thu, 7 May 2020 04:49:03 +0000 (13:49 +0900)
committer이형주/Common Platform Lab(SR)/Staff Engineer/삼성전자 <leee.lee@samsung.com>
Thu, 7 May 2020 04:49:03 +0000 (13:49 +0900)
Change-Id: I8dde5eca0a3115b5ae2eac2527810529f11ebfbb

Managed/Dotnet.Launcher/Dotnet.Launcher.cs [deleted file]
Managed/Dotnet.Launcher/Dotnet.Launcher.csproj [deleted file]
Managed/Managed.sln
Managed/Tizen.Runtime/Environment.cs [new file with mode: 0644]
Managed/Tizen.Runtime/Preloader.cs [new file with mode: 0644]
Managed/Tizen.Runtime/Tizen.Runtime.cs [deleted file]
NativeLauncher/launcher/lib/dotnet_launcher.cc
packaging/dotnet-launcher.spec

diff --git a/Managed/Dotnet.Launcher/Dotnet.Launcher.cs b/Managed/Dotnet.Launcher/Dotnet.Launcher.cs
deleted file mode 100644 (file)
index 6e9d3d2..0000000
+++ /dev/null
@@ -1,26 +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.
- */
-
-namespace Dotnet.Launcher
-{
-    class Environment
-    {
-        public static void SetEnvironmentVariable(string variable, string value)
-        {
-            System.Environment.SetEnvironmentVariable(variable, value);
-        }
-    }
-}
diff --git a/Managed/Dotnet.Launcher/Dotnet.Launcher.csproj b/Managed/Dotnet.Launcher/Dotnet.Launcher.csproj
deleted file mode 100644 (file)
index ae1a3a5..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<Project Sdk="Microsoft.NET.Sdk">
-    <PropertyGroup>
-           <TargetFramework>netcoreapp2.1</TargetFramework>
-           <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
-           <NoWin32Manifest>True</NoWin32Manifest>
-           <Configuration>Release</Configuration>
-    </PropertyGroup>
-</Project>
index 150e7489836eaa0bcd47c255f97c6ecd6df2d435..2126fb02bfcdba94a3bb8bf903c2bbc0145373f0 100644 (file)
@@ -2,8 +2,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
 # 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.Runtime", "Tizen.Runtime\Tizen.Runtime.csproj", "{10904A32-26EB-4135-B012-8F123A63E29D}"
 EndProject
 Global
@@ -12,10 +10,6 @@ Global
                Release|Any CPU = Release|Any CPU
        EndGlobalSection
        GlobalSection(ProjectConfigurationPlatforms) = postSolution
-               {92F481F9-A099-40D7-9DD7-BE1B64C010D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-               {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
                {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
diff --git a/Managed/Tizen.Runtime/Environment.cs b/Managed/Tizen.Runtime/Environment.cs
new file mode 100644 (file)
index 0000000..6a03854
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+namespace Tizen.Runtime
+{
+    public class Environment
+    {
+        public static void SetEnvironmentVariable(string variable, string value)
+        {
+            System.Environment.SetEnvironmentVariable(variable, value);
+        }
+    }
+}
diff --git a/Managed/Tizen.Runtime/Preloader.cs b/Managed/Tizen.Runtime/Preloader.cs
new file mode 100644 (file)
index 0000000..9965caf
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * 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
+{
+    public class Preloader
+    {
+        const string preloadPath = "/usr/share/dotnet.tizen/preload/";
+        public static void Preload()
+        {
+            string[] paths = Directory.GetFiles(preloadPath, "*.preload");
+            Array.Sort(paths);
+            foreach (string path in paths)
+            {
+                // ex) Tizen.preload / 0A.Tizen.preload / A0.Tizen.preload / .0.Tizen.preload / .00.Tizen.preload
+                if (!char.IsNumber(Path.GetFileName(path), 0) || !char.IsNumber(Path.GetFileName(path), 1))
+                    continue;
+
+                // ex) 000.Tizen.preload / 0.Tizen.preload
+                if (Path.GetFileName(path).IndexOf('.') != 2)
+                    continue;
+
+                try
+                {
+                    BindingFlags bindingFlag = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
+                    foreach (string line in File.ReadLines(path))
+                    {
+                        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 " + path + " file open");
+                }
+                finally
+                {
+                    Console.WriteLine("Success to preload : " + path);
+                }
+            }
+
+            GC.Collect();
+            GC.WaitForPendingFinalizers();
+        }
+    }
+}
diff --git a/Managed/Tizen.Runtime/Tizen.Runtime.cs b/Managed/Tizen.Runtime/Tizen.Runtime.cs
deleted file mode 100644 (file)
index 580c44f..0000000
+++ /dev/null
@@ -1,105 +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.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()
-        {
-            string[] paths = Directory.GetFiles(preloadPath, "*.preload");
-            Array.Sort(paths);
-            foreach (string path in paths)
-            {
-                // ex) Tizen.preload / 0A.Tizen.preload / A0.Tizen.preload / .0.Tizen.preload / .00.Tizen.preload
-                if (!char.IsNumber(Path.GetFileName(path), 0) || !char.IsNumber(Path.GetFileName(path), 1))
-                    continue;
-
-                // ex) 000.Tizen.preload / 0.Tizen.preload
-                if (Path.GetFileName(path).IndexOf('.') != 2)
-                    continue;
-
-                try
-                {
-                    BindingFlags bindingFlag = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
-                    foreach (string line in File.ReadLines(path))
-                    {
-                        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 " + path + " file open");
-                }
-                finally
-                {
-                    Console.WriteLine("Success to preload : " + path);
-                }
-            }
-
-            GC.Collect();
-            GC.WaitForPendingFinalizers();
-        }
-    }
-}
index 02c077905fc5e5100940f86f462574a27711dcc0..f88d9a94920ca6cda113cc0dbfdef11cea82bff5 100644 (file)
@@ -459,9 +459,9 @@ int CoreRuntime::initialize(LaunchMode launchMode)
                return -1;
        }
 
-       int st = createDelegate(__hostHandle, __domainId, "Dotnet.Launcher", "Dotnet.Launcher.Environment", "SetEnvironmentVariable", (void**)&setEnvironmentVariable);
+       int st = createDelegate(__hostHandle, __domainId, "Tizen.Runtime", "Tizen.Runtime.Environment", "SetEnvironmentVariable", (void**)&setEnvironmentVariable);
        if (st < 0 || setEnvironmentVariable == nullptr) {
-               _ERR("Create delegate for Dotnet.Launcher.dll -> Dotnet.Launcher.Environment -> SetEnvironmentVariable failed (0x%08x)", st);
+               _ERR("Create delegate for Tizen.Runtime.dll -> Tizen.Runtime.Environment -> SetEnvironmentVariable failed (0x%08x)", st);
                return -1;
        }
 
index f33c6f289049132df5257dcca2c0e1cf9d022f8a..2d3ada9bca731833f27bd6530dc8df1b67c9d8af 100644 (file)
@@ -132,7 +132,6 @@ rm -rf %{buildroot}
 %make_install
 mkdir -p %{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}
 mkdir -p %{buildroot}%{_native_lib_dir}
@@ -173,7 +172,6 @@ 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}/Dotnet.Launcher.dll
 %{_framework_dir}/Tizen.Runtime.dll
 %{_dotnet_dir}
 %{_ibc_data_dir}