Skip to content

Commit

Permalink
fix demos' native dependency: cairo(d).dll by using NativeLibraryCopi…
Browse files Browse the repository at this point in the history
…er.exe in pre-build event

set per-platform CairoSharp DllImport name
  • Loading branch information
zwcloud committed Jan 31, 2018
1 parent 80bda33 commit 1a26181
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 18 deletions.
37 changes: 21 additions & 16 deletions CairoSharp.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2026
VisualStudioVersion = 15.0.27130.2020
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "native", "native", "{5D290B69-83E1-4FF5-9218-61864989B879}"
EndProject
Expand Down Expand Up @@ -100,57 +100,62 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4AA3435B-C3E8-4231-8CFA-17FB0C20BBBD}.Debug|Any CPU.ActiveCfg = Debug|Win32
{4AA3435B-C3E8-4231-8CFA-17FB0C20BBBD}.Debug|Any CPU.ActiveCfg = Debug|x64
{4AA3435B-C3E8-4231-8CFA-17FB0C20BBBD}.Debug|Any CPU.Build.0 = Debug|x64
{4AA3435B-C3E8-4231-8CFA-17FB0C20BBBD}.Debug|x64.ActiveCfg = Debug|x64
{4AA3435B-C3E8-4231-8CFA-17FB0C20BBBD}.Debug|x64.Build.0 = Debug|x64
{4AA3435B-C3E8-4231-8CFA-17FB0C20BBBD}.Debug|x86.ActiveCfg = Debug|Win32
{4AA3435B-C3E8-4231-8CFA-17FB0C20BBBD}.Debug|x86.Build.0 = Debug|Win32
{4AA3435B-C3E8-4231-8CFA-17FB0C20BBBD}.Release|Any CPU.ActiveCfg = Release|Win32
{4AA3435B-C3E8-4231-8CFA-17FB0C20BBBD}.Release|Any CPU.Build.0 = Release|Win32
{4AA3435B-C3E8-4231-8CFA-17FB0C20BBBD}.Release|Any CPU.ActiveCfg = Release|x64
{4AA3435B-C3E8-4231-8CFA-17FB0C20BBBD}.Release|Any CPU.Build.0 = Release|x64
{4AA3435B-C3E8-4231-8CFA-17FB0C20BBBD}.Release|x64.ActiveCfg = Release|x64
{4AA3435B-C3E8-4231-8CFA-17FB0C20BBBD}.Release|x64.Build.0 = Release|x64
{4AA3435B-C3E8-4231-8CFA-17FB0C20BBBD}.Release|x86.ActiveCfg = Release|Win32
{4AA3435B-C3E8-4231-8CFA-17FB0C20BBBD}.Release|x86.Build.0 = Release|Win32
{C9B5D82C-9367-44EA-881E-65AB29969616}.Debug|Any CPU.ActiveCfg = Debug|Win32
{C9B5D82C-9367-44EA-881E-65AB29969616}.Debug|Any CPU.ActiveCfg = Debug|x64
{C9B5D82C-9367-44EA-881E-65AB29969616}.Debug|Any CPU.Build.0 = Debug|x64
{C9B5D82C-9367-44EA-881E-65AB29969616}.Debug|x64.ActiveCfg = Debug|x64
{C9B5D82C-9367-44EA-881E-65AB29969616}.Debug|x64.Build.0 = Debug|x64
{C9B5D82C-9367-44EA-881E-65AB29969616}.Debug|x86.ActiveCfg = Debug|Win32
{C9B5D82C-9367-44EA-881E-65AB29969616}.Debug|x86.Build.0 = Debug|Win32
{C9B5D82C-9367-44EA-881E-65AB29969616}.Release|Any CPU.ActiveCfg = Release|Win32
{C9B5D82C-9367-44EA-881E-65AB29969616}.Release|Any CPU.Build.0 = Release|Win32
{C9B5D82C-9367-44EA-881E-65AB29969616}.Release|Any CPU.ActiveCfg = Release|x64
{C9B5D82C-9367-44EA-881E-65AB29969616}.Release|Any CPU.Build.0 = Release|x64
{C9B5D82C-9367-44EA-881E-65AB29969616}.Release|x64.ActiveCfg = Release|x64
{C9B5D82C-9367-44EA-881E-65AB29969616}.Release|x64.Build.0 = Release|x64
{C9B5D82C-9367-44EA-881E-65AB29969616}.Release|x86.ActiveCfg = Release|Win32
{C9B5D82C-9367-44EA-881E-65AB29969616}.Release|x86.Build.0 = Release|Win32
{C0E161AA-D628-419A-9B78-E1CE2B596FAB}.Debug|Any CPU.ActiveCfg = Debug|Win32
{C0E161AA-D628-419A-9B78-E1CE2B596FAB}.Debug|Any CPU.ActiveCfg = Debug|x64
{C0E161AA-D628-419A-9B78-E1CE2B596FAB}.Debug|Any CPU.Build.0 = Debug|x64
{C0E161AA-D628-419A-9B78-E1CE2B596FAB}.Debug|x64.ActiveCfg = Debug|x64
{C0E161AA-D628-419A-9B78-E1CE2B596FAB}.Debug|x64.Build.0 = Debug|x64
{C0E161AA-D628-419A-9B78-E1CE2B596FAB}.Debug|x86.ActiveCfg = Debug|Win32
{C0E161AA-D628-419A-9B78-E1CE2B596FAB}.Debug|x86.Build.0 = Debug|Win32
{C0E161AA-D628-419A-9B78-E1CE2B596FAB}.Release|Any CPU.ActiveCfg = Release|Win32
{C0E161AA-D628-419A-9B78-E1CE2B596FAB}.Release|Any CPU.Build.0 = Release|Win32
{C0E161AA-D628-419A-9B78-E1CE2B596FAB}.Release|Any CPU.ActiveCfg = Release|x64
{C0E161AA-D628-419A-9B78-E1CE2B596FAB}.Release|Any CPU.Build.0 = Release|x64
{C0E161AA-D628-419A-9B78-E1CE2B596FAB}.Release|x64.ActiveCfg = Release|x64
{C0E161AA-D628-419A-9B78-E1CE2B596FAB}.Release|x64.Build.0 = Release|x64
{C0E161AA-D628-419A-9B78-E1CE2B596FAB}.Release|x86.ActiveCfg = Release|Win32
{C0E161AA-D628-419A-9B78-E1CE2B596FAB}.Release|x86.Build.0 = Release|Win32
{E987F1F8-5AD6-4893-8672-DF2B8A2CA9DB}.Debug|Any CPU.ActiveCfg = Debug|Win32
{E987F1F8-5AD6-4893-8672-DF2B8A2CA9DB}.Debug|Any CPU.ActiveCfg = Debug|x64
{E987F1F8-5AD6-4893-8672-DF2B8A2CA9DB}.Debug|Any CPU.Build.0 = Debug|x64
{E987F1F8-5AD6-4893-8672-DF2B8A2CA9DB}.Debug|x64.ActiveCfg = Debug|x64
{E987F1F8-5AD6-4893-8672-DF2B8A2CA9DB}.Debug|x64.Build.0 = Debug|x64
{E987F1F8-5AD6-4893-8672-DF2B8A2CA9DB}.Debug|x86.ActiveCfg = Debug|Win32
{E987F1F8-5AD6-4893-8672-DF2B8A2CA9DB}.Debug|x86.Build.0 = Debug|Win32
{E987F1F8-5AD6-4893-8672-DF2B8A2CA9DB}.Release|Any CPU.ActiveCfg = Release|Win32
{E987F1F8-5AD6-4893-8672-DF2B8A2CA9DB}.Release|Any CPU.Build.0 = Release|Win32
{E987F1F8-5AD6-4893-8672-DF2B8A2CA9DB}.Release|Any CPU.ActiveCfg = Release|x64
{E987F1F8-5AD6-4893-8672-DF2B8A2CA9DB}.Release|Any CPU.Build.0 = Release|x64
{E987F1F8-5AD6-4893-8672-DF2B8A2CA9DB}.Release|x64.ActiveCfg = Release|x64
{E987F1F8-5AD6-4893-8672-DF2B8A2CA9DB}.Release|x64.Build.0 = Release|x64
{E987F1F8-5AD6-4893-8672-DF2B8A2CA9DB}.Release|x86.ActiveCfg = Release|Win32
{E987F1F8-5AD6-4893-8672-DF2B8A2CA9DB}.Release|x86.Build.0 = Release|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Debug|Any CPU.ActiveCfg = Debug|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Debug|Any CPU.ActiveCfg = Debug|x64
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Debug|Any CPU.Build.0 = Debug|x64
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Debug|x64.ActiveCfg = Debug|x64
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Debug|x64.Build.0 = Debug|x64
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Debug|x86.ActiveCfg = Debug|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Debug|x86.Build.0 = Debug|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Release|Any CPU.ActiveCfg = Release|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Release|Any CPU.Build.0 = Release|Win32
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Release|Any CPU.ActiveCfg = Release|x64
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Release|Any CPU.Build.0 = Release|x64
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Release|x64.ActiveCfg = Release|x64
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Release|x64.Build.0 = Release|x64
{78B079BD-9FC7-4B9E-B4A6-96DA0F00248B}.Release|x86.ActiveCfg = Release|Win32
Expand Down
4 changes: 4 additions & 0 deletions demos/CairoDemo.netFull/CairoDemo.netFull.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -59,4 +60,7 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>"$(SolutionDir)source\Native\Output\NativeLibraryCopier.exe" #$(SolutionDir),$(ConfigurationName),$(PlatformName),$(TargetDir)#</PreBuildEvent>
</PropertyGroup>
</Project>
4 changes: 4 additions & 0 deletions demos/CairoDemo/CairoDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@
<ProjectReference Include="..\..\source\CairoSharp\CairoSharp.csproj" />
</ItemGroup>

