mirror of
https://github.com/status-im/xgo.git
synced 2025-01-14 12:55:11 +00:00
Skip android aar builds if no API header is available.
This commit is contained in:
parent
60aa71bb38
commit
8c6a1b73ab
@ -260,34 +260,39 @@ for TARGET in $TARGETS; do
|
|||||||
|
|
||||||
# Generate the JNI wrappers automatically with SWIG
|
# Generate the JNI wrappers automatically with SWIG
|
||||||
jni=`mktemp -d`
|
jni=`mktemp -d`
|
||||||
cp `find /build-android-aar | grep '\.h$' | head -n 1` $jni/$NAME.h
|
header=`find /build-android-aar | grep '\.h$' | head -n 1`
|
||||||
sed -i -e 's|__complex|complex|g' $jni/$NAME.h
|
if [ "$header" == "" ]; then
|
||||||
sed -i -e 's|_Complex|complex|g' $jni/$NAME.h
|
echo "No API C header specified, skipping android-$PLATFORM/aar..."
|
||||||
echo -e "%module $title\n%{\n#include \"$NAME.h\"\n%}\n%pragma(java) jniclasscode=%{\nstatic {\nSystem.loadLibrary(\"$NAME\");\n}\n%}\n%include \"$NAME.h\"" > $jni/$NAME.i
|
else
|
||||||
|
cp $header $jni/$NAME.h
|
||||||
|
sed -i -e 's|__complex|complex|g' $jni/$NAME.h
|
||||||
|
sed -i -e 's|_Complex|complex|g' $jni/$NAME.h
|
||||||
|
echo -e "%module $title\n%{\n#include \"$NAME.h\"\n%}\n%pragma(java) jniclasscode=%{\nstatic {\nSystem.loadLibrary(\"$NAME\");\n}\n%}\n%include \"$NAME.h\"" > $jni/$NAME.i
|
||||||
|
|
||||||
mkdir -p $jni/${package//.//}
|
mkdir -p $jni/${package//.//}
|
||||||
swig -java -package $package -outdir $jni/${package//.//} $jni/$NAME.i
|
swig -java -package $package -outdir $jni/${package//.//} $jni/$NAME.i
|
||||||
|
|
||||||
# Assemble the Go static libraries and the JNI interface into shared libraries
|
# Assemble the Go static libraries and the JNI interface into shared libraries
|
||||||
for lib in `find /build-android-aar | grep '\.so$'`; do
|
for lib in `find /build-android-aar | grep '\.so$'`; do
|
||||||
if [[ "$lib" = *-arm.so ]]; then cc=arm-linux-androideabi-gcc; abi="armeabi-v7a"; fi
|
if [[ "$lib" = *-arm.so ]]; then cc=arm-linux-androideabi-gcc; abi="armeabi-v7a"; fi
|
||||||
if [[ "$lib" = *-arm64.so ]]; then cc=aarch64-linux-android-gcc; abi="arm64-v8a"; fi
|
if [[ "$lib" = *-arm64.so ]]; then cc=aarch64-linux-android-gcc; abi="arm64-v8a"; fi
|
||||||
if [[ "$lib" = *-386.so ]]; then cc=i686-linux-android-gcc; abi="x86"; fi
|
if [[ "$lib" = *-386.so ]]; then cc=i686-linux-android-gcc; abi="x86"; fi
|
||||||
|
|
||||||
mkdir -p $archive/jni/$abi
|
mkdir -p $archive/jni/$abi
|
||||||
cp ${lib%.*}.h $jni/${NAME}.h
|
cp ${lib%.*}.h $jni/${NAME}.h
|
||||||
cp $lib $archive/jni/$abi/lib${NAME}raw.so
|
cp $lib $archive/jni/$abi/lib${NAME}raw.so
|
||||||
(cd $archive/jni/$abi && $cc -shared -fPIC -o lib${NAME}.so -I"$ANDROID_NDK_LIBC/include" -I"$ANDROID_NDK_LIBC/libs/$abi/include" -I"$jni" lib${NAME}raw.so $jni/${NAME}_wrap.c)
|
(cd $archive/jni/$abi && $cc -shared -fPIC -o lib${NAME}.so -I"$ANDROID_NDK_LIBC/include" -I"$ANDROID_NDK_LIBC/libs/$abi/include" -I"$jni" lib${NAME}raw.so $jni/${NAME}_wrap.c)
|
||||||
done
|
done
|
||||||
|
|
||||||
# Compile the Java wrapper and assemble into a .jar file
|
# Compile the Java wrapper and assemble into a .jar file
|
||||||
mkdir -p $jni/build
|
mkdir -p $jni/build
|
||||||
javac -cp . -d $jni/build $jni/${package//.//}/*.java
|
javac -cp . -d $jni/build $jni/${package//.//}/*.java
|
||||||
(cd $jni/build && jar cvf $archive/classes.jar *)
|
(cd $jni/build && jar cvf $archive/classes.jar *)
|
||||||
|
|
||||||
# Finally assemble the archive contents into an .aar and clean up
|
# Finally assemble the archive contents into an .aar and clean up
|
||||||
(cd $archive && zip -r $bundle *)
|
(cd $archive && zip -r $bundle *)
|
||||||
rm -rf $jni $archive
|
rm -rf $jni $archive
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
# Clean up the android builds, toolchains and runtimes
|
# Clean up the android builds, toolchains and runtimes
|
||||||
rm -rf /build-android-aar
|
rm -rf /build-android-aar
|
||||||
|
Loading…
x
Reference in New Issue
Block a user