aboutsummaryrefslogtreecommitdiff
path: root/comms/java-simple-serial-connector
diff options
context:
space:
mode:
authorBoris Samorodov <bsam@FreeBSD.org>2016-10-25 19:37:33 +0000
committerBoris Samorodov <bsam@FreeBSD.org>2016-10-25 19:37:33 +0000
commit658f5275a539aae2fb0109cee852989d7f3e4b59 (patch)
tree10644197da465922eb5b6b04effcda349a087c00 /comms/java-simple-serial-connector
parent010f3fdb7635f726019c2d9f577b9b79213a49bb (diff)
downloadports-658f5275a539aae2fb0109cee852989d7f3e4b59.tar.gz
ports-658f5275a539aae2fb0109cee852989d7f3e4b59.zip
Library for working with serial ports in Java.
WWW: https://github.com/scream3r/java-simple-serial-connector PR: 213758 Submitted by: bsdports@kyle-evans.net
Notes
Notes: svn path=/head/; revision=424647
Diffstat (limited to 'comms/java-simple-serial-connector')
-rw-r--r--comms/java-simple-serial-connector/Makefile45
-rw-r--r--comms/java-simple-serial-connector/distinfo3
-rw-r--r--comms/java-simple-serial-connector/files/build.xml.in25
-rw-r--r--comms/java-simple-serial-connector/files/patch-src_cpp___nix__based_jssc.cpp11
-rw-r--r--comms/java-simple-serial-connector/files/patch-src_cpp_jssc__SerialNativeInterface.h11
-rw-r--r--comms/java-simple-serial-connector/files/patch-src_java_jssc_SerialNativeInterface.java62
-rw-r--r--comms/java-simple-serial-connector/files/patch-src_java_jssc_SerialPort.java32
-rw-r--r--comms/java-simple-serial-connector/files/patch-src_java_jssc_SerialPortList.java14
-rw-r--r--comms/java-simple-serial-connector/pkg-descr3
9 files changed, 206 insertions, 0 deletions
diff --git a/comms/java-simple-serial-connector/Makefile b/comms/java-simple-serial-connector/Makefile
new file mode 100644
index 000000000000..cefd777580d6
--- /dev/null
+++ b/comms/java-simple-serial-connector/Makefile
@@ -0,0 +1,45 @@
+# $FreeBSD$
+
+PORTNAME= java-simple-serial-connector
+PORTVERSION= 2.8.0
+DISTVERSIONPREFIX= v
+CATEGORIES= comms java
+
+MAINTAINER= bsdports@kyle-evans.net
+COMMENT= Library for working with serial ports from Java
+
+LICENSE= LGPL3
+
+USE_GITHUB= yes
+GH_ACCOUNT= scream3r
+
+MAJOR_MINOR= ${PORTVERSION:C/(.*)\.[0-9]*/\\1/}
+USE_JAVA= yes
+USE_ANT= yes
+ALL_TARGET= dist
+CXXFLAGS+= -I${JAVA_HOME}/include -I${JAVA_HOME}/include/freebsd
+WRKSRC_LIBS= ${WRKSRC}/src/java/libs
+
+PLIST_FILES= ${JAVA_HOME}/jre/lib/ext/jssc-${PORTVERSION}.jar
+
+.include <bsd.port.pre.mk>
+
+.if ${ARCH} == "armv6" || ${ARCH} == "aarch64"
+ARCH= arm
+.endif
+
+post-extract:
+ @${CP} ${FILESDIR}/build.xml.in ${WRKSRC}/build.xml
+ @${REINPLACE_CMD} -e 's|%%PORTVERSION%%|${PORTVERSION}|' ${WRKSRC}/build.xml
+
+pre-build:
+ ${RM} -r ${WRKSRC_LIBS}/*
+ ${MKDIR} ${WRKSRC_LIBS}/freebsd
+ (cd ${WRKSRC}/src/cpp/_nix_based && ${CXX} ${CXXFLAGS} ${CPPFLAGS} -shared -fPIC -o ${WRKSRC_LIBS}/freebsd/libjSSC-${MAJOR_MINOR}_${ARCH}.so jssc.cpp)
+ ${STRIP_CMD} ${WRKSRC_LIBS}/freebsd/libjSSC-${MAJOR_MINOR}_${ARCH}.so
+
+do-install:
+ @${MKDIR} ${STAGEDIR}${JAVA_HOME}/jre/lib/ext
+ ${CP} ${WRKSRC}/build/jssc-${PORTVERSION}.jar ${STAGEDIR}${JAVA_HOME}/jre/lib/ext
+
+.include <bsd.port.post.mk>
diff --git a/comms/java-simple-serial-connector/distinfo b/comms/java-simple-serial-connector/distinfo
new file mode 100644
index 000000000000..fe66340a465c
--- /dev/null
+++ b/comms/java-simple-serial-connector/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1477335330
+SHA256 (scream3r-java-simple-serial-connector-v2.8.0_GH0.tar.gz) = c3287bfc31ea81929739271b087b833fb7050686af6a90ec953c5b2f41b4d42d
+SIZE (scream3r-java-simple-serial-connector-v2.8.0_GH0.tar.gz) = 149937
diff --git a/comms/java-simple-serial-connector/files/build.xml.in b/comms/java-simple-serial-connector/files/build.xml.in
new file mode 100644
index 000000000000..da8c2facf368
--- /dev/null
+++ b/comms/java-simple-serial-connector/files/build.xml.in
@@ -0,0 +1,25 @@
+<project name="JSSC" basedir=".">
+ <property name="src" location="src/java" />
+ <property name="build" location="build" />
+ <property name="libs" location="${src}/libs" />
+ <property name="libsto" location="${build}/libs" />
+ <property name="dist" location="dist" />
+
+ <target name="init">
+ <tstamp />
+ <mkdir dir="${build}" />
+ </target>
+
+ <target name="compile" depends="init" description="Compile JSSC">
+ <javac srcdir="${src}" destdir="${build}" encoding="UTF-8" />
+ <copy todir="${libsto}">
+ <fileset dir="${libs}" />
+ </copy>
+ </target>
+
+ <target name="dist" depends="compile" description="Build distributable">
+ <jar destfile="${build}/jssc-%%PORTVERSION%%.jar">
+ <fileset dir="${build}" />
+ </jar>
+ </target>
+</project>
diff --git a/comms/java-simple-serial-connector/files/patch-src_cpp___nix__based_jssc.cpp b/comms/java-simple-serial-connector/files/patch-src_cpp___nix__based_jssc.cpp
new file mode 100644
index 000000000000..fe42d023c863
--- /dev/null
+++ b/comms/java-simple-serial-connector/files/patch-src_cpp___nix__based_jssc.cpp
@@ -0,0 +1,11 @@
+--- src/cpp/_nix_based/jssc.cpp.orig 2016-10-24 19:48:41 UTC
++++ src/cpp/_nix_based/jssc.cpp
+@@ -545,7 +545,7 @@ JNIEXPORT jbyteArray JNICALL Java_jssc_S
+ FD_CLR(portHandle, &read_fd_set);
+ jbyteArray returnArray = env->NewByteArray(byteCount);
+ env->SetByteArrayRegion(returnArray, 0, byteCount, lpBuffer);
+- delete lpBuffer;
++ delete[] lpBuffer;
+ return returnArray;
+ }
+
diff --git a/comms/java-simple-serial-connector/files/patch-src_cpp_jssc__SerialNativeInterface.h b/comms/java-simple-serial-connector/files/patch-src_cpp_jssc__SerialNativeInterface.h
new file mode 100644
index 000000000000..a8d47509d322
--- /dev/null
+++ b/comms/java-simple-serial-connector/files/patch-src_cpp_jssc__SerialNativeInterface.h
@@ -0,0 +1,11 @@
+--- src/cpp/jssc_SerialNativeInterface.h.orig 2016-10-24 19:47:55 UTC
++++ src/cpp/jssc_SerialNativeInterface.h
+@@ -43,6 +43,8 @@ extern "C" {
+ #define jssc_SerialNativeInterface_OS_SOLARIS 2L
+ #undef jssc_SerialNativeInterface_OS_MAC_OS_X
+ #define jssc_SerialNativeInterface_OS_MAC_OS_X 3L
++#undef jssc_SerialNativeInterface_OS_FREEBSD
++#define jssc_SerialNativeInterface_OS_FREEBSD 4L
+ #undef jssc_SerialNativeInterface_ERR_PORT_BUSY
+ #define jssc_SerialNativeInterface_ERR_PORT_BUSY -1LL
+ #undef jssc_SerialNativeInterface_ERR_PORT_NOT_FOUND
diff --git a/comms/java-simple-serial-connector/files/patch-src_java_jssc_SerialNativeInterface.java b/comms/java-simple-serial-connector/files/patch-src_java_jssc_SerialNativeInterface.java
new file mode 100644
index 000000000000..fadcacf8c820
--- /dev/null
+++ b/comms/java-simple-serial-connector/files/patch-src_java_jssc_SerialNativeInterface.java
@@ -0,0 +1,62 @@
+--- src/java/jssc/SerialNativeInterface.java.orig 2014-01-24 14:34:02 UTC
++++ src/java/jssc/SerialNativeInterface.java
+@@ -43,6 +43,7 @@ public class SerialNativeInterface {
+ public static final int OS_WINDOWS = 1;
+ public static final int OS_SOLARIS = 2;//since 0.9.0
+ public static final int OS_MAC_OS_X = 3;//since 0.9.0
++ public static final int OS_FREEBSD = 4;
+
+ private static int osType = -1;
+
+@@ -108,36 +109,16 @@ public class SerialNativeInterface {
+ osName = "mac_os_x";
+ osType = OS_MAC_OS_X;
+ }//<- since 0.9.0
++ else if(osName.equals("FreeBSD")){
++ osName = "freebsd";
++ osType = OS_FREEBSD;
++ }
+
+ if(architecture.equals("i386") || architecture.equals("i686")){
+- architecture = "x86";
++ architecture = "i386";
+ }
+ else if(architecture.equals("amd64") || architecture.equals("universal")){//os.arch "universal" since 2.6.0
+- architecture = "x86_64";
+- }
+- else if(architecture.equals("arm")) {//since 2.1.0
+- String floatStr = "sf";
+- if(javaLibPath.toLowerCase().contains("gnueabihf") || javaLibPath.toLowerCase().contains("armhf")){
+- floatStr = "hf";
+- }
+- else {
+- try {
+- Process readelfProcess = Runtime.getRuntime().exec("readelf -A /proc/self/exe");
+- BufferedReader reader = new BufferedReader(new InputStreamReader(readelfProcess.getInputStream()));
+- String buffer = "";
+- while((buffer = reader.readLine()) != null && !buffer.isEmpty()){
+- if(buffer.toLowerCase().contains("Tag_ABI_VFP_args".toLowerCase())){
+- floatStr = "hf";
+- break;
+- }
+- }
+- reader.close();
+- }
+- catch (Exception ex) {
+- //Do nothing
+- }
+- }
+- architecture = "arm" + floatStr;
++ architecture = "amd64";
+ }
+
+ libFolderPath = libRootFolder + fileSeparator + ".jssc" + fileSeparator + osName;
+@@ -259,7 +240,7 @@ public class SerialNativeInterface {
+ }
+
+ /**
+- * Get OS type (OS_LINUX || OS_WINDOWS || OS_SOLARIS)
++ * Get OS type (OS_LINUX || OS_WINDOWS || OS_SOLARIS || OS_FREEBSD)
+ *
+ * @since 0.8
+ */
diff --git a/comms/java-simple-serial-connector/files/patch-src_java_jssc_SerialPort.java b/comms/java-simple-serial-connector/files/patch-src_java_jssc_SerialPort.java
new file mode 100644
index 000000000000..136f195d9577
--- /dev/null
+++ b/comms/java-simple-serial-connector/files/patch-src_java_jssc_SerialPort.java
@@ -0,0 +1,32 @@
+--- src/java/jssc/SerialPort.java.orig 2016-10-24 19:44:26 UTC
++++ src/java/jssc/SerialPort.java
+@@ -264,7 +264,8 @@ public class SerialPort {
+ checkPortOpened("setEventsMask()");
+ if(SerialNativeInterface.getOsType() == SerialNativeInterface.OS_LINUX ||
+ SerialNativeInterface.getOsType() == SerialNativeInterface.OS_SOLARIS ||
+- SerialNativeInterface.getOsType() == SerialNativeInterface.OS_MAC_OS_X){//since 0.9.0
++ SerialNativeInterface.getOsType() == SerialNativeInterface.OS_MAC_OS_X ||
++ SerialNativeInterface.getOsType() == SerialNativeInterface.OS_FREEBSD){//since 0.9.0
+ linuxMask = mask;
+ if(mask > 0){
+ maskAssigned = true;
+@@ -298,7 +299,8 @@ public class SerialPort {
+ checkPortOpened("getEventsMask()");
+ if(SerialNativeInterface.getOsType() == SerialNativeInterface.OS_LINUX ||
+ SerialNativeInterface.getOsType() == SerialNativeInterface.OS_SOLARIS ||
+- SerialNativeInterface.getOsType() == SerialNativeInterface.OS_MAC_OS_X){//since 0.9.0
++ SerialNativeInterface.getOsType() == SerialNativeInterface.OS_MAC_OS_X ||
++ SerialNativeInterface.getOsType() == SerialNativeInterface.OS_FREEBSD){//since 0.9.0
+ return linuxMask;
+ }
+ return serialInterface.getEventsMask(portHandle);
+@@ -1041,7 +1043,8 @@ public class SerialPort {
+ private EventThread getNewEventThread() {
+ if(SerialNativeInterface.getOsType() == SerialNativeInterface.OS_LINUX ||
+ SerialNativeInterface.getOsType() == SerialNativeInterface.OS_SOLARIS ||
+- SerialNativeInterface.getOsType() == SerialNativeInterface.OS_MAC_OS_X){//since 0.9.0
++ SerialNativeInterface.getOsType() == SerialNativeInterface.OS_MAC_OS_X ||
++ SerialNativeInterface.getOsType() == SerialNativeInterface.OS_FREEBSD){//since 0.9.0
+ return new LinuxEventThread();
+ }
+ return new EventThread();
diff --git a/comms/java-simple-serial-connector/files/patch-src_java_jssc_SerialPortList.java b/comms/java-simple-serial-connector/files/patch-src_java_jssc_SerialPortList.java
new file mode 100644
index 000000000000..8e43754c1f69
--- /dev/null
+++ b/comms/java-simple-serial-connector/files/patch-src_java_jssc_SerialPortList.java
@@ -0,0 +1,14 @@
+--- src/java/jssc/SerialPortList.java.orig 2016-10-24 19:46:27 UTC
++++ src/java/jssc/SerialPortList.java
+@@ -57,6 +57,11 @@ public class SerialPortList {
+ PORTNAMES_PATH = "/dev/";
+ break;
+ }
++ case SerialNativeInterface.OS_FREEBSD: {
++ PORTNAMES_REGEXP = Pattern.compile("cuaU[0-9]{1,3}");
++ PORTNAMES_PATH = "/dev/";
++ break;
++ }
+ case SerialNativeInterface.OS_WINDOWS: {
+ PORTNAMES_REGEXP = Pattern.compile("");
+ PORTNAMES_PATH = "";
diff --git a/comms/java-simple-serial-connector/pkg-descr b/comms/java-simple-serial-connector/pkg-descr
new file mode 100644
index 000000000000..863b0643822f
--- /dev/null
+++ b/comms/java-simple-serial-connector/pkg-descr
@@ -0,0 +1,3 @@
+Library for working with serial ports in Java.
+
+WWW: https://github.com/scream3r/java-simple-serial-connector