<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="&quot;$(SolutionDir)source\Native\Output\NativeLibraryCopier.exe&quot; #$(SolutionDir),$(ConfigurationName),$(PlatformName),$(TargetDir)#" />
</Target>

</Project>
4 changes: 4 additions & 0 deletions demos/Windows/CairoSamples/CairoSamples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -89,6 +90,9 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>"$(SolutionDir)source\Native\Output\NativeLibraryCopier.exe" #$(SolutionDir),$(ConfigurationName),$(PlatformName),$(TargetDir)#</PreBuildEvent>
</PropertyGroup>
<!-- 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">
Expand Down
4 changes: 4 additions & 0 deletions demos/Windows/WinFormDemo/WinFormDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -84,6 +85,9 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>"$(SolutionDir)source\Native\Output\NativeLibraryCopier.exe" #$(SolutionDir),$(ConfigurationName),$(PlatformName),$(TargetDir)#</PreBuildEvent>
</PropertyGroup>
<!-- 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">
Expand Down
4 changes: 4 additions & 0 deletions demos/Windows/WpfDemo/WpfDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -107,6 +108,9 @@
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>"$(SolutionDir)source\Native\Output\NativeLibraryCopier.exe" #$(SolutionDir),$(ConfigurationName),$(PlatformName),$(TargetDir)#</PreBuildEvent>
</PropertyGroup>
<!-- 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">
Expand Down
8 changes: 6 additions & 2 deletions source/CairoSharp/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ namespace Cairo

internal static class NativeMethods
{
private const string cairo = "cairo";
#if DEBUG
private const string cairo = "cairod.dll";
#else
private const string cairo = "cairo.dll";
#endif
#if NET45
static NativeMethods()
static NativeMethods()
{
string path = Environment.GetEnvironmentVariable("PATH") ?? string.Empty;
string dllDir = System.IO.Path.GetDirectoryName(typeof(NativeMethods).Assembly.Location);
Expand Down
Binary file modified source/Native/Output/NativeLibraryCopier.exe
Binary file not shown.
3 changes: 3 additions & 0 deletions source/NativeLibraryCopier/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ static int Main()
cmdLine = cmdLine.Trim(new char[] { '#' });
var args = cmdLine.Split(new char[] { ',' });

//print args
/*
for (var i=0; i< args.Length; ++i)
{
Console.WriteLine($"args[{i}] = {args[i]}");
}
*/

if (args.Length != 4)
{
Expand Down

0 comments on commit 1a26181

Please sign in to comment.