Skip to content

Commit

Permalink
Link with lib util (fixes #896)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Dec 22, 2023
1 parent 8c9a4ab commit 687695e
Show file tree
Hide file tree
Showing 11 changed files with 159 additions and 9 deletions.
2 changes: 1 addition & 1 deletion native/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ NATIVE_DLL:=$(NATIVE_DIR)/$(LIBNAME)
# For cross-compilation, install docker. See also https://github.com/dockcross/dockcross
# Disabled linux-armv6 build because of this issue; https://github.com/dockcross/dockcross/issues/190
native-all: \
linux-x86 linux-x86_64 linux-arm linux-armv6 linux-armv7 linux-arm64 linux-ppc64 linux-riscv64 \
linux-x86 linux-x86_64 linux-arm linux-armv6 linux-armv7 linux-arm64 linux-ppc64 \
win-x86 win-x86_64 win-arm64 \
mac-x86 mac-x86_64 mac-arm64 \
freebsd-x86 freebsd-x86_64
Expand Down
16 changes: 8 additions & 8 deletions native/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -36,43 +36,43 @@ Default_LIBNAME := libjlinenative.so
Linux-x86_CC := $(CROSS_PREFIX)gcc
Linux-x86_STRIP := $(CROSS_PREFIX)strip
Linux-x86_CCFLAGS := -I$(JAVA_HOME)/include -Itarget/inc -Itarget/inc/unix -Os -fPIC -m32 -fvisibility=hidden
Linux-x86_LINKFLAGS := -shared -static-libgcc
Linux-x86_LINKFLAGS := -shared -static-libgcc -lutil
Linux-x86_LIBNAME := libjlinenative.so

Linux-x86_64_CC := $(CROSS_PREFIX)gcc
Linux-x86_64_STRIP := $(CROSS_PREFIX)strip
Linux-x86_64_CCFLAGS := -I$(JAVA_HOME)/include -Itarget/inc -Itarget/inc/unix -Os -fPIC -m64 -fvisibility=hidden
Linux-x86_64_LINKFLAGS := -shared -static-libgcc
Linux-x86_64_LINKFLAGS := -shared -static-libgcc -lutil
Linux-x86_64_LIBNAME := libjlinenative.so

Linux-arm_CC := $(CROSS_PREFIX)gcc
Linux-arm_STRIP := $(CROSS_PREFIX)strip
Linux-arm_CCFLAGS := -I$(JAVA_HOME)/include -Itarget/inc -Itarget/inc/unix -Os -fPIC -mfloat-abi=softfp -mfpu=vfp -fvisibility=hidden
Linux-arm_LINKFLAGS := -shared -static-libgcc
Linux-arm_LINKFLAGS := -shared -static-libgcc -lutil
Linux-arm_LIBNAME := libjlinenative.so

Linux-armv6_CC := $(CROSS_PREFIX)gcc
Linux-armv6_STRIP := $(CROSS_PREFIX)strip
Linux-armv6_CCFLAGS := -I$(JAVA_HOME)/include -Itarget/inc -Itarget/inc/unix -Os -mfloat-abi=hard -mfpu=vfp -fPIC -fvisibility=hidden
Linux-armv6_LINKFLAGS := -shared -static-libgcc
Linux-armv6_LINKFLAGS := -shared -static-libgcc -lutil
Linux-armv6_LIBNAME := libjlinenative.so

Linux-armv7_CC := $(CROSS_PREFIX)gcc
Linux-armv7_STRIP := $(CROSS_PREFIX)strip
Linux-armv7_CCFLAGS := -I$(JAVA_HOME)/include -Itarget/inc -Itarget/inc/unix -Os -mfloat-abi=hard -mfpu=vfp -fPIC -fvisibility=hidden
Linux-armv7_LINKFLAGS := -shared -static-libgcc
Linux-armv7_LINKFLAGS := -shared -static-libgcc -lutil
Linux-armv7_LIBNAME := libjlinenative.so

Linux-arm64_CC := $(CROSS_PREFIX)gcc
Linux-arm64_STRIP := $(CROSS_PREFIX)strip
Linux-arm64_CCFLAGS := -I$(JAVA_HOME)/include -Itarget/inc -Itarget/inc/unix -Os -march=armv8-a -fPIC -fvisibility=hidden
Linux-arm64_LINKFLAGS := -shared -static-libgcc
Linux-arm64_LINKFLAGS := -shared -static-libgcc -lutil
Linux-arm64_LIBNAME := libjlinenative.so

Linux-ppc64_CC := $(CROSS_PREFIX)gcc
Linux-ppc64_STRIP := $(CROSS_PREFIX)strip
Linux-ppc64_CCFLAGS := -I$(JAVA_HOME)/include -Itarget/inc -Itarget/inc/unix -Os -fPIC -fvisibility=hidden
Linux-ppc64_LINKFLAGS := -shared -static-libgcc
Linux-ppc64_LINKFLAGS := -shared -static-libgcc -lutil
Linux-ppc64_LIBNAME := libjlinenative.so

Linux-riscv64_CC := $(CROSS_PREFIX)gcc
Expand Down Expand Up @@ -130,7 +130,7 @@ ifeq ($(wildcard MAC_SDK),)
MAC_SDK := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
endif
Mac-x86_64_CCFLAGS := -I$(MAC_SDK)/System/Library/Frameworks/JavaVM.framework/Headers -Itarget/inc -Itarget/inc/unix -Os -fPIC -mmacosx-version-min=10.6 -fvisibility=hidden
Mac-x86_64_LINKFLAGS := -dynamiclib
Mac-x86_64_LINKFLAGS := -dynamiclib
Mac-x86_64_LIBNAME := libjlinenative.jnilib

Mac-arm64_CC := $(CROSS_PREFIX)clang -v
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,20 @@
*/
package org.jline.terminal.impl.jansi;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.nio.charset.Charset;

import org.jline.terminal.Terminal;
import org.jline.terminal.spi.SystemStream;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

public class JansiTerminalProviderTest {

Expand All @@ -19,4 +30,30 @@ public void testJansiVersion() {
assertEquals(2, JansiTerminalProvider.JANSI_MAJOR_VERSION);
assertEquals(4, JansiTerminalProvider.JANSI_MINOR_VERSION);
}

@Test
void testIsSystemStream() {
assertDoesNotThrow(() -> new JansiTerminalProvider().isSystemStream(SystemStream.Output));
}

@Test
@Disabled
void testNewTerminal() throws IOException {
PipedOutputStream pos = new PipedOutputStream();
PipedInputStream pis = new PipedInputStream(pos);
ByteArrayOutputStream baos = new ByteArrayOutputStream();

Terminal terminal = new JansiTerminalProvider()
.newTerminal(
"name",
"xterm",
pis,
baos,
Charset.defaultCharset(),
Terminal.SignalHandler.SIG_DFL,
true,
null,
null);
assertNotNull(terminal);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2002-2021, the original author(s).
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
*
* https://opensource.org/licenses/BSD-3-Clause
*/
package org.jline.terminal.impl.jna;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.nio.charset.Charset;

import org.jline.terminal.Terminal;
import org.jline.terminal.spi.SystemStream;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;

import com.sun.jna.Platform;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assumptions.assumeFalse;

public class JnaTerminalProviderTest {

@Test
void testIsSystemStream() {
assumeFalse(Platform.isMac() && Platform.is64Bit() && Platform.isARM());

assertDoesNotThrow(() -> new JnaTerminalProvider().isSystemStream(SystemStream.Output));
}

@Test
@DisabledOnOs(OS.WINDOWS)
void testNewTerminal() throws IOException {
assumeFalse(Platform.isMac() && Platform.is64Bit() && Platform.isARM());

PipedOutputStream pos = new PipedOutputStream();
PipedInputStream pis = new PipedInputStream(pos);
ByteArrayOutputStream baos = new ByteArrayOutputStream();

Terminal terminal = new JnaTerminalProvider()
.newTerminal(
"name",
"xterm",
pis,
baos,
Charset.defaultCharset(),
Terminal.SignalHandler.SIG_DFL,
true,
null,
null);
assertNotNull(terminal);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2002-2021, the original author(s).
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
*
* https://opensource.org/licenses/BSD-3-Clause
*/
package org.jline.terminal.impl.jni;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.nio.charset.Charset;

import org.jline.terminal.Terminal;
import org.jline.terminal.spi.SystemStream;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertNotNull;

public class JniTerminalProviderTest {

@Test
void testIsSystemStream() {
assertDoesNotThrow(() -> new JniTerminalProvider().isSystemStream(SystemStream.Output));
}

@Test
@DisabledOnOs(OS.WINDOWS)
void testNewTerminal() throws IOException {
PipedOutputStream pos = new PipedOutputStream();
PipedInputStream pis = new PipedInputStream(pos);
ByteArrayOutputStream baos = new ByteArrayOutputStream();

Terminal terminal = new JniTerminalProvider()
.newTerminal(
"name",
"xterm",
pis,
baos,
Charset.defaultCharset(),
Terminal.SignalHandler.SIG_DFL,
true,
null,
null);
assertNotNull(terminal);
}
}

0 comments on commit 687695e

Please sign in to comment.