-
Notifications
You must be signed in to change notification settings - Fork 751
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add presets for libffi 3.3 (issue #833)
- Loading branch information
Showing
29 changed files
with
1,750 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: libffi | ||
on: | ||
push: | ||
paths: | ||
- libffi/** | ||
pull_request: | ||
paths: | ||
- libffi/** | ||
workflow_dispatch: | ||
env: | ||
CI_DEPLOY_MODULE: ${{ github.workflow }} | ||
CI_DEPLOY_PLATFORM: ${{ github.job }} | ||
CI_DEPLOY_SETTINGS: ${{ secrets.CI_DEPLOY_SETTINGS }} | ||
CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} | ||
CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} | ||
STAGING_REPOSITORY: ${{ secrets.STAGING_REPOSITORY }} | ||
jobs: | ||
android-arm: | ||
runs-on: ubuntu-16.04 | ||
container: centos:7 | ||
steps: | ||
- uses: bytedeco/javacpp-presets/.github/actions/deploy-centos@actions | ||
android-arm64: | ||
runs-on: ubuntu-16.04 | ||
container: centos:7 | ||
steps: | ||
- uses: bytedeco/javacpp-presets/.github/actions/deploy-centos@actions | ||
android-x86: | ||
runs-on: ubuntu-16.04 | ||
container: centos:7 | ||
steps: | ||
- uses: bytedeco/javacpp-presets/.github/actions/deploy-centos@actions | ||
android-x86_64: | ||
runs-on: ubuntu-16.04 | ||
container: centos:7 | ||
steps: | ||
- uses: bytedeco/javacpp-presets/.github/actions/deploy-centos@actions | ||
linux-armhf: | ||
runs-on: ubuntu-16.04 | ||
container: ubuntu:xenial | ||
steps: | ||
- uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions | ||
linux-arm64: | ||
runs-on: ubuntu-16.04 | ||
container: ubuntu:xenial | ||
steps: | ||
- uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions | ||
linux-ppc64le: | ||
runs-on: ubuntu-16.04 | ||
container: ubuntu:xenial | ||
steps: | ||
- uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions | ||
linux-x86: | ||
runs-on: ubuntu-16.04 | ||
container: centos:6 | ||
steps: | ||
- uses: bytedeco/javacpp-presets/.github/actions/deploy-centos@actions | ||
linux-x86_64: | ||
runs-on: ubuntu-16.04 | ||
container: centos:6 | ||
steps: | ||
- uses: bytedeco/javacpp-presets/.github/actions/deploy-centos@actions | ||
macosx-x86_64: | ||
runs-on: macos-10.15 | ||
steps: | ||
- uses: bytedeco/javacpp-presets/.github/actions/deploy-macosx@actions | ||
windows-x86: | ||
runs-on: windows-2019 | ||
steps: | ||
- uses: bytedeco/javacpp-presets/.github/actions/deploy-windows@actions | ||
windows-x86_64: | ||
runs-on: windows-2019 | ||
steps: | ||
- uses: bytedeco/javacpp-presets/.github/actions/deploy-windows@actions | ||
redeploy: | ||
needs: [android-arm, android-arm64, android-x86, android-x86_64, linux-armhf, linux-arm64, linux-ppc64le, linux-x86, linux-x86_64, macosx-x86_64, windows-x86, windows-x86_64] | ||
runs-on: ubuntu-16.04 | ||
steps: | ||
- uses: bytedeco/javacpp-presets/.github/actions/redeploy@actions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
libffi - Copyright (c) 1996-2019 Anthony Green, Red Hat, Inc and others. | ||
See source files for details. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
``Software''), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
JavaCPP Presets for libffi | ||
========================== | ||
|
||
[![Gitter](https://badges.gitter.im/bytedeco/javacpp.svg)](https://gitter.im/bytedeco/javacpp) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.bytedeco/libffi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.bytedeco/libffi) [![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/https/oss.sonatype.org/org.bytedeco/libffi.svg)](http://bytedeco.org/builds/) | ||
<sup>Build status for all platforms:</sup> [![libffi](https://github.com/bytedeco/javacpp-presets/workflows/libffi/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Alibffi) <sup>Commercial support:</sup> [![xscode](https://img.shields.io/badge/Available%20on-xs%3Acode-blue?style=?style=plastic&logo=appveyor&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAZQTFRF////////VXz1bAAAAAJ0Uk5T/wDltzBKAAAAlUlEQVR42uzXSwqAMAwE0Mn9L+3Ggtgkk35QwcnSJo9S+yGwM9DCooCbgn4YrJ4CIPUcQF7/XSBbx2TEz4sAZ2q1RAECBAiYBlCtvwN+KiYAlG7UDGj59MViT9hOwEqAhYCtAsUZvL6I6W8c2wcbd+LIWSCHSTeSAAECngN4xxIDSK9f4B9t377Wd7H5Nt7/Xz8eAgwAvesLRjYYPuUAAAAASUVORK5CYII=)](https://xscode.com/bytedeco/javacpp-presets) | ||
|
||
|
||
Introduction | ||
------------ | ||
This directory contains the JavaCPP Presets module for: | ||
|
||
* libffi 3.3 https://sourceware.org/libffi/ | ||
|
||
Please refer to the parent README.md file for more detailed information about the JavaCPP Presets. | ||
|
||
|
||
Documentation | ||
------------- | ||
Java API documentation is available here: | ||
|
||
* http://bytedeco.org/javacpp-presets/libffi/apidocs/ | ||
|
||
|
||
Sample Usage | ||
------------ | ||
Here is a simple example of libffi ported to Java from the "Simple Example" in this file: | ||
|
||
* https://github.com/libffi/libffi/blob/master/doc/libffi.texi | ||
|
||
We can use [Maven 3](http://maven.apache.org/) to download and install automatically all the class files as well as the native binaries. To run this sample code, after creating the `pom.xml` and `SimpleExample.java` source files below, simply execute on the command line: | ||
```bash | ||
$ mvn compile exec:java | ||
``` | ||
|
||
### The `pom.xml` build file | ||
```xml | ||
<project> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.bytedeco.libffi</groupId> | ||
<artifactId>simpleexample</artifactId> | ||
<version>1.5.6-SNAPSHOT</version> | ||
<properties> | ||
<exec.mainClass>SimpleExample</exec.mainClass> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.bytedeco</groupId> | ||
<artifactId>libffi-platform</artifactId> | ||
<version>3.3-1.5.6-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<sourceDirectory>.</sourceDirectory> | ||
</build> | ||
</project> | ||
``` | ||
|
||
### The `SimpleExample.java` source file | ||
```java | ||
import org.bytedeco.javacpp.*; | ||
import org.bytedeco.libffi.*; | ||
import static org.bytedeco.libffi.global.ffi.*; | ||
|
||
public class SimpleExample { | ||
static Pointer puts = Loader.addressof("puts"); | ||
|
||
public static void main(String[] a) { | ||
ffi_cif cif = new ffi_cif(); | ||
PointerPointer<ffi_type> args = new PointerPointer<>(1); | ||
PointerPointer<PointerPointer> values = new PointerPointer<>(1); | ||
PointerPointer<BytePointer> s = new PointerPointer<>(1); | ||
LongPointer rc = new LongPointer(1); | ||
|
||
/* Initialize the argument info vectors */ | ||
args.put(0, ffi_type_pointer()); | ||
values.put(0, s); | ||
|
||
/* Initialize the cif */ | ||
if (ffi_prep_cif(cif, FFI_DEFAULT_ABI(), 1, | ||
ffi_type_sint(), args) == FFI_OK) | ||
{ | ||
s.putString("Hello World!"); | ||
ffi_call(cif, puts, rc, values); | ||
/* rc now holds the result of the call to puts */ | ||
|
||
/* values holds a pointer to the function's arg, so to | ||
call puts() again all we need to do is change the | ||
value of s */ | ||
s.putString("This is cool!"); | ||
ffi_call(cif, puts, rc, values); | ||
} | ||
|
||
System.exit(0); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#!/bin/bash | ||
# This file is meant to be included by the parent cppbuild.sh script | ||
if [[ -z "$PLATFORM" ]]; then | ||
pushd .. | ||
bash cppbuild.sh "$@" libffi | ||
popd | ||
exit | ||
fi | ||
|
||
LIBFFI_VERSION=3.3 | ||
download https://github.com/libffi/libffi/releases/download/v$LIBFFI_VERSION/libffi-$LIBFFI_VERSION.tar.gz libffi-$LIBFFI_VERSION.tar.gz | ||
|
||
mkdir -p $PLATFORM | ||
cd $PLATFORM | ||
INSTALL_PATH=`pwd` | ||
echo "Decompressing archives..." | ||
tar --totals -xzf ../libffi-$LIBFFI_VERSION.tar.gz | ||
cd libffi-$LIBFFI_VERSION | ||
|
||
case $PLATFORM in | ||
android-arm) | ||
export AR="$ANDROID_PREFIX-ar" | ||
export RANLIB="$ANDROID_PREFIX-ranlib" | ||
export CC="$ANDROID_CC $ANDROID_FLAGS" | ||
export STRIP="$ANDROID_PREFIX-strip" | ||
export LIBS="$ANDROID_LIBS" | ||
./configure --prefix="$INSTALL_PATH" --disable-multi-os-directory --host="arm-linux-androideabi" --with-sysroot="$ANDROID_ROOT" | ||
make -j $MAKEJ | ||
make install-strip | ||
;; | ||
android-arm64) | ||
export AR="$ANDROID_PREFIX-ar" | ||
export RANLIB="$ANDROID_PREFIX-ranlib" | ||
export CC="$ANDROID_CC $ANDROID_FLAGS" | ||
export STRIP="$ANDROID_PREFIX-strip" | ||
export LIBS="$ANDROID_LIBS" | ||
./configure --prefix="$INSTALL_PATH" --disable-multi-os-directory --host="aarch64-linux-android" --with-sysroot="$ANDROID_ROOT" | ||
make -j $MAKEJ | ||
make install-strip | ||
;; | ||
android-x86) | ||
export AR="$ANDROID_PREFIX-ar" | ||
export RANLIB="$ANDROID_PREFIX-ranlib" | ||
export CC="$ANDROID_CC $ANDROID_FLAGS" | ||
export STRIP="$ANDROID_PREFIX-strip" | ||
export LIBS="$ANDROID_LIBS" | ||
./configure --prefix="$INSTALL_PATH" --disable-multi-os-directory --host="i686-linux-android" --with-sysroot="$ANDROID_ROOT" | ||
make -j $MAKEJ | ||
make install-strip | ||
;; | ||
android-x86_64) | ||
export AR="$ANDROID_PREFIX-ar" | ||
export RANLIB="$ANDROID_PREFIX-ranlib" | ||
export CC="$ANDROID_CC $ANDROID_FLAGS" | ||
export STRIP="$ANDROID_PREFIX-strip" | ||
export LIBS="$ANDROID_LIBS" | ||
./configure --prefix="$INSTALL_PATH" --disable-multi-os-directory --host="x86_64-linux-android" --with-sysroot="$ANDROID_ROOT" | ||
make -j $MAKEJ | ||
make install-strip | ||
;; | ||
linux-x86) | ||
CC="gcc -m32" ./configure --prefix="$INSTALL_PATH" --disable-multi-os-directory | ||
make -j $MAKEJ | ||
make install-strip | ||
;; | ||
linux-x86_64) | ||
CC="gcc -m64" ./configure --prefix="$INSTALL_PATH" --disable-multi-os-directory | ||
make -j $MAKEJ | ||
make install-strip | ||
;; | ||
linux-armhf) | ||
CC="arm-linux-gnueabihf-gcc" ./configure --prefix="$INSTALL_PATH" --disable-multi-os-directory --host="arm-linux-gnueabihf" | ||
make -j $MAKEJ | ||
make install-strip | ||
;; | ||
linux-arm64) | ||
CC="aarch64-linux-gnu-gcc" ./configure --prefix="$INSTALL_PATH" --disable-multi-os-directory --host="aarch64-linux-gnu" | ||
make -j $MAKEJ | ||
make install-strip | ||
;; | ||
linux-ppc64le) | ||
CC="powerpc64le-linux-gnu-gcc" ./configure --prefix="$INSTALL_PATH" --disable-multi-os-directory --host="powerpc64le-linux-gnu" | ||
make -j $MAKEJ | ||
make install-strip | ||
;; | ||
macosx-*) | ||
CC="clang" ./configure --prefix="$INSTALL_PATH" --disable-multi-os-directory | ||
make -j $MAKEJ | ||
make install-strip | ||
;; | ||
windows-x86) | ||
CC="../msvcc.sh -m32" LD="link" CPP="cl -nologo -EP" CPPFLAGS="-DFFI_BUILDING_DLL" ./configure --prefix="$INSTALL_PATH" --disable-multi-os-directory | ||
make -j $MAKEJ | ||
make install || true | ||
cp */.libs/* ../lib | ||
;; | ||
windows-x86_64) | ||
CC="../msvcc.sh -m64" LD="link" CPP="cl -nologo -EP" CPPFLAGS="-DFFI_BUILDING_DLL" ./configure --prefix="$INSTALL_PATH" --disable-multi-os-directory | ||
make -j $MAKEJ | ||
make install || true | ||
cp */.libs/* ../lib | ||
;; | ||
*) | ||
echo "Error: Platform \"$PLATFORM\" is not supported" | ||
;; | ||
esac | ||
|
||
cd ../.. |
Oops, something went wrong.