Skip to content

Commit 29024cf

Browse files
committed
WASM support
1 parent ce163e7 commit 29024cf

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ file(GLOB_RECURSE
3232
)
3333

3434
# Build and install Entity library
35-
add_library(LangulusEntity ${LANGULUS_LIBRARY_TYPE}
35+
add_langulus_library(LangulusEntity
3636
$<TARGET_OBJECTS:LangulusLogger>
3737
$<TARGET_OBJECTS:LangulusRTTI>
3838
$<$<BOOL:${LANGULUS_FEATURE_MANAGED_MEMORY}>:$<TARGET_OBJECTS:LangulusFractalloc>>

source/Runtime.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <Windows.h>
2727
#endif
2828

29-
#if LANGULUS_OS(LINUX)
29+
#if LANGULUS_OS(LINUX) or LANGULUS_COMPILER(WASM)
3030
#include <dlfcn.h>
3131
#endif
3232

@@ -64,12 +64,10 @@ namespace Langulus::Entity
6464
void UnloadSharedLibrary(HMODULE library) {
6565
FreeLibrary(library);
6666
}
67-
#elif LANGULUS_OS(LINUX)
67+
#else
6868
void UnloadSharedLibrary(void* library) {
6969
dlclose(library);
7070
}
71-
#else
72-
#error Unsupported OS
7371
#endif
7472

7573
/// Runtime construction
@@ -356,6 +354,8 @@ namespace Langulus::Entity
356354
path += ".dll";
357355
#elif LANGULUS_OS(LINUX)
358356
path += ".so";
357+
#elif LANGULUS_COMPILER(WASM)
358+
path += ".wasm";
359359
#else
360360
#error Unsupported OS
361361
#endif
@@ -366,10 +366,8 @@ namespace Langulus::Entity
366366
// Load the library
367367
#if LANGULUS_OS(WINDOWS)
368368
const auto dll = LoadLibraryA(path.GetRaw());
369-
#elif LANGULUS_OS(LINUX)
369+
#else
370370
const auto dll = dlopen(path.GetRaw(), RTLD_NOW);
371-
#else
372-
#error Unsupported OS
373371
#endif
374372

375373
if (not dll) {
@@ -395,35 +393,33 @@ namespace Langulus::Entity
395393
GetProcAddress(dll, LANGULUS_MODULE_CREATE_TOKEN()));
396394
library.mInfo = reinterpret_cast<A::Module::InfoFunction>(
397395
GetProcAddress(dll, LANGULUS_MODULE_INFO_TOKEN()));
398-
#elif LANGULUS_OS(LINUX)
396+
#else
399397
library.mEntry = reinterpret_cast<A::Module::EntryFunction>(
400398
dlsym(dll, LANGULUS_MODULE_ENTRY_TOKEN()));
401399
library.mCreator = reinterpret_cast<A::Module::CreateFunction>(
402400
dlsym(dll, LANGULUS_MODULE_CREATE_TOKEN()));
403401
library.mInfo = reinterpret_cast<A::Module::InfoFunction>(
404402
dlsym(dll, LANGULUS_MODULE_INFO_TOKEN()));
405-
#else
406-
#error Unsupported OS
407403
#endif
408404

409405
if (not library.mEntry) {
410406
Logger::Error("Module `", path, "` has no valid entry point - ",
411407
"the function " LANGULUS_MODULE_ENTRY_TOKEN() " is missing");
412-
(void)UnloadSharedLibrary(library);
408+
(void) UnloadSharedLibrary(library);
413409
return {};
414410
}
415411

416412
if (not library.mCreator) {
417413
Logger::Error("Module `", path, "` has no valid instantiation point - ",
418414
"the function " LANGULUS_MODULE_CREATE_TOKEN() " is missing");
419-
(void)UnloadSharedLibrary(library);
415+
(void) UnloadSharedLibrary(library);
420416
return {};
421417
}
422418

423419
if (not library.mInfo) {
424420
Logger::Error("Module `", path, "` has no valid information point - ",
425421
"the function " LANGULUS_MODULE_INFO_TOKEN() " is missing");
426-
(void)UnloadSharedLibrary(library);
422+
(void) UnloadSharedLibrary(library);
427423
return {};
428424
}
429425

@@ -568,11 +564,9 @@ namespace Langulus::Entity
568564
#if LANGULUS_OS(WINDOWS)
569565
Entity::UnloadSharedLibrary(
570566
reinterpret_cast<HMODULE>(library.mHandle));
571-
#elif LANGULUS_OS(LINUX)
567+
#else
572568
Entity::UnloadSharedLibrary(
573569
reinterpret_cast<void*>(library.mHandle));
574-
#else
575-
#error Unsupported OS
576570
#endif
577571
return true;
578572
}

0 commit comments

Comments
 (0)