- Tweaked build for linux.
- Tweaked how errno is sent back to Java land.
This commit is contained in:
@@ -20,7 +20,12 @@ libraries {
|
|||||||
main {
|
main {
|
||||||
spec {
|
spec {
|
||||||
includes([nativeHeadersDir])
|
includes([nativeHeadersDir])
|
||||||
includes(['/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/'])
|
if (org.gradle.internal.os.OperatingSystem.current().macOsX) {
|
||||||
|
includes(['/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/'])
|
||||||
|
} else {
|
||||||
|
includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include"])
|
||||||
|
includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include/linux"])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,4 +6,4 @@ Provides Java bindings for various native APIs.
|
|||||||
* Determine if stdout/stderr are attached to a terminal.
|
* Determine if stdout/stderr are attached to a terminal.
|
||||||
* Query the terminal size.
|
* Query the terminal size.
|
||||||
|
|
||||||
Currently only ported to OS X.
|
Currently only ported to OS X (10.7.4) and Linux (Ubuntu 12.04).
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
void markFailed(JNIEnv *env, jobject result) {
|
void markFailed(JNIEnv *env, jobject result) {
|
||||||
jclass destClass = env->GetObjectClass(result);
|
jclass destClass = env->GetObjectClass(result);
|
||||||
jfieldID errnoField = env->GetFieldID(destClass, "errno", "I");
|
jmethodID method = env->GetMethodID(destClass, "failed", "(I)V");
|
||||||
env->SetIntField(result, errnoField, errno);
|
env->CallVoidMethod(result, method, errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
|
|||||||
@@ -17,7 +17,11 @@ public class Platform {
|
|||||||
if (!loaded) {
|
if (!loaded) {
|
||||||
System.setProperty("java.library.path", new File("build/binaries").getAbsolutePath());
|
System.setProperty("java.library.path", new File("build/binaries").getAbsolutePath());
|
||||||
try {
|
try {
|
||||||
System.load(new File("build/binaries/libnative-platform.dylib").getCanonicalPath());
|
File libFile = new File("build/binaries/libnative-platform.dylib");
|
||||||
|
if (!libFile.isFile()) {
|
||||||
|
libFile = new File("build/binaries/libnative-platform.so");
|
||||||
|
}
|
||||||
|
System.load(libFile.getCanonicalPath());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ package net.rubygrapefruit.platform.internal;
|
|||||||
public class FunctionResult {
|
public class FunctionResult {
|
||||||
int errno;
|
int errno;
|
||||||
|
|
||||||
|
void failed(int errno) {
|
||||||
|
this.errno = errno;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isFailed() {
|
public boolean isFailed() {
|
||||||
return errno != 0;
|
return errno != 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ class TerminalTest extends Specification {
|
|||||||
!terminal.isTerminal(Terminal.Output.Stderr);
|
!terminal.isTerminal(Terminal.Output.Stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
def "cannot detemine terminal size from a test"() {
|
def "cannot determine terminal size from a test"() {
|
||||||
when:
|
when:
|
||||||
terminal.getTerminalSize(Terminal.Output.Stdout)
|
terminal.getTerminalSize(Terminal.Output.Stdout)
|
||||||
|
|
||||||
then:
|
then:
|
||||||
NativeException e = thrown()
|
NativeException e = thrown()
|
||||||
e.message == 'Could not get terminal size. Errno is 25.'
|
e.message.startsWith('Could not get terminal size. Errno is ')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user