From 105ae49b0194bb3f41fb6aafe2cbac65ce6fdcc6 Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Sun, 13 Sep 2020 15:51:12 +0200 Subject: [PATCH] Build non-SIMD versions of Stockfish engine Will be used for CPUs that don't support the best SIMD instructions. --- DroidFishApp/build.gradle | 1 + .../src/main/cpp/stockfish/Android.mk | 22 ++++++++++++++----- .../src/main/cpp/stockfish/build_sf.mk | 5 +++++ 3 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 DroidFishApp/src/main/cpp/stockfish/build_sf.mk diff --git a/DroidFishApp/build.gradle b/DroidFishApp/build.gradle index 7a7171b..45986e6 100644 --- a/DroidFishApp/build.gradle +++ b/DroidFishApp/build.gradle @@ -78,6 +78,7 @@ preBuild.dependsOn buildEco task copyToAssets(type: Copy, dependsOn: 'externalNativeBuildRelease') { from('build/intermediates/ndkBuild/release/obj/local') { include '*/stockfish' + include '*/stockfish_nosimd' } into 'src/main/assets' } diff --git a/DroidFishApp/src/main/cpp/stockfish/Android.mk b/DroidFishApp/src/main/cpp/stockfish/Android.mk index da13c07..7a83390 100644 --- a/DroidFishApp/src/main/cpp/stockfish/Android.mk +++ b/DroidFishApp/src/main/cpp/stockfish/Android.mk @@ -23,8 +23,20 @@ endif include $(CLEAR_VARS) LOCAL_MODULE := stockfish -LOCAL_SRC_FILES := $(SF_SRC_FILES) -LOCAL_CFLAGS := -std=c++17 -O2 -fno-exceptions -DNNUE_EMBEDDING_OFF \ - -fPIE $(MY_ARCH_DEF) -s -LOCAL_LDFLAGS += -fPIE -pie -s -include $(BUILD_EXECUTABLE) +include $(LOCAL_PATH)/build_sf.mk + +ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) + MY_ARCH_DEF := + include $(CLEAR_VARS) + LOCAL_MODULE := stockfish_nosimd + include $(LOCAL_PATH)/build_sf.mk + stockfish : stockfish_nosimd +endif + +ifeq ($(TARGET_ARCH_ABI),x86) + MY_ARCH_DEF := + include $(CLEAR_VARS) + LOCAL_MODULE := stockfish_nosimd + include $(LOCAL_PATH)/build_sf.mk + stockfish : stockfish_nosimd +endif diff --git a/DroidFishApp/src/main/cpp/stockfish/build_sf.mk b/DroidFishApp/src/main/cpp/stockfish/build_sf.mk new file mode 100644 index 0000000..b7f06a9 --- /dev/null +++ b/DroidFishApp/src/main/cpp/stockfish/build_sf.mk @@ -0,0 +1,5 @@ +LOCAL_SRC_FILES := $(SF_SRC_FILES) +LOCAL_CFLAGS := -std=c++17 -O2 -fno-exceptions -DNNUE_EMBEDDING_OFF \ + -fPIE $(MY_ARCH_DEF) -s +LOCAL_LDFLAGS += -fPIE -pie -s +include $(BUILD_EXECUTABLE)