diff options
author | Roel Spilker <r.spilker@gmail.com> | 2009-07-24 00:23:08 +0200 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2009-07-24 00:23:08 +0200 |
commit | 437d8965e1879a10604f8b7e9e369198973229c1 (patch) | |
tree | 68c587bdf01748dc032b18b7c0c05fde14e0b16b /src/lombok/installer | |
parent | 5835344277d10d069d792c59d67e41313d589d68 (diff) | |
download | lombok-437d8965e1879a10604f8b7e9e369198973229c1.tar.gz lombok-437d8965e1879a10604f8b7e9e369198973229c1.tar.bz2 lombok-437d8965e1879a10604f8b7e9e369198973229c1.zip |
Added WindowsDriveInfo support for 64-bit JVMs on windows. We think.
Honestly, we haven't tested it! Also updated instructions on how to
build the 64-bit version of the JVM, and generalized some of the loading
aspects of the DLL, as we now need to potentially try 2 of them.
Diffstat (limited to 'src/lombok/installer')
-rw-r--r-- | src/lombok/installer/EclipseFinder.java | 43 | ||||
-rw-r--r-- | src/lombok/installer/WindowsDriveInfo-i386.dll (renamed from src/lombok/installer/WindowsDriveInfo.dll) | bin | 14472 -> 14472 bytes | |||
-rw-r--r-- | src/lombok/installer/WindowsDriveInfo-x86_64.dll | bin | 0 -> 66806 bytes | |||
-rw-r--r-- | src/lombok/installer/WindowsDriveInfo.java | 24 |
4 files changed, 47 insertions, 20 deletions
diff --git a/src/lombok/installer/EclipseFinder.java b/src/lombok/installer/EclipseFinder.java index 5356d6fc..eabd6f04 100644 --- a/src/lombok/installer/EclipseFinder.java +++ b/src/lombok/installer/EclipseFinder.java @@ -24,7 +24,6 @@ package lombok.installer; import static java.util.Arrays.asList; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -38,6 +37,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import lombok.Lombok; +import lombok.core.Version; /** Utility class for doing various OS-specific operations related to finding Eclipse installations. */ class EclipseFinder { @@ -63,18 +63,36 @@ class EclipseFinder { } private static final AtomicBoolean windowsDriveInfoLibLoaded = new AtomicBoolean(false); - private static void loadWindowsDriveInfoLib() throws IOException, FileNotFoundException { + private static void loadWindowsDriveInfoLib() throws IOException { if ( !windowsDriveInfoLibLoaded.compareAndSet(false, true) ) return; - InputStream in = EclipseFinder.class.getResourceAsStream("WindowsDriveInfo.dll"); - File dllFile; + final String prefix = "lombok-" + Version.getVersion() + "-"; + + File temp = File.createTempFile("lombok", ".mark"); + File dll1 = new File(temp.getParentFile(), prefix + "WindowsDriveInfo-i386.dll"); + File dll2 = new File(temp.getParentFile(), prefix + "WindowsDriveInfo-x86_64.dll"); + temp.delete(); + dll1.deleteOnExit(); + dll2.deleteOnExit(); + try { + if ( unpackDLL("WindowsDriveInfo-i386.dll", dll1) ) { + System.load(dll1.getAbsolutePath()); + return; + } + } catch ( Throwable ignore ) {} + + try { + if ( unpackDLL("WindowsDriveInfo-x64_64.dll", dll1) ) { + System.load(dll2.getAbsolutePath()); + } + } catch ( Throwable ignore ) {} + } + + private static boolean unpackDLL(String dllName, File target) throws IOException { + InputStream in = EclipseFinder.class.getResourceAsStream(dllName); try { - File temp = File.createTempFile("lombok", ".mark"); - dllFile = new File(temp.getParentFile(), "lombok-WindowsDriveInfo.dll"); - temp.delete(); - dllFile.deleteOnExit(); try { - FileOutputStream out = new FileOutputStream(dllFile); + FileOutputStream out = new FileOutputStream(target); try { byte[] b = new byte[32000]; while ( true ) { @@ -86,15 +104,14 @@ class EclipseFinder { out.close(); } } catch ( IOException e ) { - if ( dllFile.exists() && dllFile.canRead() ) { - //Fall through - if there is a file named lombok-WindowsDriveInfo.dll, we'll try it. - } else throw e; + //Fall through - if there is a file named lombok-WindowsDriveInfo-arch.dll, we'll try it. + return target.exists() && target.canRead(); } } finally { in.close(); } - System.load(dllFile.getAbsolutePath()); + return true; } /** diff --git a/src/lombok/installer/WindowsDriveInfo.dll b/src/lombok/installer/WindowsDriveInfo-i386.dll Binary files differindex eb7fa49a..eb7fa49a 100644 --- a/src/lombok/installer/WindowsDriveInfo.dll +++ b/src/lombok/installer/WindowsDriveInfo-i386.dll diff --git a/src/lombok/installer/WindowsDriveInfo-x86_64.dll b/src/lombok/installer/WindowsDriveInfo-x86_64.dll Binary files differnew file mode 100644 index 00000000..0b7c9a83 --- /dev/null +++ b/src/lombok/installer/WindowsDriveInfo-x86_64.dll diff --git a/src/lombok/installer/WindowsDriveInfo.java b/src/lombok/installer/WindowsDriveInfo.java index a0cfcbc1..fd16ee6e 100644 --- a/src/lombok/installer/WindowsDriveInfo.java +++ b/src/lombok/installer/WindowsDriveInfo.java @@ -45,19 +45,29 @@ import java.util.List; * your git bash prompt's path (/etc/profile) and then run: * * $ gcc -c \ - * -I "/c/Program Files/Java/jdk1.6.0_14/include" \ - * -I "/c/Program Files/Java/jdk1.6.0_14/include/win32" \ - * -D__int64="long long" lombok_installer_WindowsDriveInfo.c + -I "/c/Program Files/Java/jdk1.6.0_14/include" \ + -I "/c/Program Files/Java/jdk1.6.0_14/include/win32" \ + -D__int64="long long" lombok_installer_WindowsDriveInfo.c * * $ dllwrap.exe --add-stdcall-alias \ - * -o WindowsDriveInfo.dll \ - * lombok_installer_WindowsDriveInfo.o + -o WindowsDriveInfo-i386.dll \ + lombok_installer_WindowsDriveInfo.o * * You may get a warning along the lines of "Creating an export definition". * This is expected behaviour. * - * The DLL produced has been checked into the git repository so you won't - * need to build this file again unless you make some changes to it. + * <p> + * Now download MinGW-w64 to build the 64-bit version of the dll (you thought you were done, weren't you?) + * from: http://sourceforge.net/projects/mingw-w64/files/ + * (under toolchains targetting Win64 / Release for GCC 4.4.0 (or later) / the version for your OS.) + * + * Then, do this all over again, but this time with the x86_64-w64-mingw32-gcc and + * x86_64-w64-mingw32-dllwrap versions that are part of the MinGW-w64 distribution. + * Name the dll 'WindowsDriveInfo-x86_64.dll'. + * + * Both the 32-bit and 64-bit DLLs that this produces have been checked into the git repository + * under src/lombok/installer so you won't need to build them again unless you make some changes to + * the code in the winsrc directory. */ public class WindowsDriveInfo { /** |