- Tweaked build for linux.
- Tweaked how errno is sent back to Java land.
This commit is contained in:
@@ -20,7 +20,12 @@ libraries {
|
||||
main {
|
||||
spec {
|
||||
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.
|
||||
* 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) {
|
||||
jclass destClass = env->GetObjectClass(result);
|
||||
jfieldID errnoField = env->GetFieldID(destClass, "errno", "I");
|
||||
env->SetIntField(result, errnoField, errno);
|
||||
jmethodID method = env->GetMethodID(destClass, "failed", "(I)V");
|
||||
env->CallVoidMethod(result, method, errno);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
|
||||
@@ -17,7 +17,11 @@ public class Platform {
|
||||
if (!loaded) {
|
||||
System.setProperty("java.library.path", new File("build/binaries").getAbsolutePath());
|
||||
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) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,10 @@ package net.rubygrapefruit.platform.internal;
|
||||
public class FunctionResult {
|
||||
int errno;
|
||||
|
||||
void failed(int errno) {
|
||||
this.errno = errno;
|
||||
}
|
||||
|
||||
public boolean isFailed() {
|
||||
return errno != 0;
|
||||
}
|
||||
|
||||
@@ -14,12 +14,12 @@ class TerminalTest extends Specification {
|
||||
!terminal.isTerminal(Terminal.Output.Stderr);
|
||||
}
|
||||
|
||||
def "cannot detemine terminal size from a test"() {
|
||||
def "cannot determine terminal size from a test"() {
|
||||
when:
|
||||
terminal.getTerminalSize(Terminal.Output.Stdout)
|
||||
|
||||
then:
|
||||
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