# # Copyright OpenSearch Contributors # SPDX-License-Identifier: Apache-2.0 # git submodule update --init -- jni/external/nmslib git submodule update --init -- jni/external/faiss # _MSC_VER is a predefined macro which defines the version of Visual Studio Compiler # As we are using x86_64-w64-mingw32-gcc compiler we need to replace this macro with __MINGW32__ (Get-Content jni/external/faiss/faiss/impl/index_read.cpp).replace('_MSC_VER', '__MINGW32__') | Set-Content jni/external/faiss/faiss/impl/index_read.cpp (Get-Content jni/external/faiss/faiss/impl/index_write.cpp).replace('_MSC_VER', '__MINGW32__') | Set-Content jni/external/faiss/faiss/impl/index_write.cpp (Get-Content jni/external/faiss/faiss/impl/platform_macros.h).replace('_MSC_VER', '__MINGW32__') | Set-Content jni/external/faiss/faiss/impl/platform_macros.h (Get-Content jni/external/faiss/faiss/impl/platform_macros.h).replace('#define __PRETTY_FUNCTION__ __FUNCSIG__', ' ') | Set-Content jni/external/faiss/faiss/impl/platform_macros.h (Get-Content jni/external/faiss/faiss/utils/utils.cpp).replace('_MSC_VER', '__MINGW32__') | Set-Content jni/external/faiss/faiss/utils/utils.cpp (Get-Content jni/external/faiss/faiss/utils/prefetch.h).replace('_MSC_VER', '__MINGW32__') | Set-Content jni/external/faiss/faiss/utils/prefetch.h (Get-Content jni/external/faiss/faiss/invlists/InvertedListsIOHook.cpp).replace('_MSC_VER', '__MINGW32__') | Set-Content jni/external/faiss/faiss/invlists/InvertedListsIOHook.cpp (Get-Content jni/external/faiss/faiss/AutoTune.cpp).replace('__PRETTY_FUNCTION__', 'NULL') | Set-Content jni/external/faiss/faiss/AutoTune.cpp (Get-Content jni/external/faiss/faiss/utils/distances_simd.cpp).replace('FAISS_PRAGMA_IMPRECISE_FUNCTION_BEGIN', ' ') | Set-Content jni/external/faiss/faiss/utils/distances_simd.cpp (Get-Content jni/external/faiss/faiss/utils/distances_simd.cpp).replace('FAISS_PRAGMA_IMPRECISE_FUNCTION_END', ' ') | Set-Content jni/external/faiss/faiss/utils/distances_simd.cpp # is a Unix header and is not available on Windows. So, adding condition to include it if not running on Windows # Replace '#include ' with # #ifndef __MINGW32__ # #include # #endif (Get-Content jni/external/faiss/faiss/OnDiskInvertedLists.cpp).replace('#include ', "#ifndef __MINGW32__`n#include `n#endif") | Set-Content jni/external/faiss/faiss/OnDiskInvertedLists.cpp # intrin.h function like __builtin_ctz, __builtin_clzll is not available in MINGW32. So, adding condition to include it if not running on Windows # Replace '#include ' with # #ifndef __MINGW32__ # include # and # Closing the above #ifndef with # #define __builtin_popcountl __popcnt64 # #endif (Get-Content jni/external/faiss/faiss/impl/platform_macros.h).replace('#include ', "#ifndef __MINGW32__`n#include `n") | Set-Content jni/external/faiss/faiss/impl/platform_macros.h (Get-Content jni/external/faiss/faiss/impl/platform_macros.h).replace('#define __builtin_popcountl __popcnt64', "#define __builtin_popcountl __popcnt64`n#endif`n") | Set-Content jni/external/faiss/faiss/impl/platform_macros.h