Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable building jna for Darwin arm64 #1238

Closed
wants to merge 11 commits into from
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Next Release (5.7.0)

Features
--------
* [#1238](https://github.com/java-native-access/jna/pull/1238): Add macOS `aarch64` architecture to universal `darwin` target. Cherry pick [libffi/libffi#577](https://github.com/libffi/libffi/pull/577). - [@fkistner](https://github.com/fkistner).
fkistner marked this conversation as resolved.
Show resolved Hide resolved
* [#1264](https://github.com/java-native-access/jna/pull/1264): Update libffi to v3.3; Add Windows `aarch64` target. - [@tresf](https://github.com/tresf).
* [#1293](https://github.com/java-native-access/jna/issues/1293): Bind part of Windows Application Recovery and Restart API: `RegisterApplicationRestart`, `UnregisterApplicationRestart` and `GetApplicationRestartSettings` in `c.s.j.p.w.Kernel32` - [@matthiasblaesing](https://github.com/matthiasblaesing).
* [#1217](https://github.com/java-native-access/jna/pull/1217): Add mappings for AIX `Perfstat` library to `c.s.j.p.unix.aix` - [@dbwiddis](https://github.com/dbwiddis).
Expand Down
116 changes: 84 additions & 32 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,18 @@
<equals arg1="${build.os.name}" arg2="GNU/kFreeBSD"/>
</condition>
<fail unless="os.prefix" message="OS/arch not supported (${os.name}/${jre.arch}), edit build.xml and native/Makefile to add it."/>
<condition property="build.os.prefix" value="darwin-aarch64">
<and>
<equals arg1="${os.prefix}" arg2="darwin"/>
<equals arg1="${jre.arch}" arg2="aarch64"/>
</and>
</condition>
<condition property="build.os.prefix" value="darwin-intel">
<equals arg1="${os.prefix}" arg2="darwin"/>
</condition>
<property name="build.os.prefix" value="${os.prefix}"/>
<!-- Keep all natives separate -->
<property name="native.subdir" value="native-${os.prefix}"/>
<property name="native.subdir" value="native-${build.os.prefix}"/>
<condition property="jdk.home" value="${java.home}">
<available file="${java.home}/include"/>
</condition>
Expand All @@ -316,7 +326,7 @@
<condition property="ld.preload.name" value="LD_PRELOAD" else="IGNORE">
<not><equals arg1="${libjsig}" arg2=""/></not>
</condition>
<property name="native.jar" value="${os.prefix}.jar"/>
<property name="native.jar" value="${build.os.prefix}.jar"/>
<property name="build.native" location="${build}/${native.subdir}"/>
<property name="build.headers" location="${build}/headers"/>
<property name="build.aar" location="${build}/aar"/>
Expand Down Expand Up @@ -521,7 +531,7 @@ com/sun/jna/openbsd-x86-64/libjnidispatch.so;
processor=x86-64;osname=openbsd,

com/sun/jna/darwin/libjnidispatch.jnilib;
osname=macosx;processor=x86;processor=x86-64;processor=ppc
osname=macosx;processor=x86;processor=x86-64;processor=ppc;processor=aarch64
"/>
</manifest>
<manifest file="@{target}" mode="update" if:true="@{module-info}">
Expand Down Expand Up @@ -788,6 +798,8 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc
<target name="-native-api-check" depends="javah" unless="jni.valid">
<echo>Invalidating native code, new checksum is ${md5}</echo>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/darwin.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/darwin-intel.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/darwin-aarch64.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/win32-x86.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/win32-x86-64.jar" overwrite="true"/>
<copy file="${lib.native}/out-of-date.jar" tofile="${lib.native}/win32-aarch64.jar" overwrite="true"/>
Expand Down Expand Up @@ -829,7 +841,7 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc
<condition property="-rsrc">
<and>
<not><equals arg1="${build.os.family}" arg2="windows"/></not>
<not><equals arg1="${os.prefix}" arg2="w32ce-arm"/></not>
<not><equals arg1="${build.os.prefix}" arg2="w32ce-arm"/></not>
</and>
</condition>
</target>
Expand Down Expand Up @@ -866,42 +878,45 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc
<target name="-prepare-native" depends="-setup,rsrc">
<property name="comment" value="# auto-generated by ant"/>
<condition property="make.OS" value="OS=w32ce">
<equals arg1="${os.prefix}" arg2="w32ce-arm"/>
<equals arg1="${build.os.prefix}" arg2="w32ce-arm"/>
</condition>
<condition property="make.OS" value="OS=android">
<matches pattern="^android-" string="${os.prefix}"/>
</condition>
<property name="make.OS" value="IGNORE="/>
<!-- Ensure Makefile ARCH property properly set -->
<condition property="ARCH" value="arm">
<equals arg1="${os.prefix}" arg2="w32ce-arm"/>
<equals arg1="${build.os.prefix}" arg2="w32ce-arm"/>
</condition>
<condition property="ARCH" value="arm">
<equals arg1="${os.prefix}" arg2="android-arm"/>
<equals arg1="${build.os.prefix}" arg2="android-arm"/>
</condition>
<condition property="ARCH" value="armv7">
<equals arg1="${os.prefix}" arg2="android-armv7"/>
<equals arg1="${build.os.prefix}" arg2="android-armv7"/>
</condition>
<condition property="ARCH" value="arm64">
<equals arg1="${build.os.prefix}" arg2="darwin-aarch64"/>
</condition>
<condition property="ARCH" value="aarch64">
<matches string="${os.prefix}" pattern="-aarch64$"/>
<matches string="${build.os.prefix}" pattern="-aarch64$"/>
</condition>
<condition property="ARCH" value="x86">
<equals arg1="${os.prefix}" arg2="android-x86"/>
<equals arg1="${build.os.prefix}" arg2="android-x86"/>
</condition>
<condition property="ARCH" value="x86-64">
<equals arg1="${os.prefix}" arg2="android-x86-64"/>
<equals arg1="${build.os.prefix}" arg2="android-x86-64"/>
</condition>
<condition property="ARCH" value="mips">
<equals arg1="${os.prefix}" arg2="android-mips"/>
<equals arg1="${build.os.prefix}" arg2="android-mips"/>
</condition>
<condition property="ARCH" value="mips64">
<equals arg1="${os.prefix}" arg2="android-mips64"/>
<equals arg1="${build.os.prefix}" arg2="android-mips64"/>
</condition>
<condition property="ARCH" value="ppc">
<equals arg1="${os.prefix}" arg2="aix-ppc"/>
<equals arg1="${build.os.prefix}" arg2="aix-ppc"/>
</condition>
<condition property="ARCH" value="ppc64">
<equals arg1="${os.prefix}" arg2="aix-ppc64"/>
<equals arg1="${build.os.prefix}" arg2="aix-ppc64"/>
</condition>
<!-- ensure ARCH is set properly for 64-bit capable platforms -->
<!-- use ANT_OPTS=-d64/-d32 to build 64-bit/32-bit if not the platform default -->
Expand All @@ -919,45 +934,51 @@ osname=macosx;processor=x86;processor=x86-64;processor=ppc
<isset property="SDKROOT"/>
</condition>
<property name="xcode" value="/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform"/>
<condition property="make.SDKROOT" value="SDKROOT=${xcode}/Developer/SDKs/MacOSX11.0.sdk">
<and>
<equals arg1="${build.os.prefix}" arg2="darwin-aarch64" trim="true"/>
<available file="${xcode}/Developer/SDKs/MacOSX11.0.sdk"/>
</and>
</condition>
<condition property="make.SDKROOT"
value="SDKROOT=${xcode}/Developer/SDKs/MacOSX10.11.sdk">
<and>
<equals arg1="${os.prefix}" arg2="darwin" trim="true"/>
<equals arg1="${build.os.prefix}" arg2="darwin-intel" trim="true"/>
<available file="${xcode}/Developer/SDKs/MacOSX10.11.sdk"/>
</and>
</condition>
<condition property="make.SDKROOT"
value="SDKROOT=${xcode}/Developer/SDKs/MacOSX10.9.sdk">
<and>
<equals arg1="${os.prefix}" arg2="darwin" trim="true"/>
<equals arg1="${build.os.prefix}" arg2="darwin-intel" trim="true"/>
<available file="${xcode}/Developer/SDKs/MacOSX10.9.sdk"/>
</and>
</condition>
<condition property="make.SDKROOT"
value="SDKROOT=${xcode}/Developer/SDKs/MacOSX10.8.sdk">
<and>
<equals arg1="${os.prefix}" arg2="darwin" trim="true"/>
<equals arg1="${build.os.prefix}" arg2="darwin-intel" trim="true"/>
<available file="${xcode}/Developer/SDKs/MacOSX10.8.sdk"/>
</and>
</condition>
<condition property="make.SDKROOT"
value="SDKROOT=/Developer/SDKs/MacOSX10.6.sdk">
<and>
<equals arg1="${os.prefix}" arg2="darwin" trim="true"/>
<equals arg1="${build.os.prefix}" arg2="darwin-intel" trim="true"/>
<available file="/Developer/SDKs/MacOSX10.6.sdk"/>
</and>
</condition>
<condition property="make.SDKROOT"
value="SDKROOT=/Developer/SDKs/MacOSX10.5.sdk">
<and>
<equals arg1="${os.prefix}" arg2="darwin" trim="true"/>
<equals arg1="${build.os.prefix}" arg2="darwin-intel" trim="true"/>
<available file="/Developer/SDKs/MacOSX10.5.sdk"/>
</and>
</condition>
<condition property="make.SDKROOT"
value="SDKROOT=/Developer/SDKs/MacOSX10.4u.sdk" else="IGNORE=">
<and>
<equals arg1="${os.prefix}" arg2="darwin" trim="true"/>
<equals arg1="${build.os.prefix}" arg2="darwin-intel" trim="true"/>
<available file="/Developer/SDKs/MacOSX10.4u.sdk"/>
</and>
</condition>
Expand Down Expand Up @@ -1074,17 +1095,7 @@ cd ..
<arg value="JNA_JNI_VERSION=${jni.version}"/>
<arg value="CHECKSUM=${jni.md5}"/>
</exec>
<mkdir dir="${classes}/${native.path}"/>
<copy todir="${classes}/${native.path}">
<fileset dir="${build.native}"
includes="jnidispatch.dll,libjnidispatch.*"/>
</copy>
<mkdir dir="${eclipse.classes}/${native.path}"/>
<copy todir="${eclipse.classes}/${native.path}"
failonerror="false">
<fileset dir="${build.native}"
includes="jnidispatch.dll,libjnidispatch.*"/>
</copy>

<!-- For web start, native libraries may be provided in the root of -->
<!-- an included jar file -->
<jar jarfile="${build}/${native.jar}" createUnicodeExtraFields="never" encoding="UTF-8">
Expand All @@ -1097,6 +1108,47 @@ cd ..
<copy todir="${lib.native}">
<fileset dir="${build}" includes="${native.jar}"/>
</copy>
<condition property="is_darwin">
<equals arg1="${os.prefix}" arg2="darwin"/>
</condition>
<property name="build.native.universal" value="${build}/native-darwin-universal"/>
<delete if:set="is_darwin" dir="${build.native.universal}"/>
<copy if:set="is_darwin" todir="${build.native.universal}/intel">
<zipfileset src="${lib.native}/darwin-intel.jar" includes="*jnidispatch*" erroronmissingarchive="false"/>
</copy>
<copy if:set="is_darwin" todir="${build.native.universal}/aarch64">
<zipfileset src="${lib.native}/darwin-aarch64.jar" includes="*jnidispatch*" erroronmissingarchive="false"/>
</copy>
<exec if:set="is_darwin" executable="sh" dir="${build.native.universal}" failonerror="true" >
<arg value="-c"/>
<arg value="lipo -create -output libjnidispatch.jnilib */libjnidispatch.jnilib &amp;&amp; lipo -info libjnidispatch.jnilib"/>
</exec>
<jar if:set="is_darwin" jarfile="${build}/${os.prefix}.jar" createUnicodeExtraFields="never" encoding="UTF-8">
<fileset dir="${build}/native-${os.prefix}-universal" includes="libjnidispatch.jnilib"/>
<manifest>
<attribute name="Implementation-Version" value="${jni.version} b${jni.build}"/>
<attribute name="Specification-Version" value="${jni.version}"/>
</manifest>
</jar>
<copy if:set="is_darwin" todir="${lib.native}">
<fileset dir="${build}" includes="${os.prefix}.jar"/>
</copy>

<mkdir dir="${classes}/${native.path}"/>
<copy todir="${classes}/${native.path}">
<fileset unless:set="is_darwin" dir="${build.native}"
includes="jnidispatch.dll,libjnidispatch.*"/>
<fileset if:set="is_darwin" dir="${build}/native-${os.prefix}-universal"
includes="libjnidispatch.jnilib"/>
</copy>
<mkdir dir="${eclipse.classes}/${native.path}"/>
<copy todir="${eclipse.classes}/${native.path}"
failonerror="false">
<fileset unless:set="is_darwin" dir="${build.native}"
includes="jnidispatch.dll,libjnidispatch.*"/>
<fileset if:set="is_darwin" dir="${build}/native-${os.prefix}-universal"
includes="libjnidispatch.jnilib"/>
</copy>
</target>

<target name="compile-some-tests" depends="compile,jar"
Expand Down
Binary file added lib/native/darwin-aarch64.jar
Binary file not shown.
Binary file added lib/native/darwin-intel.jar
Binary file not shown.
Binary file modified lib/native/darwin.jar
Binary file not shown.
Loading