IF(NOT DEFINED NO_TIZEN)
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
- INSTALL(FILES packaging/dotnet.loader DESTINATION ${LOADERDIR})
- INSTALL(FILES packaging/dotnet-launcher.ini DESTINATION ${CONFIGDIR})
+ INSTALL(FILES dotnet.loader DESTINATION ${LOADERDIR})
+ INSTALL(FILES dotnet-launcher.ini DESTINATION ${CONFIGDIR})
ENDIF(NOT DEFINED NO_TIZEN)
--- /dev/null
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+
+ <PropertyGroup>
+ <CoreFXRefPath>/opt/usr/share/tizen.net/ref</CoreFXRefPath>
+ <TizenDeviceAPIPath>/usr/share/assembly</TizenDeviceAPIPath>
+ </PropertyGroup>
+
+ <PropertyGroup>
+ <NoCompilerStandardLib Condition=" '$(NoCompilerStandardLib)' == '' ">true</NoCompilerStandardLib>
+ <NoStdLib Condition=" '$(NoStdLib)' == '' ">true</NoStdLib>
+ <AdditionalLibPaths>$(CoreFXRefPath);$(TizenDeviceAPIPath)</AdditionalLibPaths>
+ <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
+ <!-- Temporary suppress the warning... -->
+ <NoWarn>1701</NoWarn>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <CoreFXRefDir Include="$(CoreFXRefPath)" Condition="Exists('$(CoreFXRefPath)')"/>
+ <CoreFXRefAssemblies Include="@(CoreFXRefDir->'%(FullPath)/*.dll')" Exclude="@(CoreFXRefDir->'%(FullPath)/mscorlib.dll')"/>
+
+ <TizenDeviceAPIDir Include="$(TizenDeviceAPIPath)" Condition="Exists('$(TizenDeviceAPIPath)')"/>
+ <TizenDeviceAPIAssemblies Include="@(TizenDeviceAPIDir->'%(FullPath)/*.dll')"/>
+ </ItemGroup>
+
+ <ItemGroup>
+ <ReferencePath Include="@(CoreFXRefAssemblies->'%(Filename).dll')"/>
+ <ReferencePath Include="@(TizenDeviceAPIAssemblies->'%(Filename).dll')"/>
+ </ItemGroup>
+
+ <Target Name="BeforeBuild">
+ <Message Text="[CoreFX Reference Environment!]"/>
+ <Message Text="CoreFX dir = $(CoreFXRefPath)"/>
+ <Message Text="CoreFX dir Check Ok" Condition="Exists('$(CoreFXRefPath)')"/>
+ <Message Text="Tizen Device API dir = $(TizenDeviceAPIPath)"/>
+ <Message Text="Tizen Device API Check Ok" Condition="Exists('$(TizenDeviceAPIPath)')"/>
+ <Message Text="CoreFXRefDir = @(CoreFXRefDir)"/>
+ <Message Text="TizenDeviceAPIDir = @(TizenDeviceAPIDir)"/>
+ <Message Text="CoreFXRefDir.Identity = %(CoreFXRefDir.Identity)"/>
+ <Message Text="TizenDeviceAPIDir.Identity = %(TizenDeviceAPIDir.Identity)"/>
+ <Message Text="CoreFXRefAssemblies = %(CoreFXRefAssemblies.Identity)"/>
+ <Message Text="TizenDeviceAPIAssemblies = %(TizenDeviceAPIAssemblies.Identity)"/>
+ </Target>
+
+ <PropertyGroup>
+ <CheckConfigDependsOn>CheckEnvironment</CheckConfigDependsOn>
+ </PropertyGroup>
+</Project>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Project InitialTargets="CheckConfig" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <OutputType>Library</OutputType>
+ <AssemblyName>Tizen.Runtime</AssemblyName>
+ </PropertyGroup>
+
+ <PropertyGroup Condition=" '$(Configuration)' == 'Debug'">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <OutputPath>bin/</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ </PropertyGroup>
+
+ <PropertyGroup Condition=" '$(Configuration)' == 'Release'">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin/</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ </PropertyGroup>
+
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ <AssemblyOriginatorKeyFile>Tizen.Runtime.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <Compile Include="Tizen.Runtime/AssemblyLoader.cs" />
+ <Compile Include="Tizen.Runtime/Log.cs" />
+ <Compile Include="Tizen.Runtime/AssemblyManager.cs" />
+ </ItemGroup>
+
+ <Target Name="CheckConfig">
+ <Message Text="MSBuildProjectDirectory = $(MSBuildProjectDirectory)"/>
+ </Target>
+
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(MSBuildProjectDirectory)/Tizen.CoreFX.Ref.Targets" />
+</Project>
--- /dev/null
+using System;
+using System.IO;
+using System.Reflection;
+using System.Runtime.Loader;
+using System.Collections.Generic;
+
+namespace Tizen.Runtime
+{
+ public class AssemblyLoader : AssemblyLoadContext
+ {
+ private SortedSet<string> _dllDirectories = new SortedSet<string>();
+ public IEnumerable<string> DllDirectories
+ {
+ get { return _dllDirectories; }
+ }
+
+ public void AddSearchableDirectory(string directory)
+ {
+ if (Directory.Exists(directory))
+ {
+ _dllDirectories.Add(directory);
+ }
+ }
+
+ public void RemoveSearchableDirectory(string directory)
+ {
+ _dllDirectories.Remove(directory);
+ }
+
+ protected override Assembly Load(AssemblyName assemblyName)
+ {
+ ALog.Debug($"Load!! : {assemblyName.Name}");
+ foreach (string dir in DllDirectories)
+ {
+ FileInfo f = new FileInfo(Path.Combine(dir, $"{assemblyName.Name}.dll"));
+ ALog.Debug(f.FullName);
+ if (File.Exists(f.FullName))
+ {
+ return LoadFromAssemblyPath(f.FullName);
+ }
+ }
+ return Assembly.Load(assemblyName);
+ }
+ }
+}
--- /dev/null
+using System;
+using System.IO;
+using System.Reflection;
+using System.Runtime.Loader;
+
+namespace Tizen.Runtime
+{
+ public static class AssemblyManager
+ {
+ private static void PrintException(Exception exception)
+ {
+ while (exception != null)
+ {
+ ALog.Debug(exception.Message);
+ ALog.Debug(exception.StackTrace);
+ exception = exception.InnerException;
+ }
+ }
+
+ public static AssemblyLoader CurrentAssemblyLoaderContext
+ {
+ get;
+ private set;
+ }
+
+ public static bool Initialize(string searchableDirectories, string preloadDllPaths)
+ {
+ try
+ {
+ CurrentAssemblyLoaderContext = new AssemblyLoader();
+
+ if (searchableDirectories != null)
+ {
+ string[] dirs = searchableDirectories.Split(':');
+ foreach (string dir in dirs)
+ {
+ CurrentAssemblyLoaderContext.AddSearchableDirectory(dir);
+ }
+ }
+
+ if (preloadDllPaths != null)
+ {
+ string[] dllPaths = preloadDllPaths.Split(':');
+ foreach (string dllPath in dllPaths)
+ {
+ FileInfo f = new FileInfo(dllPath);
+ if (File.Exists(f.FullName))
+ {
+ CurrentAssemblyLoaderContext.LoadFromAssemblyPath(f.FullName);
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ ALog.Debug("Exception on Initialized");
+ PrintException(e);
+ return false;
+ }
+ return true;
+ }
+
+ public static void Execute(string dllPath)
+ {
+ try
+ {
+ FileInfo f = new FileInfo(dllPath);
+ if (File.Exists(f.FullName))
+ {
+ Assembly asm = CurrentAssemblyLoaderContext.LoadFromAssemblyPath(f.FullName);
+ if (asm == null) throw new FileNotFoundException($"{f.FullName} is not found");
+ if (asm.EntryPoint == null) throw new ArgumentException($"{f.FullName} did not have EntryPoint");
+ asm.EntryPoint.Invoke(null, new string[]{null});
+ }
+ }
+ catch (Exception e)
+ {
+ ALog.Debug("Exception on Execute");
+ PrintException(e);
+ }
+ }
+
+ public static void Finish()
+ {
+ }
+ }
+}
--- /dev/null
+using System;
+#if !CLOG
+using Tizen;
+#endif
+
+namespace Tizen.Runtime
+{
+#if CLOG
+ internal static class Log
+ {
+ static void Print(string tag, string message)
+ {
+ string[] lines = message.Split('\r');
+ foreach (string line in lines)
+ {
+ Console.WriteLine($"{tag} : {message}");
+ }
+ }
+
+ public static void Debug(string tag, string message)
+ {
+ Print($"D/{tag}", message);
+ }
+
+ public static void Info(string tag, string message)
+ {
+ Print($"I/{tag}", message);
+ }
+
+ public static void Error(string tag, string message)
+ {
+ Print($"E/{tag}", message);
+ }
+ }
+#endif
+ internal static class ALog
+ {
+ static string TAG = "Tizen.Runtime";
+
+ public static void Debug(string message)
+ {
+ Log.Debug(TAG, message);
+ }
+
+ public static void Info(string message)
+ {
+ Log.Info(TAG, message);
+ }
+
+ public static void Error(string message)
+ {
+ Log.Error(TAG, message);
+ }
+ }
+}
--- /dev/null
+using Tizen.Runtime;
+
+public class Program
+{
+ public static void Main(string[] args)
+ {
+ if (args.Length < 2)
+ {
+ ALog.Debug("Cancel..");
+ return;
+ }
+ string preload = Environment.GetEnvironmentVariable("PRELOAD_DLLS");
+ string searchable = String.Join(":", args, 1, args.Length - 1);
+
+ if (AssemblyManager.Initialize(searchable, preload))
+ {
+ ALog.Debug("After Initialized...");
+ AssemblyManager.Execute(args[0]);
+ }
+ }
+}
BuildRequires: pkgconfig(ecore)
BuildRequires: pkgconfig(launchpad)
BuildRequires: aul-devel
+BuildRequires: corefx-managed-32b-ref
+BuildRequires: mono-compiler
+BuildRequires: mono-devel
+BuildRequires: csapi-tizen
Requires: aul
Requires(post): /sbin/ldconfig
-DLOADERDIR=%{_loaderdir} \
-DCONFIGDIR=%{_configdir} \
-DCMAKE_BUILD_TYPE=%{_buildmode} \
- -DVERSION=%{version}
+ -DVERSION=%{version} \
+ NativeLauncher
make %{?jobs:-j%jobs}
+xbuild /p:Configuration=%{_buildmode} Tizen.Runtime/Tizen.Runtime.csproj
+
%install
rm -rf %{buildroot}
%make_install
+install -p -m 644 Tizen.Runtime/bin/Tizen.Runtime.dll %{buildroot}%{_bindir}
%files
%manifest dotnet-launcher.manifest
%config /etc/dotnet-launcher.ini
%{_loaderdir}/dotnet.loader
%caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/dotnet-launcher
+%caps(cap_mac_admin,cap_setgid=ei) %{_bindir}/Tizen.Runtime.dll