mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-17 04:15:10 +00:00
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.
This commit is contained in:
1 parent
5835344277
commit
437d8965e1
6 files changed
+71
-21
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
File renamed without changes.
Binary file not shown.
@@ -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 {
|
||||
/**
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
lombok_installer_WindowsDriveInfo.o
|
||||
WindowsDriveInfo.dll
|
||||
WindowsDriveInfo-x86_64.dll
|
||||
WindowsDriveInfo-i386.dll
|
||||
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user