Skip to content

Commit

Permalink
Refactor of LibHelper, splitting each supported native libraries bund…
Browse files Browse the repository at this point in the history
…le into it's own assembly.
  • Loading branch information
pruiz committed Nov 13, 2013
1 parent eecfc8f commit 99e0554
Show file tree
Hide file tree
Showing 31 changed files with 817 additions and 31 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
*.suo
*/*.??proj.user
*/bin
*/obj
Packages
6 changes: 3 additions & 3 deletions .nuget/NuGet.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>

<!-- Enable the restore command to run before builds -->
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>
<RestorePackages Condition=" '$(RestorePackages)' == '' ">true</RestorePackages>

<!-- Property that enables building a package from a project -->
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>

<!-- Determines if package restore consent is required to restore packages -->
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">false</RequireRestoreConsent>

<!-- Download NuGet.exe if it does not already exist -->
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
Expand Down Expand Up @@ -147,4 +147,4 @@
</Code>
</Task>
</UsingTask>
</Project>
</Project>
Binary file added WkHtmlToXSharp.Linux32/Libs/libwkhtmltox0.so.gz
Binary file not shown.
48 changes: 48 additions & 0 deletions WkHtmlToXSharp.Linux32/Linux32NativeBundle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Reflection;

namespace WkHtmlToXSharp
{
public class Linux32NativeBundle : INativeLibraryBundle
{
private static readonly Assembly Assembly = Assembly.GetExecutingAssembly();
private static readonly string ResourcesPath = typeof(Linux32NativeBundle).Namespace + ".Libs.";

#region INativeLibraryBundle Members

public bool SupportsCurrentPlatform
{
get {
return Environment.OSVersion.Platform == PlatformID.Unix && !WkHtmlToXLibrariesManager.RunningIn64Bits;
}
}

private void DeployLibrary(WkHtmlToXLibrariesManager manager, string resource)
{
var fileName = resource.Substring(ResourcesPath.Length);

using (var stream = Assembly.GetManifestResourceStream(resource))
{
manager.DeployLibrary(stream, fileName, File.GetLastWriteTime(Assembly.Location));
}
}

public void DeployBundle(WkHtmlToXLibrariesManager manager)
{
if (manager == null) throw new ArgumentNullException("manager");

var resourcesList = Assembly.GetManifestResourceNames();

foreach (var res in resourcesList)
{
if (res.StartsWith(ResourcesPath))
DeployLibrary(manager, res);
}
}

#endregion
}
}
36 changes: 36 additions & 0 deletions WkHtmlToXSharp.Linux32/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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("WkHtmlToXSharp.Linux32")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Pablo Ruiz García")]
[assembly: AssemblyProduct("WkHtmlToXSharp")]
[assembly: AssemblyCopyright("Copyright © Pablo Ruiz García 2011~2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("44a28893-09f7-47ed-b019-21e4044730e3")]

// 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("0.0.0.0")]
[assembly: AssemblyFileVersion("0.0.0.0")]
61 changes: 61 additions & 0 deletions WkHtmlToXSharp.Linux32/WkHtmlToXSharp.Linux32.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.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>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{32C05814-398B-436A-B76D-72EDCD15F199}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WkHtmlToXSharp</RootNamespace>
<AssemblyName>WkHtmlToXSharp.Linux32</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Linux32NativeBundle.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WkHtmlToXSharp\WkHtmlToXSharp.csproj">
<Project>{3dadecbf-6d08-4090-9a1d-2064d0466381}</Project>
<Name>WkHtmlToXSharp</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Libs\libwkhtmltox0.so.gz" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.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>
4 changes: 4 additions & 0 deletions WkHtmlToXSharp.Linux32/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Common.Logging" version="2.1.2" targetFramework="net35" />
</packages>
Binary file added WkHtmlToXSharp.Linux64/Libs/libwkhtmltox0.so.gz
Binary file not shown.
48 changes: 48 additions & 0 deletions WkHtmlToXSharp.Linux64/Linux64NativeBundle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Reflection;

namespace WkHtmlToXSharp
{
public class Linux64NativeBundle : INativeLibraryBundle
{
private static readonly Assembly Assembly = Assembly.GetExecutingAssembly();
private static readonly string ResourcesPath = typeof(Linux64NativeBundle).Namespace + ".Libs.";

#region INativeLibraryBundle Members

public bool SupportsCurrentPlatform
{
get {
return Environment.OSVersion.Platform == PlatformID.Unix && WkHtmlToXLibrariesManager.RunningIn64Bits;
}
}

private void DeployLibrary(WkHtmlToXLibrariesManager manager, string resource)
{
var fileName = resource.Substring(ResourcesPath.Length);

using (var stream = Assembly.GetManifestResourceStream(resource))
{
manager.DeployLibrary(stream, fileName, File.GetLastWriteTime(Assembly.Location));
}
}

public void DeployBundle(WkHtmlToXLibrariesManager manager)
{
if (manager == null) throw new ArgumentNullException("manager");

var resourcesList = Assembly.GetManifestResourceNames();

foreach (var res in resourcesList)
{
if (res.StartsWith(ResourcesPath))
DeployLibrary(manager, res);
}
}

#endregion
}
}
36 changes: 36 additions & 0 deletions WkHtmlToXSharp.Linux64/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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("WkHtmlToXSharp.Linux64")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("WkHtmlToXSharp.Linux64")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("778b4aeb-6d60-46f5-9eaa-7ed8d4655482")]

// 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")]
61 changes: 61 additions & 0 deletions WkHtmlToXSharp.Linux64/WkHtmlToXSharp.Linux64.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.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>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{23B0D174-40F4-4BB3-A5AA-02F7E3D8A420}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WkHtmlToXSharp</RootNamespace>
<AssemblyName>WkHtmlToXSharp.Linux64</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="Linux64NativeBundle.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Libs\libwkhtmltox0.so.gz" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WkHtmlToXSharp\WkHtmlToXSharp.csproj">
<Project>{3dadecbf-6d08-4090-9a1d-2064d0466381}</Project>
<Name>WkHtmlToXSharp</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.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>
4 changes: 4 additions & 0 deletions WkHtmlToXSharp.Linux64/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Common.Logging" version="2.1.2" targetFramework="net35" />
</packages>
12 changes: 12 additions & 0 deletions WkHtmlToXSharp.Tests/WkHtmlToXSharp.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@
<Compile Include="PdfConverterTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WkHtmlToXSharp.Linux32\WkHtmlToXSharp.Linux32.csproj">
<Project>{32c05814-398b-436a-b76d-72edcd15f199}</Project>
<Name>WkHtmlToXSharp.Linux32</Name>
</ProjectReference>
<ProjectReference Include="..\WkHtmlToXSharp.Linux64\WkHtmlToXSharp.Linux64.csproj">
<Project>{23b0d174-40f4-4bb3-a5aa-02f7e3d8a420}</Project>
<Name>WkHtmlToXSharp.Linux64</Name>
</ProjectReference>
<ProjectReference Include="..\WkHtmlToXSharp.Win32\WkHtmlToXSharp.Win32.csproj">
<Project>{eff2501d-d316-40a9-9362-9f771fb6ca98}</Project>
<Name>WkHtmlToXSharp.Win32</Name>
</ProjectReference>
<ProjectReference Include="..\WkHtmlToXSharp\WkHtmlToXSharp.csproj">
<Project>{3DADECBF-6D08-4090-9A1D-2064D0466381}</Project>
<Name>WkHtmlToXSharp</Name>
Expand Down
1 change: 1 addition & 0 deletions WkHtmlToXSharp.Tests/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Common.Logging" version="2.1.2" targetFramework="net35" />
<package id="NUnit" version="2.6.3" targetFramework="net35" />
</packages>
Binary file added WkHtmlToXSharp.Win32/Libs/libeay32.dll.gz
Binary file not shown.
Binary file added WkHtmlToXSharp.Win32/Libs/libgcc_s_dw2-1.dll.gz
Binary file not shown.
Binary file added WkHtmlToXSharp.Win32/Libs/mingwm10.dll.gz
Binary file not shown.
Binary file added WkHtmlToXSharp.Win32/Libs/ssleay32.dll.gz
Binary file not shown.
Binary file added WkHtmlToXSharp.Win32/Libs/wkhtmltox0.dll.gz
Binary file not shown.
Loading

0 comments on commit 99e0554

Please sign in to comment.