Skip to content

Commit

Permalink
Problem: CFFI RPM builds with both python 2 and 3 broken
Browse files Browse the repository at this point in the history
Solution: regenerate from zproject
  • Loading branch information
bluca committed Nov 29, 2019
1 parent 096e658 commit edb24c3
Show file tree
Hide file tree
Showing 27 changed files with 391 additions and 283 deletions.
24 changes: 16 additions & 8 deletions CMakeLists.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -218,11 +218,15 @@ ENDIF (NOT MSVC)


# shared # shared
if (ZYRE_BUILD_SHARED) if (ZYRE_BUILD_SHARED)
IF (MSVC) IF (APPLE)
add_library(zyre SHARED ${zyre_sources}) add_library(zyre SHARED ${zyre_sources})
ELSE (MSVC) ELSE (APPLE)
add_library(zyre SHARED $<TARGET_OBJECTS:zyre_objects>) IF (MSVC)
ENDIF (MSVC) add_library(zyre SHARED ${zyre_sources})
ELSE (MSVC)
add_library(zyre SHARED $<TARGET_OBJECTS:zyre_objects>)
ENDIF (MSVC)
ENDIF(APPLE)


set_target_properties (zyre PROPERTIES set_target_properties (zyre PROPERTIES
PUBLIC_HEADER "${public_headers}" PUBLIC_HEADER "${public_headers}"
Expand Down Expand Up @@ -254,11 +258,15 @@ endif()


# static # static
if (ZYRE_BUILD_STATIC) if (ZYRE_BUILD_STATIC)
IF (MSVC) IF (APPLE)
add_library(zyre-static STATIC ${zyre_sources}) add_library(zyre-static STATIC ${zyre_sources})
ELSE (MSVC) ELSE (APPLE)
add_library(zyre-static STATIC $<TARGET_OBJECTS:zyre_objects>) IF (MSVC)
ENDIF (MSVC) add_library(zyre-static STATIC ${zyre_sources})
ELSE (MSVC)
add_library(zyre-static STATIC $<TARGET_OBJECTS:zyre_objects>)
ENDIF (MSVC)
ENDIF (APPLE)


set_target_properties(zyre-static PROPERTIES set_target_properties(zyre-static PROPERTIES
PUBLIC_HEADER "${public_headers}" PUBLIC_HEADER "${public_headers}"
Expand Down
11 changes: 11 additions & 0 deletions api/python_cffi.slurp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ void
void void
zyre_set_evasive_timeout (zyre_t *self, int interval); zyre_set_evasive_timeout (zyre_t *self, int interval);


// Set the peer silence timeout, in milliseconds. Default is 5000.
// This can be tuned in order to deal with expected network conditions
// and the response time expected by the application. This is tied to
// the beacon interval and rate of messages received.
// Silence is triggered one second after the timeout if peer has not
// answered ping and has not sent any message.
// NB: this is currently redundant with the evasiveness timeout. Both
// affect the same timeout value.
void
zyre_set_silent_timeout (zyre_t *self, int interval);

// Set the peer expiration timeout, in milliseconds. Default is 30000. // Set the peer expiration timeout, in milliseconds. Default is 30000.
// This can be tuned in order to deal with expected network conditions // This can be tuned in order to deal with expected network conditions
// and the response time expected by the application. This is tied to // and the response time expected by the application. This is tied to
Expand Down
25 changes: 25 additions & 0 deletions bindings/delphi/Zyre.pas
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ interface
// the beacon interval and rate of messages received. // the beacon interval and rate of messages received.
procedure SetEvasiveTimeout(Interval: Integer); procedure SetEvasiveTimeout(Interval: Integer);


// Set the peer silence timeout, in milliseconds. Default is 5000.
// This can be tuned in order to deal with expected network conditions
// and the response time expected by the application. This is tied to
// the beacon interval and rate of messages received.
// Silence is triggered one second after the timeout if peer has not
// answered ping and has not sent any message.
// NB: this is currently redundant with the evasiveness timeout. Both
// affect the same timeout value.
procedure SetSilentTimeout(Interval: Integer);

// Set the peer expiration timeout, in milliseconds. Default is 30000. // Set the peer expiration timeout, in milliseconds. Default is 30000.
// This can be tuned in order to deal with expected network conditions // This can be tuned in order to deal with expected network conditions
// and the response time expected by the application. This is tied to // and the response time expected by the application. This is tied to
Expand Down Expand Up @@ -287,6 +297,16 @@ TZyre = class(TInterfacedObject, IZyre)
// the beacon interval and rate of messages received. // the beacon interval and rate of messages received.
procedure SetEvasiveTimeout(Interval: Integer); procedure SetEvasiveTimeout(Interval: Integer);


// Set the peer silence timeout, in milliseconds. Default is 5000.
// This can be tuned in order to deal with expected network conditions
// and the response time expected by the application. This is tied to
// the beacon interval and rate of messages received.
// Silence is triggered one second after the timeout if peer has not
// answered ping and has not sent any message.
// NB: this is currently redundant with the evasiveness timeout. Both
// affect the same timeout value.
procedure SetSilentTimeout(Interval: Integer);

// Set the peer expiration timeout, in milliseconds. Default is 30000. // Set the peer expiration timeout, in milliseconds. Default is 30000.
// This can be tuned in order to deal with expected network conditions // This can be tuned in order to deal with expected network conditions
// and the response time expected by the application. This is tied to // and the response time expected by the application. This is tied to
Expand Down Expand Up @@ -569,6 +589,11 @@ implementation
zyre_set_evasive_timeout(FHandle, Interval); zyre_set_evasive_timeout(FHandle, Interval);
end; end;


procedure TZyre.SetSilentTimeout(Interval: Integer);
begin
zyre_set_silent_timeout(FHandle, Interval);
end;

procedure TZyre.SetExpiredTimeout(Interval: Integer); procedure TZyre.SetExpiredTimeout(Interval: Integer);
begin begin
zyre_set_expired_timeout(FHandle, Interval); zyre_set_expired_timeout(FHandle, Interval);
Expand Down
10 changes: 10 additions & 0 deletions bindings/delphi/libzyre.pas
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ interface
// the beacon interval and rate of messages received. // the beacon interval and rate of messages received.
procedure zyre_set_evasive_timeout(self: PZyre; Interval: Integer); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF}; procedure zyre_set_evasive_timeout(self: PZyre; Interval: Integer); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF};


// Set the peer silence timeout, in milliseconds. Default is 5000.
// This can be tuned in order to deal with expected network conditions
// and the response time expected by the application. This is tied to
// the beacon interval and rate of messages received.
// Silence is triggered one second after the timeout if peer has not
// answered ping and has not sent any message.
// NB: this is currently redundant with the evasiveness timeout. Both
// affect the same timeout value.
procedure zyre_set_silent_timeout(self: PZyre; Interval: Integer); cdecl; external lib_zyre {$IFDEF MSWINDOWS}delayed{$ENDIF};

// Set the peer expiration timeout, in milliseconds. Default is 30000. // Set the peer expiration timeout, in milliseconds. Default is 30000.
// This can be tuned in order to deal with expected network conditions // This can be tuned in order to deal with expected network conditions
// and the response time expected by the application. This is tied to // and the response time expected by the application. This is tied to
Expand Down
1 change: 1 addition & 0 deletions bindings/jni/.gitignore
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ build/
src/native src/native
gradle-app.setting gradle-app.setting
libzyrejni.so libzyrejni.so
*.class
40 changes: 26 additions & 14 deletions bindings/jni/README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@ If you don't like to install gradle beforehand just use the gradle wrapper.


This calls javah to build the headers in src/native/include, and then compiles the C and Java pieces to create a jar file a sharable library (.so). This calls javah to build the headers in src/native/include, and then compiles the C and Java pieces to create a jar file a sharable library (.so).


## Installing the JNI Layer for Linux

If you like to use this JNI Layer in another project you'll need to distribute it
to a location where the other project can locate it. The easiest way to do this
is by leveraging maven and install to the local maven repository located at
$HOME/.m2. Therefore simply run:

./gradlew publishToMavenLocal

## Building the JNI Layer for Android ## Building the JNI Layer for Android


See bindings/jni/android/build.sh. See bindings/jni/android/build.sh.
Expand Down Expand Up @@ -56,15 +47,36 @@ This does the following:


## Building the JNI Layer for Windows ## Building the JNI Layer for Windows


You need MS Visual Studio 2010 or later. Prerequisites:
* MS Visual Studio or MS Visual Studio Tools 2010 or later are installed
* Java JDK 8 or later is installed


You need the Java SDK. Set the JAVA_HOME environment to the installation location, e.g. C:Program FilesJavajdk1.8.0_66. Environment Variables:
* Add MSBuild.exe to the PATH, e.g. C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin
* Set JAVA_HOME to the installation location, e.g. C:\Program Files\Java\jdk1.8.0_66.


1. Check out all dependent projects from github, at the same level as this project. E.g.: libzmq, czmq. 1. Check out all dependent projects from github, at the same level as this project. E.g.: libzmq, czmq.
2. In each project, open a console in builds/msvc/vs2010 and run the build.bat batch file. 2. Follow the dependent projects instuctions to build thier '.dll' and '.lib' file.
3. In this project, open a console in bindings/jni/msvc/vs2010 and run the build.bat batch file. 3. Copy a dependent '.dll' and '.lib' files to a folder
4. Add this library folder to the path, e.g.:

PATH %PATH%;C:\projects\libs

Now run:


The resulting libraries (zyrejni.dll, zyrejni.lib) are created in bindings/jni/msvc/bin. gradlew build jar "-PvsGenerator=Visual Studio 16 2019"
gradlew test "-PvsGenerator=Visual Studio 16 2019"

Change the vsGenerator parameter to the version of MS Visual Studio you have installed.

## Installing the JNI Layer

If you like to use this JNI Layer in another project you'll need to distribute it
to a location where the other project can locate it. The easiest way to do this
is by leveraging maven and install to the local maven repository located at
$HOME/.m2. Therefore simply run:

./gradlew publishToMavenLocal


## Using the JNI API ## Using the JNI API


Expand Down
154 changes: 30 additions & 124 deletions bindings/jni/build.gradle
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,146 +4,52 @@
# Read the zproject/README.md for information about making permanent changes. # # Read the zproject/README.md for information about making permanent changes. #
################################################################################ ################################################################################
*/ */
import static org.apache.tools.ant.taskdefs.condition.Os.*


plugins { plugins {
id 'java' id 'java'
id 'maven-publish' id 'maven-publish'
id "com.jfrog.bintray" version "1.7.3" id 'com.jfrog.artifactory' version '4.9.9'
id 'com.jfrog.bintray' version '1.8.4'
id 'com.google.osdetector' version '1.6.2'
} }


group = "org.zeromq" wrapper.gradleVersion = '5.6.2'
version = "2.0.1"


repositories { subprojects {
mavenLocal() apply plugin: 'java'
mavenCentral() apply plugin: 'maven-publish'
jcenter() apply plugin: 'com.jfrog.bintray'
} apply plugin: 'com.jfrog.artifactory'

apply plugin: 'com.google.osdetector'
sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
compile 'org.zeromq:czmq-jni:+'
compile 'org.scijava:native-lib-loader:2.3.4'
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-all:1.3'
}

wrapper.gradleVersion = '5.4.1'

// ------------------------------------------------------------------
// Build section


task generateJniHeaders(type: Exec, dependsOn: 'classes') { sourceCompatibility = 1.8
def classpath = sourceSets.main.output.classesDirs targetCompatibility = 1.8
def appclasspath = configurations.runtime.files*.getAbsolutePath().join(":")
def nativeIncludes = "src/native/include"
def jniClasses = [
'src/main/java/org/zeromq/zyre/Zyre.java',
'src/main/java/org/zeromq/zyre/ZyreEvent.java'
]
def utilityClasses = [
'src/main/java/org/zeromq/tools/ZmqNativeLoader.java'
]
commandLine("javac", "-h", "$nativeIncludes", "-classpath", "$classpath:$appclasspath", *jniClasses, *utilityClasses)
}
tasks.withType(Test) {
systemProperty "java.library.path", "/usr/lib:/usr/local/lib:$projectDir"
}
task initCMake(type: Exec, dependsOn: 'generateJniHeaders') {
commandLine "cmake", "."
}
task buildNative(type: Exec, dependsOn: 'initCMake') {
commandLine "make"
}

task copyLibs(type: Copy) {
from "/usr/lib/libzyre.so", "/usr/local/lib/libzyre.so", "/tmp/lib/libzyre.so",
"/usr/lib/libzmq.so", "/usr/local/lib/libzmq.so", "/tmp/lib/libzmq.so",
"/usr/lib/libczmq.so", "/usr/local/lib/libczmq.so", "/tmp/lib/libczmq.so"
into "."
}


jar.dependsOn buildNative repositories {
jar.dependsOn copyLibs mavenLocal()
test.dependsOn buildNative mavenCentral()

jcenter()
jar {
String arch = "${OS_ARCH}".contains("64") ? "64" : "32"
String os = "${OS_NAME}".equals("mac") ? "osx" : "${OS_NAME}"
from(".") {
include("*.so")
into("/natives/${os}_${arch}")
} }
}

// ------------------------------------------------------------------
// Install and Publish section


task sourcesJar(type: Jar, dependsOn: 'classes') { group = 'org.zeromq.zyre'
classifier = 'sources'
from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: 'javadoc') {
classifier = 'javadoc'
from javadoc.destinationDir
}


publishing { if (project.hasProperty('isRelease')) {
publications { version = '2.0.1'
mavenJava(MavenPublication) { } else {
from components.java version = '2.0.1-SNAPSHOT'
artifact sourcesJar
artifact javadocJar
pom.withXml {
asNode().appendNode('packaging', 'jar')
asNode().appendNode('name', 'zyre-jni')
asNode().appendNode('description', 'an open-source framework for proximity-based P2P apps')
asNode().appendNode('url', 'https://github.com/zeromq/zyre')

def license = asNode().appendNode('licenses').appendNode('license')
license.appendNode('name', 'Mozilla Public License Version 2.0')
license.appendNode('url', 'https://www.mozilla.org/en-US/MPL/2.0/')

def scm = asNode().appendNode('scm')
scm.appendNode('connection', 'https://github.com/zeromq/zyre.git')
scm.appendNode('developerConnection', 'https://github.com/zeromq/zyre.git')
scm.appendNode('url', 'https://github.com/zeromq/zyre')
}
}
} }
} }


bintray { artifactory {
user = System.getenv('BINTRAY_USER') contextUrl = "https://oss.jfrog.org/artifactory" //The base Artifactory URL if not overridden by the publisher/resolver
key = System.getenv('BINTRAY_KEY') publish {
publications = ['mavenJava'] repository {
publish = true repoKey = 'oss-snapshot-local'
override = true username = System.getenv('ARTIFACTORY_USERNAME')
pkg { password = System.getenv('ARTIFACTORY_PASSWORD')
repo = "maven" maven = true
name = "zyre-jni"
desc = "an open-source framework for proximity-based P2P apps"
userOrg = System.getenv('BINTRAY_USER_ORG')
licenses = ["MPL-2.0"]
websiteUrl = 'https://github.com/zeromq/zyre'
issueTrackerUrl = 'https://github.com/zeromq/zyre/issues'
vcsUrl = 'https://github.com/zeromq/zyre.git'
githubRepo = System.getenv('BINTRAY_USER_ORG') + '/zyre'
version {
name = '2.0.1'
vcsTag= '2.0.1'
} }
} }
} }


// ------------------------------------------------------------------ bintrayPublish.enabled = false
// Cleanup section

clean.doFirst {
delete "${rootDir}/CMakeCache.txt"
delete fileTree("${rootDir}") { include "*.so" }
}
20 changes: 9 additions & 11 deletions bindings/jni/ci_build.sh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -106,21 +106,19 @@ $CI_TIME make install


popd popd


TERM=dumb PKG_CONFIG_PATH=$BUILD_PREFIX/lib/pkgconfig $CI_TIME ./gradlew build jar TERM=dumb PKG_CONFIG_PATH=$BUILD_PREFIX/lib/pkgconfig $CI_TIME ./gradlew build jar --info
TERM=dumb $CI_TIME ./gradlew clean TERM=dumb $CI_TIME ./gradlew clean


######################################################################## ########################################################################
# Build and check the jni android binding # Build and check the jni android binding
######################################################################## ########################################################################


pushd ../../builds/android if [ "$TRAVIS_OS_NAME" == "linux" ]; then
pushd ../../builds/android
. ./ci_build.sh
popd


. ./ci_build.sh pushd zyre-jni/android

TERM=dumb PKG_CONFIG_PATH=$BUILD_PREFIX/lib/pkgconfig $CI_TIME ./build.sh
popd popd

fi
pushd android

TERM=dumb PKG_CONFIG_PATH=$BUILD_PREFIX/lib/pkgconfig $CI_TIME ./build.sh

popd
3 changes: 3 additions & 0 deletions bindings/jni/settings.gradle
Original file line number Original file line Diff line number Diff line change
@@ -1 +1,4 @@
rootProject.name = 'zyre-jni' rootProject.name = 'zyre-jni'
include 'zyre-jni'
include 'zyre-jni-native'
include 'zyre-jni-all'
Loading

0 comments on commit edb24c3

Please sign in to comment.