From cd5adb803f4b98868bbaa28ff830d54d3c3c7693 Mon Sep 17 00:00:00 2001 From: Alexander Bezzubov Date: Wed, 17 Oct 2018 22:29:32 +0300 Subject: [PATCH 1/7] ci: remove go tip Signed-off-by: Alexander Bezzubov --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5cd010f..1bd0453 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: go go: - 1.9.x - - tip addons: apt: @@ -10,8 +9,6 @@ addons: - libonig-dev matrix: - allow_failures: - - go: tip fast_finish: true env: From a7d9b95135bb024e1c2dd06f0e31035cf45d8bc7 Mon Sep 17 00:00:00 2001 From: Alexander Bezzubov Date: Wed, 17 Oct 2018 23:55:00 +0300 Subject: [PATCH 2/7] ci: move default to 1.10 Signed-off-by: Alexander Bezzubov --- .travis.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1bd0453..b2c3d36 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: go go: - - 1.9.x + - '1.10' addons: apt: @@ -12,8 +12,11 @@ matrix: fast_finish: true env: - - ONIGURUMA=0 - - ONIGURUMA=1 + global: + - GO_VERSION='1.10' + matrix: + - ONIGURUMA=0 + - ONIGURUMA=1 install: - go version @@ -50,7 +53,7 @@ jobs: jdk: oraclejdk8 install: - - GIMME_OUTPUT=$(gimme 1.9 | tee -a $HOME/.bashrc) && eval "$GIMME_OUTPUT" + - GIMME_OUTPUT=$(gimme $GO_VERSION | tee -a $HOME/.bashrc) && eval "$GIMME_OUTPUT" - 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 @@ -118,7 +121,7 @@ jobs: jdk: oraclejdk8 install: - - GIMME_OUTPUT=$(gimme 1.9 | tee -a $HOME/.bashrc) && eval "$GIMME_OUTPUT" + - GIMME_OUTPUT=$(gimme $GO_VERSION | tee -a $HOME/.bashrc) && eval "$GIMME_OUTPUT" - 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 From f8d128eeaa838c2dc90dffebd3cdda17b4d6db68 Mon Sep 17 00:00:00 2001 From: Alexander Bezzubov Date: Thu, 18 Oct 2018 12:10:03 +0300 Subject: [PATCH 3/7] ci: force missing include for java Otherwise JNAetor enry.jar binding generation on CI using `make all` results in ``` /home/travis/build/bzz/enry/java/shared/libenry.h:8:0: error: File not found: stddef.h in . /usr/include /usr/local/include /usr/include/c++/4.8.4 /usr/include/c++/4.8.4/tr1 ``` Signed-off-by: Alexander Bezzubov --- java/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/java/Makefile b/java/Makefile index 3b8fd9e..65caa2f 100644 --- a/java/Makefile +++ b/java/Makefile @@ -18,6 +18,7 @@ $(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 \ -o $(JARS_DIR) \ -mode StandaloneJar \ -runtime JNA; From 115a7bdc64ba4516e415ea8a48b740e8b4041c5d Mon Sep 17 00:00:00 2001 From: Alexander Bezzubov Date: Sun, 21 Oct 2018 15:37:31 +0200 Subject: [PATCH 4/7] java: fix macOS binding generation `/usr/include/sys/cdefs.h:74:25: warning: #warning "Unsupported compiler detected"` is solved by by tricking cdefs.h into thinking we're gcc, similar to https://github.com/nativelibs4java/JNAerator/issues/8#issuecomment-81965369 Signed-off-by: Alexander Bezzubov --- java/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/java/Makefile b/java/Makefile index 65caa2f..993d348 100644 --- a/java/Makefile +++ b/java/Makefile @@ -19,6 +19,7 @@ $(JAR): $(RESOURCES_DIR) $(JNAERATOR_JAR) -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; From 5147de90b810918cbff11c84fd041175b71beea0 Mon Sep 17 00:00:00 2001 From: Alexander Bezzubov Date: Sun, 21 Oct 2018 15:40:25 +0200 Subject: [PATCH 5/7] java: retrofit bindings for JNA generated from Cgo 1.10 Go 1.10 improved the way of passing strings between C and Go with https://go-review.googlesource.com/c/go/+/70890 This change adapts API/helpers to a new convention, without changing existing API surface and without benefiting from a new way of passing strings. Another, perferable on my readind of `go doc cgo`, but more invasive approach would be to change ALL enry C API to always return *C.char \w C.CString() Signed-off-by: Alexander Bezzubov --- java/build.sbt | 1 + .../main/java/tech/sourced/enry/GoUtils.java | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) 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) { From 89ec551e70971e633a4383ffe9a59f870c1ed4c4 Mon Sep 17 00:00:00 2001 From: Alexander Bezzubov Date: Mon, 22 Oct 2018 16:45:47 +0200 Subject: [PATCH 6/7] ci: use go 1.10.x gimme version on TravisCI is old, 1.2 and does not support .x resulting in `I don't have any idea what to do with '1.10.x' but it works on latest master https://github.com/travis-ci/gimme#asking-gimme-what-a-version-is thus opting out in always running a latest gimme Signed-off-by: Alexander Bezzubov --- .travis.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index b2c3d36..16026ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: go go: - - '1.10' + - '1.10.x' addons: apt: @@ -13,7 +13,7 @@ matrix: env: global: - - GO_VERSION='1.10' + - GO_VERSION='1.10.x' matrix: - ONIGURUMA=0 - ONIGURUMA=1 @@ -53,7 +53,8 @@ jobs: jdk: oraclejdk8 install: - - GIMME_OUTPUT=$(gimme $GO_VERSION | 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 @@ -121,7 +122,8 @@ jobs: jdk: oraclejdk8 install: - - GIMME_OUTPUT=$(gimme $GO_VERSION | 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 From 0f6077dd94de178b8fb8652e5c7a5036490e7977 Mon Sep 17 00:00:00 2001 From: Alexander Bezzubov Date: Tue, 23 Oct 2018 13:11:09 +0200 Subject: [PATCH 7/7] ci: pin VM version Signed-off-by: Alexander Bezzubov --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 16026ee..f708c22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,7 @@ -language: go +sudo: false +dist: trusty +language: go go: - '1.10.x' @@ -53,6 +55,7 @@ jobs: jdk: oraclejdk8 install: + - 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