Not-quite-working WASM

This commit is contained in:
Alex 2022-01-24 21:43:57 +00:00
parent 91bfff1a35
commit e40a743dac
2 changed files with 15 additions and 3 deletions

View File

@ -5,5 +5,14 @@ set(SRC
skinny_reference.c
)
add_library(romulus-m SHARED ${SRC})
install(TARGETS romulus-m)
if(EMSCRIPTEN)
# WASM requires an executable, so we use a dummy target that doesn't do anything
# and link our library into it.
add_library(romulus-m STATIC ${SRC})
add_executable(romulus-m-wasm "main.c")
target_link_libraries(romulus-m-wasm PRIVATE romulus-m)
target_link_options(romulus-m-wasm PRIVATE -s EXPORTED_FUNCTIONS=['_main', '_crypto_aead_encrypt', '_crypto_aead_decrypt'])
else()
add_library(romulus-m SHARED ${SRC})
install(TARGETS romulus-m)
endif()

View File

@ -8,6 +8,9 @@
#ifdef _WIN32
#define EXPORT __declspec(dllexport)
#else
#elif __linux__
#define EXPORT __attribute__((visibility("default")))
#elif __EMSCRIPTEN__
#include <emscripten.h>
#define EXPORT EMSCRIPTEN_KEEPALIVE
#endif