Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better linking with custom libzmq DLLs #147

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ZeroMQ.AcceptanceTests/ZeroMQ.AcceptanceTests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -127,7 +127,7 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>xcopy /y /c $(SolutionDir)..\lib\$(PlatformName)\libzmq.dll $(TargetDir)</PostBuildEvent>
<PostBuildEvent>xcopy /y /c $(SolutionDir)..\lib\$(PlatformName)\$(LibZmqDllName).dll $(TargetDir)</PostBuildEvent>
</PropertyGroup>
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand All @@ -137,4 +137,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
6 changes: 3 additions & 3 deletions src/ZeroMQ.Perf.LatLocal/ZeroMQ.Perf.LatLocal.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -67,7 +67,7 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>xcopy /y /c $(SolutionDir)..\lib\$(PlatformName)\libzmq.dll $(TargetDir)</PostBuildEvent>
<PostBuildEvent>xcopy /y /c $(SolutionDir)..\lib\$(PlatformName)\$(LibZmqDllName).dll $(TargetDir)</PostBuildEvent>
</PropertyGroup>
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand All @@ -77,4 +77,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
6 changes: 3 additions & 3 deletions src/ZeroMQ.SimpleTests/ZeroMQ.SimpleTests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -107,7 +107,7 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>xcopy /y /c $(SolutionDir)..\lib\$(PlatformName)\libzmq.dll $(TargetDir)</PostBuildEvent>
<PostBuildEvent>xcopy /y /c $(SolutionDir)..\lib\$(PlatformName)\$(LibZmqDllName).dll $(TargetDir)</PostBuildEvent>
</PropertyGroup>
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand All @@ -117,4 +117,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
3 changes: 2 additions & 1 deletion src/ZeroMQ/Interop/LibZmq.Mono.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ namespace ZeroMQ.Interop

