-
Notifications
You must be signed in to change notification settings - Fork 8
Migrate to SDK.v3 - protocol.v2 with decode #84
Changes from 12 commits
a48d373
fcc5112
80a7a9e
d7cd8f0
8f249f7
5761a11
198ee00
2c05d07
7c9d362
26bd96a
b12b1ab
cbb1b3e
f023d7c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
BasedOnStyle: Google | ||
AllowShortIfStatementsOnASingleLine: true | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,66 @@ | ||
dist: trusty | ||
sudo: false | ||
|
||
language: scala | ||
services: | ||
- docker | ||
|
||
jdk: | ||
- openjdk8 | ||
|
||
scala: | ||
- 2.11.11 | ||
|
||
services: | ||
- docker | ||
|
||
cache: | ||
directories: | ||
- $HOME/.ivy2 | ||
- $HOME/.sbt | ||
|
||
stages: | ||
- name: test | ||
- name: release | ||
if: tag IS present | ||
|
||
before_install: | ||
- docker run --privileged -d -p 9432:9432 --name bblfsh bblfsh/bblfshd | ||
- docker exec -it bblfsh bblfshctl driver install --recommended | ||
- sudo apt-get update | ||
- sudo apt-get install -y --no-install-recommends clang g++ gcc gcc-multilib libc6-dev libc6-dev-i386 mingw-w64 patch xz-utils libxml2-dev | ||
|
||
env: | ||
global: | ||
- OSXCROSS_PATH="$HOME/osxcross" | ||
- OSXCROSS_REV=3034f7149716d815bc473d0a7b35d17e4cf175aa | ||
- SDK_VERSION=10.11 | ||
- DARWIN_VERSION=15 | ||
- OSX_VERSION_MIN=10.6 | ||
- OSXCROSS_SDK_URL="https://s3.dockerproject.org/darwin/v2/MacOSX10.11.sdk.tar.xz" | ||
|
||
install: | ||
- mkdir -p /tmp/osxcross | ||
- cd /tmp/osxcross | ||
- curl -sSL "https://codeload.github.com/tpoechtrager/osxcross/tar.gz/${OSXCROSS_REV}" | tar -C /tmp/osxcross --strip=1 -xzf - | ||
- curl -s -S -L -o tarballs/MacOSX${SDK_VERSION}.sdk.tar.xz ${OSXCROSS_SDK_URL} | ||
- UNATTENDED=yes ./build.sh >/dev/null | ||
- mv target "${OSXCROSS_PATH}" | ||
- curl -S -L "https://github.com/karalabe/xgo/blob/647f256c447ee20f9bf13ebc42e612d55994a383/docker/base/patch.tar.xz?raw=true" | xz -dc - | tar -xf - | ||
- mv v1 "${OSXCROSS_PATH}/SDK/MacOSX${SDK_VERSION}.sdk/usr/include/c++/v1" | ||
- rm -rf /tmp/osxcross "${OSXCROSS_PATH}/SDK/MacOSX${SDK_VERSION}.sdk/usr/share/man" | ||
jobs: | ||
include: | ||
- name: 'All tests' | ||
stage: test | ||
if: tag IS present # TODO(bzz): enable on PRs as soon as migrated to V2 | ||
install: &test_setup_anchor | ||
- docker run --privileged -d -p 9432:9432 --name bblfsh bblfsh/bblfshd | ||
- docker exec -it bblfsh bblfshctl driver install --recommended | ||
- sudo apt-get update | ||
- sudo apt-get install -y --no-install-recommends clang g++ gcc gcc-multilib libc6-dev libc6-dev-i386 mingw-w64 patch xz-utils | ||
script: | ||
- ./sbt assembly test | ||
after_failure: &failure_logs_anchor | ||
- docker logs bblfsh | ||
|
||
script: | ||
- cd $TRAVIS_BUILD_DIR | ||
- ./sbt assembly test | ||
- if [[ -z "$TRAVIS_TAG" ]]; then echo "Skipping this build for non-tag builds."; exit 0; fi | ||
- ./sbt publishLocal | ||
- openssl aes-256-cbc -K $encrypted_97aef7f4ae04_key -iv $encrypted_97aef7f4ae04_iv -in key.asc.enc -out key.asc -d | ||
- gpg --no-default-keyring --primary-keyring ./project/.gnupg/pubring.gpg --secret-keyring ./project/.gnupg/secring.gpg --keyring ./project/.gnupg/pubring.gpg --fingerprint --import key.asc | ||
- ./sbt publishSigned | ||
- ./sbt sonatypeRelease | ||
- name: 'V2: passing tests' # TODO(#83): remove, after both tests sets converge | ||
install: *test_setup_anchor | ||
script: | ||
- sudo apt-get install -y binutils | ||
- ./sbt assembly | ||
- ./sbt "testOnly *Close* *ClientVersion* *SupportedLanguages*" | ||
- ./sbt "testOnly org.bblfsh.client.v2.BblfshClientParseTest -- -z \"Decoded UAST after parsing\"" | ||
- ./sbt "testOnly org.bblfsh.client.v2.BblfshClientParseTest -- -z \"Decoded UAST RootNode\"" | ||
after_failure: *failure_logs_anchor | ||
|
||
after_failure: | ||
- docker logs bblfsh | ||
- name: 'Cross-compile, release & publish to Sonatype' | ||
bzz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
stage: release | ||
before_install: | ||
- mkdir -p /tmp/osxcross | ||
- cd /tmp/osxcross | ||
- curl -sSL "https://codeload.github.com/tpoechtrager/osxcross/tar.gz/${OSXCROSS_REV}" | tar -C /tmp/osxcross --strip=1 -xzf - | ||
- curl -s -S -L -o tarballs/MacOSX${SDK_VERSION}.sdk.tar.xz ${OSXCROSS_SDK_URL} | ||
- UNATTENDED=yes ./build.sh >/dev/null | ||
- mv target "${OSXCROSS_PATH}" | ||
- curl -S -L "https://github.com/karalabe/xgo/blob/647f256c447ee20f9bf13ebc42e612d55994a383/docker/base/patch.tar.xz?raw=true" | xz -dc - | tar -xf - | ||
- mv v1 "${OSXCROSS_PATH}/SDK/MacOSX${SDK_VERSION}.sdk/usr/include/c++/v1" | ||
- rm -rf /tmp/osxcross "${OSXCROSS_PATH}/SDK/MacOSX${SDK_VERSION}.sdk/usr/share/man" | ||
script: | ||
- cd $TRAVIS_BUILD_DIR | ||
- ./sbt assembly | ||
- ./sbt publishLocal | ||
- openssl aes-256-cbc -K $encrypted_97aef7f4ae04_key -iv $encrypted_97aef7f4ae04_iv -in key.asc.enc -out key.asc -d | ||
- gpg --no-default-keyring --primary-keyring ./project/.gnupg/pubring.gpg --secret-keyring ./project/.gnupg/secring.gpg --keyring ./project/.gnupg/pubring.gpg --fingerprint --import key.asc | ||
- ./sbt publishSigned | ||
- ./sbt sonatypeRelease |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include "jni_utils.h" | ||
|
||
// Class fully qualified names | ||
const char *CLS_NODE = "org/bblfsh/client/v2/Node"; | ||
const char *CLS_CTX = "org/bblfsh/client/v2/Context"; | ||
|
||
extern JavaVM *jvm; // FIXME(bzz): double-check and document | ||
|
||
JNIEnv *getJNIEnv() { | ||
JNIEnv *pEnv = NULL; | ||
|
||
switch (jvm->GetEnv((void **)&pEnv, JNI_VERSION_1_8)) { | ||
case JNI_OK: // Thread is ready to use, nothing to do | ||
break; | ||
|
||
case JNI_EDETACHED: // Thread is detached, need to attach | ||
jvm->AttachCurrentThread((void **)&pEnv, NULL); | ||
break; | ||
} | ||
|
||
return pEnv; | ||
} | ||
|
||
jobject NewJavaObject(JNIEnv *env, const char *className, const char *initSign, | ||
...) { | ||
jclass cls = env->FindClass(className); | ||
if (env->ExceptionOccurred() || !cls) { | ||
return NULL; | ||
} | ||
|
||
jmethodID initId = env->GetMethodID(cls, "<init>", initSign); | ||
if (env->ExceptionOccurred() || !initId) { | ||
return NULL; | ||
} | ||
|
||
va_list varargs; | ||
va_start(varargs, initSign); | ||
jobject instance = env->NewObjectV(cls, initId, varargs); | ||
va_end(varargs); | ||
if (env->ExceptionOccurred() || !instance) { | ||
return NULL; | ||
} | ||
|
||
return instance; | ||
} | ||
|
||
jfieldID getField(JNIEnv *env, jobject obj, const char *name) { | ||
jclass cls = env->GetObjectClass(obj); | ||
if (env->ExceptionOccurred() || !cls) { | ||
return nullptr; | ||
} | ||
|
||
jfieldID jfid = env->GetFieldID(cls, name, "J"); | ||
if (env->ExceptionOccurred() || !jfid) { | ||
return nullptr; | ||
} | ||
return jfid; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef _Included_org_bblfsh_client_libuast_Libuast_jni_utils | ||
#define _Included_org_bblfsh_client_libuast_Libuast_jni_utils | ||
|
||
#include <jni.h> | ||
|
||
extern const char *CLS_NODE; | ||
extern const char *CLS_CTX; | ||
|
||
JNIEnv *getJNIEnv(); | ||
jobject NewJavaObject(JNIEnv *, const char *, const char *, ...); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I follow the naming convention in use here. Google style is (I'm not wedded to Google style, I only mentioned that because you included a clang-format config based on that style)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an old code, I belive it follow the same that was used in libuast. I'm not settled on this one either, but I think it's totally fine to use almost whatever in a the well-localized JNI wrappers themselves. Will be happy to refactor it, if needed, and add a better formatter config to all the projects later on, as soon as we have something functional in scala-client. For now, I'm mostly not very worried about it because of the limited scope and no expectations for this native piece to grow. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, this doesn't need to be addressed right now, I just wanted to make a note of it while we're paying attention to this code. 🙂 |
||
jfieldID getField(JNIEnv *env, jobject obj, const char *name); | ||
|
||
#endif |
Uh oh!
There was an error while loading. Please reload this page.