diff options
-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 | ||||
-rw-r--r-- | winsrc/.gitignore | 2 | ||||
-rw-r--r-- | winsrc/lombok_installer_WindowsDriveInfo.c | 23 |
6 files changed, 71 insertions, 21 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 { /** diff --git a/winsrc/.gitignore b/winsrc/.gitignore index 7d929cba..3bf43ac3 100644 --- a/winsrc/.gitignore +++ b/winsrc/.gitignore @@ -1,2 +1,4 @@ lombok_installer_WindowsDriveInfo.o WindowsDriveInfo.dll +WindowsDriveInfo-x86_64.dll +WindowsDriveInfo-i386.dll diff --git a/winsrc/lombok_installer_WindowsDriveInfo.c b/winsrc/lombok_installer_WindowsDriveInfo.c index 5bccd047..dd08706a 100644 --- a/winsrc/lombok_installer_WindowsDriveInfo.c +++ b/winsrc/lombok_installer_WindowsDriveInfo.c @@ -1,4 +1,25 @@ -/* DO NOT EDIT THIS FILE - it is machine generated */ +/* + * Copyright © 2009 Reinier Zwitserloot and Roel Spilker. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + #include <jni.h> #include <windows.h> #include <stdio.h> |