Skip to content

Commit

Permalink
add android variants, update natives
Browse files Browse the repository at this point in the history
  • Loading branch information
twall committed Sep 12, 2015
1 parent 4edc2a5 commit dde47fa
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Features
* [#422](https://github.com/twall/jna/pull/422): Update libffi to v3.2.1 - [@tdaitx](https://github.com/tdaitx).
* [#425](https://github.com/twall/jna/pull/425): Add support for PPCLE - [@tdaitx](https://github.com/tdaix).
* [#428](https://github.com/twall/jna/pull/428): Added Wincon.h related functions and definitions to `com.sun.jna.platform.win32.Kernel32` - [@lgoldstein](https://github.com/lgoldstein).
* [#430](https://github.com/twall/jna/issues/430): Add android `aarch64`, `x86-64`, `mips`, and `mips64` targets - [@twall](https://github.com/twall).
* [#431](https://github.com/twall/jna/pull/431): Added named pipe API support to `com.sun.jna.platform.win32.Kernel32` - [@lgoldstein](https://github.com/lgoldstein).
* [#432](https://github.com/twall/jna/pull/432): Added SetLocalTime definition to 'com.sun.jna.platform.win32.Kernel32' - [@lgoldstein](https://github.com/lgoldstein).
* [#434](https://github.com/twall/jna/pull/434): Added GetEnvironmentStrings to 'com.sun.jna.platform.win32.Kernel32' - [@lgoldstein](https://github.com/lgoldstein).
Expand Down
31 changes: 24 additions & 7 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Cross-compile by specifying -Dos.prefix={name-arch} to ant
(cross-compile currently only configured/tested on w32ce-arm and
android-arm/-x86)
android-{arm|aarch64|x86|x86-64|mips|mips64})
Use ANT_OPTS=-Dskip-native=false to build native parts, or directly
invoke the native or test targets
Expand Down Expand Up @@ -174,8 +174,12 @@
</condition>
<condition property="vmopt.arch" value="${vm.64}" else="${vm.32}">
<and>
<not><equals arg1="${os.prefix}" arg2="android-arm" trim="true"/></not>
<not><equals arg1="${os.prefix}" arg2="android-x86" trim="true"/></not>
<not>
<and>
<matches pattern="^android-" string="${os.prefix}"/>
<not><matches patterm="64$" string="${os.prefix}"/></not>
</and>
</not>
<or>
<equals arg1="${sun.arch.data.model}" arg2="64" trim="true"/>
<equals arg1="${com.ibm.vm.bitmode}" arg2="64" trim="true"/>
Expand Down Expand Up @@ -611,7 +615,11 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/sunos-sparc.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/sunos-sparcv9.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/android-arm.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/android-aarch64.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/android-x86.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/android-x86-64.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/android-mips.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/android-mips64.jar" overwrite="true"/>
<delete failOnError="false" includeEmptyDirs="true">
<fileset dir="${build.native}" includes="*.o,*jnidispatch*"/>
</delete>
Expand Down Expand Up @@ -670,10 +678,7 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc
<equals arg1="${os.prefix}" arg2="w32ce-arm"/>
</condition>
<condition property="make.OS" value="OS=android">
<or>
<equals arg1="${os.prefix}" arg2="android-arm"/>
<equals arg1="${os.prefix}" arg2="android-x86"/>
</or>
<matches pattern="^android-" string="${os.prefix}"/>
</condition>
<property name="make.OS" value="IGNORE="/>
<!-- Ensure Makefile ARCH property properly set -->
Expand All @@ -683,9 +688,21 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc
<condition property="ARCH" value="arm">
<equals arg1="${os.prefix}" arg2="android-arm"/>
</condition>
<condition property="ARCH" value="aarch64">
<equals arg1="${os.prefix}" arg2="android-aarch64"/>
</condition>
<condition property="ARCH" value="x86">
<equals arg1="${os.prefix}" arg2="android-x86"/>
</condition>
<condition property="ARCH" value="x86-64">
<equals arg1="${os.prefix}" arg2="android-x86-64"/>
</condition>
<condition property="ARCH" value="mips">
<equals arg1="${os.prefix}" arg2="android-mips"/>
</condition>
<condition property="ARCH" value="mips64">
<equals arg1="${os.prefix}" arg2="android-mips64"/>
</condition>
<condition property="ARCH" value="ppc">
<equals arg1="${os.prefix}" arg2="aix-ppc"/>
</condition>
Expand Down
Binary file added lib/native/android-aarch64.jar
Binary file not shown.
Binary file modified lib/native/android-arm.jar
Binary file not shown.
Binary file added lib/native/android-mips.jar
Binary file not shown.
Binary file added lib/native/android-mips64.jar
Binary file not shown.
Binary file added lib/native/android-x86-64.jar
Binary file not shown.
Binary file modified lib/native/android-x86.jar
Binary file not shown.
46 changes: 36 additions & 10 deletions native/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Solaris (i386/amd64/sparc/sparcv9)
# AIX (ppc/ppc64)
# FreeBSD/OpenBSD/NetBSD (i386/amd64)
# Android (arm/x86)
# Android (arm/aarch64/x86/x86-64/mipsel/mips64el)
#
# Built, but with outstanding bugs (not necessarily within JNA):
#
Expand All @@ -28,7 +28,7 @@
#
# The android build requires the android SDK+NDK for cross-compilation;
# make the tools available on the path and compile with
# "ant -Dos.prefix=android-arm(-x86)". Put the NDK tools in the path and adjust
# "ant -Dos.prefix=android-{arm|x86}". Put the NDK tools in the path and adjust
# NDK_PLATFORM below or set it in your environment.
#
# The windows build requires a cygwin installation. The build will use MSVC
Expand Down Expand Up @@ -114,26 +114,52 @@ STRIP=strip -x
# Android build (cross-compile) requires the android SDK+NDK.
# Ensure the following tools are in your path and adjust NDK_PLATFORM as needed
ifeq ($(OS),android)
AARCH=$(ARCH)
ALIBDIR=/usr/lib
ifeq ($(ARCH),arm)
PREFIX=arm-linux-androideabi-
COPT+= -mthumb-interwork -march=armv5te -mtune=xscale -msoft-float -fstack-protector
HOST=arm-linux-eabi
else
PREFIX=i686-android-linux-
else ifeq ($(ARCH),aarch64)
PREFIX=aarch64-linux-android-
HOST=aarch64-linux-android
AARCH=arm64
ALIBDIR=/usr/lib64
else ifeq ($(ARCH),x86)
PREFIX=i686-linux-android-
COPT+= -march=i686
HOST=i686-linux
HOST=i686-linux-android
else ifeq ($(ARCH),x86-64)
PREFIX=x86_64-linux-android-
COPT+= -m64
HOST=x86_64-linux-android
AARCH=x86_64
ALIBDIR=/usr/lib64
else ifeq ($(ARCH),mips)
PREFIX=mipsel-linux-android-
HOST=mipsel-linux-android
COPT+=
else ifeq ($(ARCH),mips64)
PREFIX=mips64el-linux-android-
HOST=mips64el-linux-android
COPT+=
ALIBDIR=/usr/lib64
else
ERROR = $(error "Unsupported android architecture '$(ARCH)'")
endif
CC=$(PREFIX)gcc
NDK?=/Developer/Applications/android-ndk-r10e
NDK_PLATFORM?=$(NDK)/platforms/android-21
SYSROOT=$(NDK_PLATFORM)/arch-$(AARCH)
CC=$(PREFIX)gcc --sysroot $(SYSROOT)
CPP=$(PREFIX)cpp
LD=$(PREFIX)gcc
LD=$(CC)
RANLIB=$(PREFIX)ranlib
STRIP=$(PREFIX)strip -x
CDEFINES=-DNO_JAWT -DNO_WEAK_GLOBALS -DFFI_MMAP_EXEC_WRIT=1 -DFFI_MMAP_EXEC_SELINUX=0
COPT+=-fpic -ffunction-sections -funwind-tables -fno-short-enums
NDK_PLATFORM?=/Developer/Applications/android-ndk-r7c/platforms/android-14
JAVA_INCLUDES=
CINCLUDES+=-I"$(NDK_PLATFORM)/arch-$(ARCH)/usr/include" # -I/usr/include
LIBS=-nostdlib -L"$(NDK_PLATFORM)/arch-$(ARCH)/usr/lib/" -lgcc -lc -ldl -lm
CINCLUDES+=-I"$(NDK_PLATFORM)/arch-$(AARCH)/usr/include" # -I/usr/include
LIBS=-nostdlib -L"$(NDK_PLATFORM)/arch-$(AARCH)$(ALIBDIR)/" -lgcc -lc -ldl -lm
LDFLAGS+=-Wl,-shared,-Bsymbolic
FFI_ENV=CPP="$(CPP)" CC="$(CC)" CFLAGS="$(COPT) $(CDEBUG) $(CINCLUDES)" CPPFLAGS="$(CDEFINES) $(CINCLUDES)" LIBS="$(LIBS)" RANLIB="$(RANLIB)"
FFI_CONFIG=--enable-static --disable-shared --with-pic=yes --host=$(HOST)
Expand Down

0 comments on commit dde47fa

Please sign in to comment.