Skip to content

Commit

Permalink
fix emscripten test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
bha-evs committed Feb 28, 2024
1 parent 02d1c6d commit c297dbc
Show file tree
Hide file tree
Showing 16 changed files with 328 additions and 225 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ option(BOFSTD_ENABLE_VERSIONING "Enable library versioning naming scheme for Bof
option(BOFSTD_FORCE_EXPORT_ALL "Force exporting all symbols of BofStd libraries (for shared library)" OFF)
#EMSCRIPTEN
option(EMSCRIPTEN_GEN_HTML "EMSCRIPTEN generateq .wasm and .js file. If you set this option to ON we also generate an html container" OFF)
set(BOFSTD_EMSCRIPTEN_MEMORY 256MB CACHE STRING "Specify emscripten default memory size")
set(BOFSTD_EMSCRIPTEN_MEMORY 512MB CACHE STRING "Specify emscripten default memory size")
message("emscripten default memory size: ${BOFSTD_EMSCRIPTEN_MEMORY}")
set(BOFSTD_EMSCRIPTEN_STACK 8MB CACHE STRING "Specify emscripten default stack size")
message("emscripten default stack size: ${BOFSTD_EMSCRIPTEN_STACK}")
Expand Down Expand Up @@ -132,11 +132,11 @@ if (EMSCRIPTEN)
message("===EMSCRIPTEN=== Generate .wasm and .js files")
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread -fwasm-exceptions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -fwasm-exceptions")

#The @ symbol is needed because sometimes it is useful to package files that are not nested below the compile-time directory, and for which #there is therefore no default mapping to a location in the virtual file system.
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s TOTAL_STACK=${BOFSTD_EMSCRIPTEN_STACK} -s TOTAL_MEMORY=${BOFSTD_EMSCRIPTEN_MEMORY} -s PTHREAD_POOL_SIZE=${BOFSTD_EMSCRIPTEN_THREAD_POOL} --embed-file ${BOFSTD_EMSCRIPTEN_FS_SRC_ROOT_DIR}@${BOFSTD_EMSCRIPTEN_FS_DST_ROOT_DIR}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fwasm-exceptions -s TOTAL_STACK=${BOFSTD_EMSCRIPTEN_STACK} -s TOTAL_MEMORY=${BOFSTD_EMSCRIPTEN_MEMORY} -s PTHREAD_POOL_SIZE=${BOFSTD_EMSCRIPTEN_THREAD_POOL} --embed-file ${BOFSTD_EMSCRIPTEN_FS_SRC_ROOT_DIR}@${BOFSTD_EMSCRIPTEN_FS_DST_ROOT_DIR}")
#-sPROXY_TO_PTHREAD not good for imgui car je pense qu'on est dans un autre thread entre imgui et le main...
#-s ASYNCIFY (very long and sometime forever)
message("===EMSCRIPTEN=== CMAKE_EXE_LINKER_FLAGS is ${CMAKE_EXE_LINKER_FLAGS}")
Expand Down
7 changes: 6 additions & 1 deletion lib/src/bofbuffer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <bofstd/bofbuffer.h>
#include <bofstd/bofbit.h>
#include <bofstd/bofbuffer.h>


#include <fcntl.h>
#if defined(_WIN32)
Expand Down Expand Up @@ -36,8 +37,12 @@ BOFERR Bof_AlignedMemAlloc(BOF_BUFFER_ALLOCATE_ZONE _AllocateZone_E, uint32_t _A
case BOF_BUFFER_ALLOCATE_ZONE::BOF_BUFFER_ALLOCATE_ZONE_RAM:
#if defined(_WIN32)
_rAllocatedBuffer_X.pData_U8 = reinterpret_cast<uint8_t *>(_aligned_malloc(_SizeInByte_U32, _AligmentInByte_U32)); // malloc(size); // TODO pChannel->getBoard()->getNUMANode() !!!
#else
#if defined(EMSCRIPTEN)
_rAllocatedBuffer_X.pData_U8 = reinterpret_cast<uint8_t *>(memalign(_AligmentInByte_U32, _SizeInByte_U32));
#else
_rAllocatedBuffer_X.pData_U8 = reinterpret_cast<uint8_t *>(aligned_alloc(_AligmentInByte_U32, _SizeInByte_U32)); // malloc(size); // TODO pChannel->getBoard()->getNUMANode() !!!
#endif
#endif
break;

Expand Down
13 changes: 6 additions & 7 deletions lib/src/bofpath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ BofPath::BofPath(const char *_pPath_c, const char *_pForbiddenChar_c, bool _Pure
if (_pPath_c)
{
Path_S = _pPath_c;
InitPathField(_pForbiddenChar_c, _PureFilename_B, Path_S);
InitPathField(_pForbiddenChar_c, _PureFilename_B, Path_S);
}
else
{
Expand Down Expand Up @@ -351,14 +351,14 @@ BOFERR BofPath::CurrentDirectoryName(const std::string &_rNewCurrentDirectoryNam
return Rts_E;
}

BOFERR BofPath::InitPathField(const char *_pForbiddenChar_c, bool _PureFilename_B,const std::string &_rPath_S)
BOFERR BofPath::InitPathField(const char *_pForbiddenChar_c, bool _PureFilename_B, const std::string &_rPath_S)
{
BOFERR Rts_E;
char LastChar_c;
std::string ThePath_S;
std::string::size_type ExtensionPos, FilenamePos;

mForbiddenCharacter_S = _pForbiddenChar_c ? _pForbiddenChar_c:"<>:\"\\|?*\a\f\n\r\t\v";
mForbiddenCharacter_S = _pForbiddenChar_c ? _pForbiddenChar_c : "<>:\"\\|?*\a\f\n\r\t\v";
mFileNameWithExtension_S = "";
mFileNameWithoutExtension_S = "";
mExtension_S = "";
Expand Down Expand Up @@ -463,10 +463,9 @@ bool BofPath::IsWindowsDiskPath(const std::string &_rPath_S)
bool BofPath::IsForbiddenChar(const std::string &_rPath_S)
{
bool Rts_B;

#if defined(__EMSCRIPTEN__)
//During file packaging under emscripten windows we can have path like /C:/pro/...
if ((_rPath_S[0] == '/') && (_rPath_S[2] == ':') && (_rPath_S[3] == '/'))
// During file packaging under emscripten windows we can have path like /C:/pro/...
if ((_rPath_S[0] == '/') && (std::isalpha(_rPath_S[1])) && (_rPath_S[2] == ':') && (_rPath_S[3] == '/'))
{
Rts_B = Bof_StringIsPresent(_rPath_S.substr(3), mForbiddenCharacter_S);
}
Expand All @@ -475,7 +474,7 @@ bool BofPath::IsForbiddenChar(const std::string &_rPath_S)
Rts_B = Bof_StringIsPresent(_rPath_S, mForbiddenCharacter_S);
}
#else
Rts_B=Bof_StringIsPresent(_rPath_S, mForbiddenCharacter_S);
Rts_B = Bof_StringIsPresent(_rPath_S, mForbiddenCharacter_S);
#endif
return Rts_B;
}
Expand Down
Loading

0 comments on commit c297dbc

Please sign in to comment.