Skip to content

Commit d388713

Browse files
committed
build: fall back to libcxx for android stl
1 parent 8d59e0e commit d388713

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

.github/workflows/build-android-arm64.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,26 @@ jobs:
8484
run: |
8585
set -e
8686
STL_ROOT="tfjava/tensorflow-core/tensorflow-core-api/android-gnu-stl"
87+
NDK_ROOT="${ANDROID_SDK_ROOT}/ndk/${ANDROID_NDK_VERSION}"
8788
rm -rf "${STL_ROOT}"
8889
mkdir -p "${STL_ROOT}/include" "${STL_ROOT}/arm64-v8a/include"
89-
cp -R "${ANDROID_SDK_ROOT}/ndk/${ANDROID_NDK_VERSION}/sources/cxx-stl/gnu-libstdc++/4.9/include/." "${STL_ROOT}/include/"
90-
cp -R "${ANDROID_SDK_ROOT}/ndk/${ANDROID_NDK_VERSION}/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/include/." "${STL_ROOT}/arm64-v8a/include/"
90+
if [ -d "${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/4.9/include" ]; then
91+
cp -R "${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/4.9/include/." "${STL_ROOT}/include/"
92+
if [ -d "${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/include" ]; then
93+
cp -R "${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/include/." "${STL_ROOT}/arm64-v8a/include/"
94+
fi
95+
cp "${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/libgnustl_static.a" "${STL_ROOT}/arm64-v8a/libgnustl_static.a"
96+
else
97+
cp -R "${NDK_ROOT}/sources/cxx-stl/llvm-libc++/include/." "${STL_ROOT}/include/"
98+
if [ -d "${NDK_ROOT}/sources/cxx-stl/llvm-libc++abi/include" ]; then
99+
cp -R "${NDK_ROOT}/sources/cxx-stl/llvm-libc++abi/include/." "${STL_ROOT}/include/"
100+
fi
101+
if [ -d "${NDK_ROOT}/sources/android/support/include" ]; then
102+
cp -R "${NDK_ROOT}/sources/android/support/include/." "${STL_ROOT}/include/"
103+
fi
104+
cp "${NDK_ROOT}/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_static.a" "${STL_ROOT}/arm64-v8a/libgnustl_static.a"
105+
fi
106+
find "${STL_ROOT}" -maxdepth 3 -type f | sort | sed -n '1,20p'
91107
92108
- name: Write TensorFlow Configure Overrides
93109
shell: bash

scripts/patch_tfjava.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ def patch_module_pom(path: Path) -> None:
2323
old = """ <includePaths>\n <includePath>${project.basedir}/</includePath>\n <includePath>${project.basedir}/bazel-${project.artifactId}/external/org_tensorflow/</includePath>\n </includePaths>\n"""
2424
new = """ <includePaths>\n <includePath>${project.basedir}/</includePath>\n <includePath>${project.basedir}/bazel-${project.artifactId}/external/org_tensorflow/</includePath>\n <includePath>${project.basedir}/android-gnu-stl/include</includePath>\n <includePath>${project.basedir}/android-gnu-stl/arm64-v8a/include</includePath>\n </includePaths>\n"""
2525
text = replace_once(text, old, new, path)
26+
if "<linkPath>${project.basedir}/android-gnu-stl/arm64-v8a</linkPath>" not in text:
27+
old = """ <linkPaths>\n <linkPath>${project.basedir}/bazel-bin/external/org_tensorflow/tensorflow/</linkPath>\n </linkPaths>\n"""
28+
new = """ <linkPaths>\n <linkPath>${project.basedir}/bazel-bin/external/org_tensorflow/tensorflow/</linkPath>\n <linkPath>${project.basedir}/android-gnu-stl/arm64-v8a</linkPath>\n </linkPaths>\n"""
29+
text = replace_once(text, old, new, path)
2630
path.write_text(text, encoding="utf-8")
2731

2832

0 commit comments

Comments
 (0)