diff --git a/.travis.yml b/.travis.yml index 5cd010f..f708c22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,9 @@ -language: go +sudo: false +dist: trusty +language: go go: - - 1.9.x - - tip + - '1.10.x' addons: apt: @@ -10,13 +11,14 @@ addons: - libonig-dev matrix: - allow_failures: - - go: tip fast_finish: true env: - - ONIGURUMA=0 - - ONIGURUMA=1 + global: + - GO_VERSION='1.10.x' + matrix: + - ONIGURUMA=0 + - ONIGURUMA=1 install: - go version @@ -53,7 +55,9 @@ jobs: jdk: oraclejdk8 install: - - GIMME_OUTPUT=$(gimme 1.9 | tee -a $HOME/.bashrc) && eval "$GIMME_OUTPUT" + - gimme version + - eval "$(curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | GIMME_GO_VERSION=$GO_VERSION bash)" + - go version - export GOPATH=$HOME/gopath - mkdir -p $GOPATH/src/gopkg.in/src-d/enry.v1 - rsync -az ${TRAVIS_BUILD_DIR}/ $GOPATH/src/gopkg.in/src-d/enry.v1 @@ -121,7 +125,8 @@ jobs: jdk: oraclejdk8 install: - - GIMME_OUTPUT=$(gimme 1.9 | tee -a $HOME/.bashrc) && eval "$GIMME_OUTPUT" + - eval "$(curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | GIMME_GO_VERSION=$GO_VERSION bash)" + - go version - export GOPATH=$HOME/gopath - mkdir -p $GOPATH/src/gopkg.in/src-d/enry.v1 - rsync -az ${TRAVIS_BUILD_DIR}/ $GOPATH/src/gopkg.in/src-d/enry.v1 diff --git a/java/Makefile b/java/Makefile index 3b8fd9e..993d348 100644 --- a/java/Makefile +++ b/java/Makefile @@ -18,6 +18,8 @@ $(JAR): $(RESOURCES_DIR) $(JNAERATOR_JAR) -package tech.sourced.enry.nativelib \ -library enry \ $(HEADER_FILE) \ + -I/usr/lib/gcc/x86_64-linux-gnu/4.8/include \ + -D__GNUC__=4 \ -o $(JARS_DIR) \ -mode StandaloneJar \ -runtime JNA; diff --git a/java/build.sbt b/java/build.sbt index b93d032..201a451 100644 --- a/java/build.sbt +++ b/java/build.sbt @@ -35,6 +35,7 @@ pgpSecretRing := baseDirectory.value / "project" / ".gnupg" / "secring.gpg" pgpPublicRing := baseDirectory.value / "project" / ".gnupg" / "pubring.gpg" pgpPassphrase := Some(SONATYPE_PASSPHRASE.toArray) +libraryDependencies += "com.nativelibs4java" % "jnaerator-runtime" % "0.12" libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test unmanagedBase := baseDirectory.value / "lib" diff --git a/java/src/main/java/tech/sourced/enry/GoUtils.java b/java/src/main/java/tech/sourced/enry/GoUtils.java index 4168aca..54d66d4 100644 --- a/java/src/main/java/tech/sourced/enry/GoUtils.java +++ b/java/src/main/java/tech/sourced/enry/GoUtils.java @@ -3,13 +3,14 @@ package tech.sourced.enry; import com.sun.jna.Memory; import com.sun.jna.Pointer; import tech.sourced.enry.nativelib.GoSlice; -import tech.sourced.enry.nativelib.GoString; +import tech.sourced.enry.nativelib._GoString_; +import com.ochafik.lang.jnaerator.runtime.NativeSize; import java.io.UnsupportedEncodingException; class GoUtils { - static GoString.ByValue toGoString(String str) { + static _GoString_.ByValue toGoString(String str) { byte[] bytes; try { bytes = str.getBytes("utf-8"); @@ -26,19 +27,19 @@ class GoUtils { ptr = ptrFromBytes(bytes); } - GoString.ByValue val = new GoString.ByValue(); - val.n = length; + _GoString_.ByValue val = new _GoString_.ByValue(); + val.n = new NativeSize(length); val.p = ptr; return val; } - static String toJavaString(GoString str) { - if (str.n == 0) { + static String toJavaString(_GoString_ str) { + if (str.n.intValue() == 0) { return ""; } - byte[] bytes = new byte[(int) str.n]; - str.p.read(0, bytes, 0, (int) str.n); + byte[] bytes = new byte[(int) str.n.intValue()]; + str.p.read(0, bytes, 0, (int) str.n.intValue()); try { return new String(bytes, "utf-8"); } catch (UnsupportedEncodingException e) {