Skip to content

Commit

Permalink
Create a portable library version.
Browse files Browse the repository at this point in the history
  • Loading branch information
weltkante committed Dec 14, 2015
1 parent cacedc6 commit c3e22d1
Show file tree
Hide file tree
Showing 10 changed files with 321 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ build/
bld/
[Bb]in/
[Oo]bj/
project.lock.json

# Roslyn cache directories
*.ide/
Expand Down
27 changes: 27 additions & 0 deletions lzma.sln
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "shared", "shared\shared.shp
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "library", "library\library.csproj", "{136726D6-588F-446C-BC0F-77D02350FAE4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "portable", "portable\portable.csproj", "{801178B6-36EF-44F7-84A5-06B06D5EA07F}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
shared\shared.projitems*{b55693b1-3a6d-44bc-92f9-1e2f7018553f}*SharedItemsImports = 4
shared\shared.projitems*{d2b79ce1-6d9a-4785-8255-10890f5ffdff}*SharedItemsImports = 13
shared\shared.projitems*{801178b6-36ef-44f7-84a5-06b06d5ea07f}*SharedItemsImports = 4
shared\shared.projitems*{136726d6-588f-446c-bc0f-77d02350fae4}*SharedItemsImports = 4
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -183,6 +186,30 @@ Global
{136726D6-588F-446C-BC0F-77D02350FAE4}.ReleaseTest|Mixed Platforms.Build.0 = Release|Any CPU
{136726D6-588F-446C-BC0F-77D02350FAE4}.ReleaseTest|Win32.ActiveCfg = Release|Any CPU
{136726D6-588F-446C-BC0F-77D02350FAE4}.ReleaseTest|Win32.Build.0 = Release|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.Debug|Win32.ActiveCfg = Debug|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.Debug|Win32.Build.0 = Debug|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.DebugTest|Any CPU.ActiveCfg = Debug|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.DebugTest|Any CPU.Build.0 = Debug|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.DebugTest|Mixed Platforms.ActiveCfg = Debug|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.DebugTest|Mixed Platforms.Build.0 = Debug|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.DebugTest|Win32.ActiveCfg = Debug|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.DebugTest|Win32.Build.0 = Debug|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.Release|Any CPU.Build.0 = Release|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.Release|Win32.ActiveCfg = Release|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.Release|Win32.Build.0 = Release|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.ReleaseTest|Any CPU.ActiveCfg = Release|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.ReleaseTest|Any CPU.Build.0 = Release|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.ReleaseTest|Mixed Platforms.ActiveCfg = Release|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.ReleaseTest|Mixed Platforms.Build.0 = Release|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.ReleaseTest|Win32.ActiveCfg = Release|Any CPU
{801178B6-36EF-44F7-84A5-06B06D5EA07F}.ReleaseTest|Win32.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
30 changes: 30 additions & 0 deletions portable/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Resources;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("portable")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("portable")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
55 changes: 55 additions & 0 deletions portable/portable.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{801178B6-36EF-44F7-84A5-06B06D5EA07F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ManagedLzma</RootNamespace>
<AssemblyName>ManagedLzma</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;BUILD_PORTABLE;DISABLE_TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;BUILD_PORTABLE;DISABLE_TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<None Include="project.json" />
<!-- A reference to the entire .NET Framework is automatically included -->
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="..\shared\shared.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
17 changes: 17 additions & 0 deletions portable/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"supports": {
"net46.app": {},
"uwp.10.0.app": {},
"dnxcore50.app": {}
},
"dependencies": {
"Microsoft.NETCore": "5.0.0",
"Microsoft.NETCore.Portable.Compatibility": "1.0.0",
"System.Security.Cryptography.Algorithms": "4.0.0-beta-23409"
},
"frameworks": {
"dotnet": {
"imports": "portable-net452+win81"
}
}
}
18 changes: 18 additions & 0 deletions shared/Compression/Implementation/Threads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ partial class LZMA

internal sealed class CThread
{
#if BUILD_PORTABLE
internal System.Threading.Tasks.Task _task;
#else
internal System.Threading.Thread _thread;
#endif
}

internal static void Thread_Construct(out CThread p)
Expand All @@ -30,6 +34,8 @@ internal static void Thread_Close(ref CThread p)
{
#if !DISABLE_TRACE
Trace.MatchThreadClose(p._thread);
#elif BUILD_PORTABLE
p._task.GetAwaiter().GetResult();
#else
p._thread.Join();
#endif
Expand All @@ -40,10 +46,16 @@ internal static void Thread_Close(ref CThread p)

internal static SRes Thread_Wait(CThread p)
{
#if BUILD_PORTABLE
p._task.GetAwaiter().GetResult();
#else
p._thread.Join();
#endif

#if !DISABLE_TRACE
Trace.MatchThreadWait(p._thread);
#endif

return TSZ("Thread_Wait");
}

Expand All @@ -52,6 +64,8 @@ internal static SRes Thread_Create(out CThread p, Action func, string threadName
p = new CThread();
#if !DISABLE_TRACE
p._thread = Trace.MatchThreadStart(func);
#elif BUILD_PORTABLE
p._task = System.Threading.Tasks.Task.Run(func);
#else
p._thread = new System.Threading.Thread(delegate () { func(); });
p._thread.Name = threadName;
Expand Down Expand Up @@ -89,6 +103,8 @@ internal static void Event_Close(ref CEvent p)
{
#if !DISABLE_TRACE
Trace.MatchObjectDestroy(p, "Event_Close");
#elif BUILD_PORTABLE
p.Event.Dispose();
#else
p.Event.Close();
#endif
Expand Down Expand Up @@ -159,6 +175,8 @@ internal static void Semaphore_Close(ref CSemaphore p)
{
#if !DISABLE_TRACE
Trace.MatchObjectDestroy(p, "Semaphore_Close");
#elif BUILD_PORTABLE
p.Semaphore.Dispose();
#else
p.Semaphore.Close();
#endif
Expand Down
Loading

0 comments on commit c3e22d1

Please sign in to comment.