Skip to content

Commit

Permalink
Add: WASM binding for USearch C API
Browse files Browse the repository at this point in the history
  • Loading branch information
DarvinHarutyunyan committed Jul 18, 2023
1 parent 42d939c commit dd768c6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,7 @@ endif()
if(${USEARCH_BUILD_WOLFRAM})
add_subdirectory(wolfram)
endif()

if(${USEARCH_BUILD_WASM})
add_subdirectory(wasm)
endif()
15 changes: 15 additions & 0 deletions wasm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
include(emscripten)

set(CMAKE_CXX_COMPILER em++)
set(CMAKE_C_COMPILER emcc)

set(USEARCH_PUNNED_INCLUDE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}/../c"
"${CMAKE_CURRENT_SOURCE_DIR}/../include"
"${CMAKE_CURRENT_SOURCE_DIR}/../fp16/include"
"${CMAKE_CURRENT_SOURCE_DIR}/../robin-map/include"
)

add_executable(index lib.cpp)
target_include_directories(index PRIVATE ${USEARCH_PUNNED_INCLUDE_DIRS})
set_target_properties(index PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
5 changes: 5 additions & 0 deletions wasm/lib.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#define EXPORT EMSCRIPTEN_KEEPALIVE

#include <emscripten/emscripten.h>

#include <lib.cpp>

0 comments on commit dd768c6

Please sign in to comment.