Skip to content
Permalink
Browse files

Merge pull request #647 from bluca/rpm

Problem: CFFI RPM builds with both python 2 and 3 broken
  • Loading branch information
keent committed Nov 29, 2019
2 parents 096e658 + edb24c3 commit f13b5597cd340b6bb8bc112c68121fc3a6651c84
@@ -218,11 +218,15 @@ ENDIF (NOT MSVC)

# shared
if (ZYRE_BUILD_SHARED)
IF (MSVC)
IF (APPLE)
add_library(zyre SHARED ${zyre_sources})
ELSE (MSVC)
add_library(zyre SHARED $<TARGET_OBJECTS:zyre_objects>)
ENDIF (MSVC)
ELSE (APPLE)
IF (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
PUBLIC_HEADER "${public_headers}"
@@ -254,11 +258,15 @@ endif()

# static
if (ZYRE_BUILD_STATIC)
IF (MSVC)
IF (APPLE)
add_library(zyre-static STATIC ${zyre_sources})
ELSE (MSVC)
add_library(zyre-static STATIC $<TARGET_OBJECTS:zyre_objects>)
ENDIF (MSVC)
ELSE (APPLE)
IF (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
PUBLIC_HEADER "${public_headers}"
@@ -72,6 +72,17 @@ void
void
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.
// This can be tuned in order to deal with expected network conditions
// and the response time expected by the application. This is tied to
@@ -57,6 +57,16 @@ interface
// the beacon interval and rate of messages received.
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.
// This can be tuned in order to deal with expected network conditions
// and the response time expected by the application. This is tied to
@@ -287,6 +297,16 @@ TZyre = class(TInterfacedObject, IZyre)
// the beacon interval and rate of messages received.
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.
// This can be tuned in order to deal with expected network conditions
// and the response time expected by the application. This is tied to
@@ -569,6 +589,11 @@ implementation
zyre_set_evasive_timeout(FHandle, Interval);
end;

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

procedure TZyre.SetExpiredTimeout(Interval: Integer);
begin
zyre_set_expired_timeout(FHandle, Interval);
@@ -80,6 +80,16 @@ interface
// 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};

// 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.
// This can be tuned in order to deal with expected network conditions
// and the response time expected by the application. This is tied to
@@ -6,3 +6,4 @@ build/
src/native
gradle-app.setting
libzyrejni.so
*.class
@@ -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).
## 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
See bindings/jni/android/build.sh.
@@ -56,15 +47,36 @@ This does the following:
## 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.
2. In each project, open a console in builds/msvc/vs2010 and run the build.bat batch file.
3. In this project, open a console in bindings/jni/msvc/vs2010 and run the build.bat batch file.
2. Follow the dependent projects instuctions to build thier '.dll' and '.lib' 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
@@ -4,146 +4,52 @@
# Read the zproject/README.md for information about making permanent changes. #
################################################################################
*/
import static org.apache.tools.ant.taskdefs.condition.Os.*

plugins {
id 'java'
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"
version = "2.0.1"
wrapper.gradleVersion = '5.6.2'

repositories {
mavenLocal()
mavenCentral()
jcenter()
}

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
subprojects {
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'com.google.osdetector'

task generateJniHeaders(type: Exec, dependsOn: 'classes') {
def classpath = sourceSets.main.output.classesDirs
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 "."
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

jar.dependsOn buildNative
jar.dependsOn copyLibs
test.dependsOn buildNative

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}")
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
}

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

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

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

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
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')
}
}
if (project.hasProperty('isRelease')) {
version = '2.0.1'
} else {
version = '2.0.1-SNAPSHOT'
}
}

bintray {
user = System.getenv('BINTRAY_USER')
key = System.getenv('BINTRAY_KEY')
publications = ['mavenJava']
publish = true
override = true
pkg {
repo = "maven"
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'
artifactory {
contextUrl = "https://oss.jfrog.org/artifactory" //The base Artifactory URL if not overridden by the publisher/resolver
publish {
repository {
repoKey = 'oss-snapshot-local'
username = System.getenv('ARTIFACTORY_USERNAME')
password = System.getenv('ARTIFACTORY_PASSWORD')
maven = true
}
}
}

// ------------------------------------------------------------------
// Cleanup section

clean.doFirst {
delete "${rootDir}/CMakeCache.txt"
delete fileTree("${rootDir}") { include "*.so" }
}
bintrayPublish.enabled = false
@@ -106,21 +106,19 @@ $CI_TIME make install

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

########################################################################
# 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

popd

pushd android

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

popd
pushd zyre-jni/android
TERM=dumb PKG_CONFIG_PATH=$BUILD_PREFIX/lib/pkgconfig $CI_TIME ./build.sh
popd
fi
@@ -1 +1,4 @@
rootProject.name = 'zyre-jni'
include 'zyre-jni'
include 'zyre-jni-native'
include 'zyre-jni-all'

0 comments on commit f13b559

Please sign in to comment.
You can’t perform that action at this time.