Skip to content

Commit

Permalink
* Add presets for libffi 3.3 (issue #833)
Browse files Browse the repository at this point in the history
  • Loading branch information
saudet committed May 20, 2021
1 parent 7b925c6 commit 6df0806
Show file tree
Hide file tree
Showing 29 changed files with 1,750 additions and 12 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/libffi.yml
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Build FFmpeg with libxml2, enabling support for DASH demuxing ([pull #1033](https://github.com/bytedeco/javacpp-presets/pull/1033)), and libsrt for SRT protocol support ([pull #1036](https://github.com/bytedeco/javacpp-presets/pull/1036))
* Add `@MemberGetter` for `av_log_default_callback()` in presets for FFmpeg ([issue #812](https://github.com/bytedeco/javacpp-presets/issues/812))
* Include `cudaGL.h` and `cuda_gl_interop.h` header files in presets for CUDA ([pull #1027](https://github.com/bytedeco/javacpp-presets/pull/1027))
* Add presets for NVIDIA Video Codec SDK 11.0.10 ([pull #1020](https://github.com/bytedeco/javacpp-presets/pull/1020)), PyTorch 1.8.1 ([issue #623](https://github.com/bytedeco/javacpp-presets/issues/623)), DepthAI 2.3.0, ModSecurity ([pull #1012](https://github.com/bytedeco/javacpp-presets/pull/1012))
* Add presets for libffi 3.3 ([issue #833](https://github.com/bytedeco/javacpp-presets/issues/833)), NVIDIA Video Codec SDK 11.0.10 ([pull #1020](https://github.com/bytedeco/javacpp-presets/pull/1020)), PyTorch 1.8.1 ([issue #623](https://github.com/bytedeco/javacpp-presets/issues/623)), DepthAI 2.3.0, ModSecurity ([pull #1012](https://github.com/bytedeco/javacpp-presets/pull/1012))
* Map `std::vector<cv::Range>` to `RangeVector` in `opencv_core.Mat` for convenience ([issue bytedeco/javacv#1607](https://github.com/bytedeco/javacv/issues/1607))
* Include `genericaliasobject.h`, `context.h`, `tracemalloc.h`, and `datetime.h` for CPython ([issue #1017](https://github.com/bytedeco/javacpp-presets/issues/1017))
* Add samples using LLVM modules to deal with bitcode and object files ([pull #1016](https://github.com/bytedeco/javacpp-presets/pull/1016))
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ JavaCPP Presets
[![scipy](https://github.com/bytedeco/javacpp-presets/workflows/scipy/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Ascipy)
[![gym](https://github.com/bytedeco/javacpp-presets/workflows/gym/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Agym)
[![llvm](https://github.com/bytedeco/javacpp-presets/workflows/llvm/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Allvm)
[![libffi](https://github.com/bytedeco/javacpp-presets/workflows/libffi/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Alibffi)
[![libpostal](https://github.com/bytedeco/javacpp-presets/workflows/libpostal/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Alibpostal)
[![leptonica](https://github.com/bytedeco/javacpp-presets/workflows/leptonica/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Aleptonica)
[![tesseract](https://github.com/bytedeco/javacpp-presets/workflows/tesseract/badge.svg)](https://github.com/bytedeco/javacpp-presets/actions?query=workflow%3Atesseract)
Expand Down Expand Up @@ -196,6 +197,7 @@ Each child module in turn relies by default on the included [`cppbuild.sh` scrip
* SciPy 1.6.x https://github.com/scipy/scipy
* Gym 0.18.x https://github.com/openai/gym
* LLVM 12.x.x http://llvm.org/releases/download.html
* libffi 3.3 https://github.com/libffi/libffi
* libpostal 1.1-alpha https://github.com/openvenues/libpostal
* Leptonica 1.80.0 http://www.leptonica.org/download.html
* Tesseract 4.1.1 https://github.com/tesseract-ocr/tesseract
Expand Down
21 changes: 21 additions & 0 deletions libffi/LICENSE
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.
96 changes: 96 additions & 0 deletions libffi/README.md
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);
}
}
```
108 changes: 108 additions & 0 deletions libffi/cppbuild.sh
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 i686-w64-mingw32/.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 x86_64-w64-mingw32/.libs/* ../lib
;;
*)
echo "Error: Platform \"$PLATFORM\" is not supported"
;;
esac

cd ../..
Loading

0 comments on commit 6df0806

Please sign in to comment.