lbry-android-sdk/p4a/pythonforandroid/recipes/tflite-runtime/build_with_cmake.patch

49 lines
2 KiB
Diff
Raw Normal View History

2022-12-02 21:15:34 +01:00
--- tflite-runtime/tensorflow/lite/tools/pip_package/build_pip_package_with_cmake.sh 2022-01-22 08:57:16.000000000 -1000
+++ build_pip_package_with_cmake.sh 2022-03-02 18:19:05.185550500 -1000
@@ -28,7 +28,7 @@
export TENSORFLOW_TARGET="armhf"
fi
PYTHON_INCLUDE=$(${PYTHON} -c "from sysconfig import get_paths as gp; print(gp()['include'])")
-PYBIND11_INCLUDE=$(${PYTHON} -c "import pybind11; print (pybind11.get_include())")
+# PYBIND11_INCLUDE=$(${PYTHON} -c "import pybind11; print (pybind11.get_include())")
export CROSSTOOL_PYTHON_INCLUDE_PATH=${PYTHON_INCLUDE}
# Fix container image for cross build.
@@ -58,7 +58,7 @@
"${TENSORFLOW_LITE_DIR}/python/metrics/metrics_portable.py" \
"${BUILD_DIR}/tflite_runtime"
echo "__version__ = '${PACKAGE_VERSION}'" >> "${BUILD_DIR}/tflite_runtime/__init__.py"
-echo "__git_version__ = '$(git -C "${TENSORFLOW_DIR}" describe)'" >> "${BUILD_DIR}/tflite_runtime/__init__.py"
+echo "__git_version__ = '${PACKAGE_VERSION}'" >> "${BUILD_DIR}/tflite_runtime/__init__.py"
# Build python interpreter_wrapper.
mkdir -p "${BUILD_DIR}/cmake_build"
@@ -111,6 +111,18 @@
-DCMAKE_CXX_FLAGS="${BUILD_FLAGS}" \
"${TENSORFLOW_LITE_DIR}"
;;
+ android)
+ BUILD_FLAGS=${BUILD_FLAGS:-"${WRAPPER_INCLUDES}"}
+ cmake \
+ -DCMAKE_SYSTEM_NAME=Android \
+ -DANDROID_ARM_NEON=ON \
+ -DCMAKE_CXX_FLAGS="${BUILD_FLAGS}" \
+ -DCMAKE_SHARED_LINKER_FLAGS="${CMAKE_SHARED_LINKER_FLAGS}" \
+ -DCMAKE_TOOLCHAIN_FILE="${CMAKE_TOOLCHAIN_FILE}" \
+ -DANDROID_PLATFORM="${ANDROID_PLATFORM}" \
+ -DANDROID_ABI="${ANDROID_ABI}" \
+ "${TENSORFLOW_LITE_DIR}"
+ ;;
*)
BUILD_FLAGS=${BUILD_FLAGS:-"-I${PYTHON_INCLUDE} -I${PYBIND11_INCLUDE}"}
cmake \
@@ -162,7 +174,7 @@
${PYTHON} setup.py bdist --plat-name=${WHEEL_PLATFORM_NAME} \
bdist_wheel --plat-name=${WHEEL_PLATFORM_NAME}
else
- ${PYTHON} setup.py bdist bdist_wheel
+ ${PYTHON} setup.py bdist
fi
;;
esac