internal static class LibZmq
{
public const string LibraryName = "libzmq";
// LibraryName is now declared in ZmqLibraryName.cs, which is auto-generated depending on the custom set zmq library from the project properties
//public const string LibraryName = "libzmq";

// From zmq.h (v3):
// typedef struct {unsigned char _ [32];} zmq_msg_t;
Expand Down
11 changes: 7 additions & 4 deletions src/ZeroMQ/Interop/LibZmq.NET.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ namespace ZeroMQ.Interop
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1310:FieldNamesMustNotContainUnderscore", Justification = "Compatibility with native headers.")]
[SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1201:ElementsMustAppearInTheCorrectOrder", Justification = "Compatibility with native headers.")]
[SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1202:ElementsMustBeOrderedByAccess", Justification = "Reviewed. Suppression is OK here.")]
internal static class LibZmq
internal static partial class LibZmq
{
public const string LibraryName = "libzmq";
// LibraryName is now declared in ZmqLibraryName.cs, which is auto-generated depending on the custom set zmq library from the project properties
//public const string LibraryName = "libzmq";

// From zmq.h (v3):
// typedef struct {unsigned char _ [32];} zmq_msg_t;
Expand Down Expand Up @@ -44,8 +45,10 @@ internal static class LibZmq
public static readonly long PollTimeoutRatio;

static LibZmq()
{
NativeLib = new UnmanagedLibrary(LibraryName);
{
Console.WriteLine("yooooo libraryname {0}", LibraryName);
NativeLib = new UnmanagedLibrary(LibraryName);
Console.WriteLine("successsssssss");

AssignCommonDelegates();
AssignCurrentVersion(out MajorVersion, out MinorVersion, out PatchVersion);
Expand Down
1 change: 1 addition & 0 deletions src/ZeroMQ/Interop/ZmqLibraryName.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
namespace ZeroMQ.Interop { internal partial class LibZmq { public const string LibraryName = "libzmq-v100-mt-3_2_3"; } }
271 changes: 149 additions & 122 deletions src/ZeroMQ/ZeroMQ.csproj
Original file line number Diff line number Diff line change
@@ -1,127 +1,154 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{6FFD872F-A4A4-4EFA-9B4D-4342BA6CF250}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ZeroMQ</RootNamespace>
<AssemblyName>clrzmq</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\src\</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>TRACE;DEBUG</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" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ContextOption.cs" />
<Compile Include="Devices\DeviceMode.cs" />
<Compile Include="Devices\ThreadedDeviceRunner.cs" />
<Compile Include="Devices\Device.cs" />
<Compile Include="Devices\DeviceRunner.cs" />
<Compile Include="Devices\DeviceSocketSetup.cs" />
<Compile Include="Devices\ForwarderDevice.cs" />
<Compile Include="Devices\QueueDevice.cs" />
<Compile Include="Devices\StreamerDevice.cs" />
<Compile Include="Devices\ZmqDeviceException.cs" />
<Compile Include="DuplexSocket.cs" />
<Compile Include="Devices\IDevice.cs" />
<Compile Include="ExecuteExtensions.cs" />
<Compile Include="Interop\ErrorDetails.cs" />
<Compile Include="Interop\MonitorEventData.cs" />
<Compile Include="Interop\LibZmq.Mono.cs" />
<Compile Include="Interop\Retry.cs" />
<Compile Include="Interop\Platform.Mono.cs" />
<Compile Include="Interop\Platform.NET.cs" />
<Compile Include="Interop\Platform.Unix.cs" />
<Compile Include="Interop\Platform.Windows.cs" />
<Compile Include="Interop\PollerProxy.cs" />
<Compile Include="Interop\PollEvents.cs" />
<Compile Include="Interop\PollItem.cs" />
<Compile Include="Interop\ManifestResource.cs" />
<Compile Include="Interop\SafeLibraryHandle.cs" />
<Compile Include="Interop\Tracer.cs" />
<Compile Include="Interop\UnmanagedLibrary.cs" />
<Compile Include="Interop\ZmqMsgT.cs" />
<Compile Include="Monitoring\MonitorContextExtensions.cs" />
<Compile Include="Monitoring\MonitorEvents.cs" />
<Compile Include="Monitoring\MonitorSocketExtensions.cs" />
<Compile Include="RouterBehavior.cs" />
<Compile Include="TcpKeepaliveBehaviour.cs" />
<Compile Include="ZmqMessage.cs" />
<Compile Include="Poller.cs" />
<Compile Include="SendReceiveExtensions.cs" />
<Compile Include="SocketEventArgs.cs" />
<Compile Include="SubscribeExtSocket.cs" />
<Compile Include="SubscribeSocket.cs" />
<Compile Include="Frame.cs" />
<Compile Include="Interop\ContextProxy.cs" />
<Compile Include="Interop\DisposableIntPtr.cs" />
<Compile Include="ErrorCode.cs" />
<Compile Include="Interop\ErrorProxy.cs" />
<Compile Include="Interop\LibZmq.NET.cs" />
<Compile Include="ReceiveSocket.cs" />
<Compile Include="SendSocket.cs" />
<Compile Include="SocketFlags.cs" />
<Compile Include="Interop\SocketProxy.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ProtocolType.cs" />
<Compile Include="ReceiveStatus.cs" />
<Compile Include="SendStatus.cs" />
<Compile Include="SocketOption.cs" />
<Compile Include="SocketType.cs" />
<Compile Include="ZmqContext.cs" />
<Compile Include="ZmqException.cs" />
<Compile Include="Monitoring\ZmqMonitor.cs" />
<Compile Include="Monitoring\ZmqMonitorErrorEventArgs.cs" />
<Compile Include="Monitoring\ZmqMonitorEventArgs.cs" />
<Compile Include="Monitoring\ZmqMonitorFileDescriptorEventArgs.cs" />
<Compile Include="Monitoring\ZmqMonitorIntervalEventArgs.cs" />
<Compile Include="ZmqSocket.cs" />
<Compile Include="ZmqSocketException.cs" />
<Compile Include="ZmqVersion.cs" />
<Compile Include="ZmqVersionException.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" />
<Import Project="$(SolutionDir)CustomTasks.targets" />
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{6FFD872F-A4A4-4EFA-9B4D-4342BA6CF250}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ZeroMQ</RootNamespace>
<AssemblyName>clrzmq</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\src\</SolutionDir>
<LibZmqDllName Condition="'$(LibZmqDllName)' == ''">libzmq.dll</LibZmqDllName>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</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>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
<CodeAnalysisFailOnMissingRules>false</CodeAnalysisFailOnMissingRules>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ContextOption.cs" />
<Compile Include="Devices\DeviceMode.cs" />
<Compile Include="Devices\ThreadedDeviceRunner.cs" />
<Compile Include="Devices\Device.cs" />
<Compile Include="Devices\DeviceRunner.cs" />
<Compile Include="Devices\DeviceSocketSetup.cs" />
<Compile Include="Devices\ForwarderDevice.cs" />
<Compile Include="Devices\QueueDevice.cs" />
<Compile Include="Devices\StreamerDevice.cs" />
<Compile Include="Devices\ZmqDeviceException.cs" />
<Compile Include="DuplexSocket.cs" />
<Compile Include="Devices\IDevice.cs" />
<Compile Include="ExecuteExtensions.cs" />
<Compile Include="Interop\ErrorDetails.cs" />
<Compile Include="Interop\MonitorEventData.cs" />
<Compile Include="Interop\LibZmq.Mono.cs" />
<Compile Include="Interop\Retry.cs" />
<Compile Include="Interop\Platform.Mono.cs" />
<Compile Include="Interop\Platform.NET.cs" />
<Compile Include="Interop\Platform.Unix.cs" />
<Compile Include="Interop\Platform.Windows.cs" />
<Compile Include="Interop\PollerProxy.cs" />
<Compile Include="Interop\PollEvents.cs" />
<Compile Include="Interop\PollItem.cs" />
<Compile Include="Interop\ManifestResource.cs" />
<Compile Include="Interop\SafeLibraryHandle.cs" />
<Compile Include="Interop\Tracer.cs" />
<Compile Include="Interop\UnmanagedLibrary.cs" />
<Compile Include="Interop\ZmqLibraryName.cs" />
<Compile Include="Interop\ZmqMsgT.cs" />
<Compile Include="Monitoring\MonitorContextExtensions.cs" />
<Compile Include="Monitoring\MonitorEvents.cs" />
<Compile Include="Monitoring\MonitorSocketExtensions.cs" />
<Compile Include="RouterBehavior.cs" />
<Compile Include="TcpKeepaliveBehaviour.cs" />
<Compile Include="ZmqMessage.cs" />
<Compile Include="Poller.cs" />
<Compile Include="SendReceiveExtensions.cs" />
<Compile Include="SocketEventArgs.cs" />
<Compile Include="SubscribeExtSocket.cs" />
<Compile Include="SubscribeSocket.cs" />
<Compile Include="Frame.cs" />
<Compile Include="Interop\ContextProxy.cs" />
<Compile Include="Interop\DisposableIntPtr.cs" />
<Compile Include="ErrorCode.cs" />
<Compile Include="Interop\ErrorProxy.cs" />
<Compile Include="Interop\LibZmq.NET.cs" />
<Compile Include="ReceiveSocket.cs" />
<Compile Include="SendSocket.cs" />
<Compile Include="SocketFlags.cs" />
<Compile Include="Interop\SocketProxy.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ProtocolType.cs" />
<Compile Include="ReceiveStatus.cs" />
<Compile Include="SendStatus.cs" />
<Compile Include="SocketOption.cs" />
<Compile Include="SocketType.cs" />
<Compile Include="ZmqContext.cs" />
<Compile Include="ZmqException.cs" />
<Compile Include="Monitoring\ZmqMonitor.cs" />
<Compile Include="Monitoring\ZmqMonitorErrorEventArgs.cs" />
<Compile Include="Monitoring\ZmqMonitorEventArgs.cs" />
<Compile Include="Monitoring\ZmqMonitorFileDescriptorEventArgs.cs" />
<Compile Include="Monitoring\ZmqMonitorIntervalEventArgs.cs" />
<Compile Include="ZmqSocket.cs" />
<Compile Include="ZmqSocketException.cs" />
<Compile Include="ZmqVersion.cs" />
<Compile Include="ZmqVersionException.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" />
<Import Project="$(SolutionDir)CustomTasks.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">
<FindLastDirectory Path="$(PackagesDir)" Pattern="libzmq.*">
<Output TaskParameter="Dir" PropertyName="LibzmqDir" />
</FindLastDirectory>
<ItemGroup>
<LibzmqFiles Include="$(LibzmqDir)\Content\lib\**\*" />
<LibFiles Include="@(LibzmqFiles->'$(SolutionDir)..\lib\%(RecursiveDir)%(FileName)%(Extension)')" />
</ItemGroup>
<Copy Condition="'$(UseCustomLibzmq)' != 'true'" SourceFiles="@(LibzmqFiles)" DestinationFiles="@(LibFiles)" SkipUnchangedFiles="true" />
</Target>
-->
<Target Name="AfterBuild">
<FindLastDirectory Path="$(PackagesDir)" Pattern="libzmq.*">
<Output TaskParameter="Dir" PropertyName="LibzmqDir" />
</FindLastDirectory>
<ItemGroup>
<LibzmqFiles Include="$(LibzmqDir)\Content\lib\**\*" />
<LibFiles Include="@(LibzmqFiles->'$(SolutionDir)..\lib\%(RecursiveDir)%(FileName)%(Extension)')" />
</ItemGroup>
<Copy Condition="'$(UseCustomLibzmq)' != 'true'" SourceFiles="@(LibzmqFiles)" DestinationFiles="@(LibFiles)" SkipUnchangedFiles="true" />
</Target>
<PropertyGroup>
<PreBuildEvent>ECHO namespace ZeroMQ.Interop { internal partial class LibZmq { public const string LibraryName = "$(LibZmqDllName)"; } } &gt; $(ProjectDir)Interop\ZmqLibraryName.cs</PreBuildEvent>
</PropertyGroup>
</Project>
Loading