Re: RFC; [PATCH] Add ikvm.props to the NuGet Package to Copy Native Binaries
Christopher Boumenot <[email protected]> Mon, 31 Aug 2015 21:25:30 -0700
| Newsgroups | gmane.comp.java.ikvm.devel |
|---|---|
| Message-ID | <CAOZeni6TB9uatyEWB0Ov-b=g9VKRDL1LGE5cLx=FQ_JSpw=BCg@mail.gmail.com> |
This iteration splits IKVM into two NuGet packages, and moves IKVM.Runtime.JNI.dll into the IKVM.NativeBinaries package. IKVM.NativeBinaries depends on IKVM, and is locked to the same version. The native binaries are copied to NativeBinaries/x86/lib or NativeBinaries/x64/lib; I followed the lead of libgit2sharp.NativeBinaries mostly. On Mon, Aug 31, 2015 at 9:17 AM, Christopher Boumenot <[email protected]> wrote: > Hi Jeroen, > > I like that idea better. I will work on this and send an updated > patch, and I'll move over KVM.Runtime.JNI.dll too. > > I based my first patch on a cloned git repo just to see if the idea > made sense. It does, so I'll invest in syncing from the official CVS > repository. It will take a little bit longer to get the next revision > out. > > > > Thanks, > Christopher > > On Mon, Aug 31, 2015 at 7:42 AM, Jeroen Frijters <[email protected]> wrote: >> Hi Christopher, >> >> Thanks for looking into this. Would it be an idea to split the nuget package into a pure-managed and a native package? That way the majority of users that don't need to native code won't get the native libaries. It should be possible to move IKVM.Runtime.JNI.dll into the native package as well. >> >> Thanks, >> Jeroen >> >>> -----Original Message----- >>> From: Christopher Boumenot [mailto:[email protected]] >>> Sent: Monday, August 31, 2015 8:25 >>> To: [email protected] >>> Subject: [Ikvm-developers] RFC; [PATCH] Add ikvm.props to the NuGet >>> Package to Copy Native Binaries >>> >>> I am developing a project that uses IKVM that has to access native >>> binaries. In my project I reference ikvm-native-win32-x64.dll and >>> JVM.dll in my project, but I am trying to figure out how to make this >>> easier when I ship my project as a NuGet package to end-users. I would >>> prefer if end users just install the NuGet package, and the binaries end >>> up in the build output directory. This is not true for IKVM (in the >>> case of these binaries), and instead I need to rely on the end user >>> referencing the ikvm-native-win32-x64.dll and JVM.dll or putting it in >>> their load path. One solution that I have seen (from >>> libgit2sharp.nativebinaries) is to create a props files that copies the >>> native binaries to the build output directory. This provides a well- >>> defined location for my project to load these necessary binaries without >>> the user having to take action. This also makes it easier to consume my >>> project in LINQPad without having to manually call out binaries. >>> >>> Is there a preferred solution to this problem or any ideas on how to >>> best solve it? I have attached a patch that implements the props >>> solution. Any feedback is appreciated. >>> >>> >>> >>> Thanks, >>> Christopher ------------------------------------------------------------------------------ _______________________________________________ Ikvm-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ikvm-developers
ikvm.patch
(application/octet-stream, 5.6 KB)
Index: nupkg.build
===================================================================
RCS file: /cvsroot/ikvm/ikvm/nuget/nupkg.build,v
retrieving revision 1.1
diff -u -r1.1 nupkg.build
--- nupkg.build 19 Mar 2013 10:12:46 -0000 1.1
+++ nupkg.build 1 Sep 2015 03:58:48 -0000
@@ -32,6 +32,7 @@
</fileset>
</delete>
<delete dir="Package" />
+ <delete dir="Package.NativeBinaries" />
</target>
<target name="version">
@@ -48,6 +49,16 @@
</copy>
</target>
+ <target name="IKVM.NativeBinaries.nuspec" depends="version">
+ <copy file="IKVM.NativeBinaries.nuspec.in" tofile="Package.NativeBinaries/IKVM.NativeBinaries.nuspec" overwrite="true">
+ <filterchain>
+ <replacetokens>
+ <token key="VERSION" value="${VERSION}" />
+ </replacetokens>
+ </filterchain>
+ </copy>
+ </target>
+
<target name="Package">
<copy todir="Package">
<fileset basedir="..">
@@ -56,21 +67,30 @@
<include name="TRADEMARK" />
</fileset>
</copy>
+ <copy todir="Package.NativeBinaries">
+ <fileset basedir="..">
+ <include name="LICENSE" />
+ <include name="THIRD_PARTY_README" />
+ <include name="TRADEMARK" />
+ </fileset>
+ </copy>
<copy todir="Package/lib">
<fileset basedir="../bin">
<include name="IKVM.AWT.WinForms.dll" />
<include name="IKVM.OpenJDK.*.dll" />
<include name="IKVM.Runtime.dll" />
- <include name="IKVM.Runtime.JNI.dll" />
</fileset>
</copy>
- <copy file="../bin/ikvm-native-win32-x64.dll" todir="Package/x64/lib" />
- <copy file="../bin/ikvm-native-win32-x86.dll" todir="Package/x86/lib" />
- <copy file="../bin-x64/JVM.DLL" todir="Package/x64/lib" />
- <copy file="../bin-x86/JVM.DLL" todir="Package/x86/lib" />
+ <copy file="IKVM.NativeBinaries.props" todir="Package.NativeBinaries/build" />
+ <copy file="../bin/IKVM.Runtime.JNI.dll" todir="Package.NativeBinaries/lib" />
+ <copy file="../bin/ikvm-native-win32-x64.dll" todir="Package.NativeBinaries/NativeBinaries/x64/lib" />
+ <copy file="../bin/ikvm-native-win32-x86.dll" todir="Package.NativeBinaries/NativeBinaries/x86/lib" />
+ <copy file="../bin-x64/JVM.DLL" todir="Package.NativeBinaries/NativeBinaries/x64/lib" />
+ <copy file="../bin-x86/JVM.DLL" todir="Package.NativeBinaries/NativeBinaries/x86/lib" />
</target>
- <target name="nupkg" depends="clean Package IKVM.nuspec">
+ <target name="nupkg" depends="clean Package IKVM.nuspec IKVM.NativeBinaries.nuspec">
<exec program="nuget" commandline="pack Package/IKVM.nuspec" />
+ <exec program="nuget" commandline="pack Package.NativeBinaries/IKVM.NativeBinaries.nuspec" />
</target>
</project>
--- Binaries.nuspec.in
+++ Binaries.nuspec.in
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
+ <metadata>
+ <version>@VERSION@</version>
+ <authors>Jeroen Frijters</authors>
+ <owners />
+ <licenseUrl>http://sourceforge.net/apps/mediawiki/ikvm/index.php?title=License</licenseUrl>
+ <projectUrl>http://www.ikvm.net/</projectUrl>
+ <id>IKVM.NativeBinaries</id>
+ <title>IKVM.NET</title>
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
+ <description>IKVM.NET is an implementation of Java for Mono and the Microsoft .NET Framework.</description>
+ <tags>IKVM.NET, Java, .NET</tags>
+ <releaseNotes>The release notes can be found here: http://ikvm.net/release/@VERSION@</releaseNotes>
+ <dependencies>
+ <dependency id="IKVM" version="[@VERSION@]" />
+ </dependencies>
+ </metadata>
+</package>
--- Binaries.props
+++ Binaries.props
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <None Condition="Exists('$(MSBuildThisFileDirectory)\..\NativeBinaries\x64\lib\ikvm-native-win32-x64.dll')"
+ Include="$(MSBuildThisFileDirectory)\..\NativeBinaries\x64\lib\ikvm-native-win32-x64.dll">
+ <Link>NativeBinaries\x64\lib\ikvm-native-win32-x64.dll</Link>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Condition="Exists('$(MSBuildThisFileDirectory)\..\NativeBinaries\x64\lib\JVM.dll')"
+ Include="$(MSBuildThisFileDirectory)\..\NativeBinaries\x64\lib\JVM.dll">
+ <Link>NativeBinaries\x64\lib\JVM.dll</Link>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Condition="Exists('$(MSBuildThisFileDirectory)\..\NativeBinaries\x86\lib\ikvm-native-win32-x86.dll')"
+ Include="$(MSBuildThisFileDirectory)\..\NativeBinaries\x86\lib\ikvm-native-win32-x86.dll">
+ <Link>NativeBinaries\x86\lib\ikvm-native-win32-x86.dll</Link>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ <None Condition="Exists('$(MSBuildThisFileDirectory)\..\NativeBinaries\x86\lib\JVM.dll')"
+ Include="$(MSBuildThisFileDirectory)\..\NativeBinaries\x86\lib\JVM.dll">
+ <Link>NativeBinaries\x86\lib\JVM.dll</Link>
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
+ </ItemGroup>
+</Project>