Skip to content

Commit 016c90a

Browse files
committed
Simulation: have simulation tasks run in their own thread.
1 parent b757449 commit 016c90a

48 files changed

Lines changed: 2540 additions & 461 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎cmake/buildpackage.cmake.in‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ project(@PACKAGE_NAME@)
1818

1919
include(ExternalProject)
2020

21-
ExternalProject_Add(@PACKAGE_NAME@ @ARGN@)
21+
ExternalProject_Add(@PACKAGE_NAME@ @ARGN_QUOTED@)

‎cmake/common.cmake‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ function(configure_target TARGET)
108108
-Wno-global-constructors
109109
-Wno-padded
110110
-Wno-switch-enum
111+
-Wno-thread-safety-negative
111112
-Wno-unsafe-buffer-usage
112113
-Wno-weak-vtables
113114
)

‎cmake/packages.cmake‎

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,21 @@ function(build_package PACKAGE_NAME)
5757

5858
message(STATUS "Building ${PACKAGE_NAME}")
5959

60+
set(ARGN_QUOTED)
61+
62+
foreach(ARG ${ARGN})
63+
string(REPLACE "\\" "\\\\" ARG_ESCAPED "${ARG}")
64+
string(REPLACE "\"" "\\\"" ARG_ESCAPED "${ARG_ESCAPED}")
65+
66+
if(NOT WIN32)
67+
string(REPLACE " " "\\ " ARG_ESCAPED "${ARG_ESCAPED}")
68+
endif()
69+
70+
list(APPEND ARGN_QUOTED "\"${ARG_ESCAPED}\"")
71+
endforeach()
72+
73+
string(REPLACE ";" " " ARGN_QUOTED "${ARGN_QUOTED}")
74+
6075
configure_file(${CMAKE_SOURCE_DIR}/cmake/buildpackage.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.txt)
6176

6277
if(EMSCRIPTEN)
@@ -263,8 +278,15 @@ function(retrieve_package PACKAGE_NAME PACKAGE_VERSION PACKAGE_REPOSITORY RELEAS
263278
add_custom_target(${PACKAGE_NAME})
264279
endfunction()
265280

266-
function(escape_path OLD_PATH NEW_PATH)
267-
# Escape spaces and parentheses in a path.
281+
function(safe_path OLD_PATH NEW_PATH)
282+
# Make a path safe for use in CMake arguments by double quoting it on Windows and by escaping spaces and parentheses
283+
# on Linux and macOS.
284+
285+
if(WIN32)
286+
set(${NEW_PATH} "${OLD_PATH}" PARENT_SCOPE)
287+
288+
return()
289+
endif()
268290

269291
string(REPLACE " " "\\ " NEW_PATH_VALUE "${OLD_PATH}")
270292
string(REPLACE "(" "\\(" NEW_PATH_VALUE "${NEW_PATH_VALUE}")
@@ -276,7 +298,7 @@ endfunction()
276298
# Determine the platform on which we are and the architecture on which we want to build.
277299

278300
if(EMSCRIPTEN)
279-
set(TARGET_PLATFORM_ARCHITECTURE wasm)
301+
set(TARGET_PLATFORM_ARCHITECTURE wasm-threaded) #---GRY--- This should eventually be renamed to just "wasm" once we are done with running simulations in their own thread.
280302
else()
281303
if(WIN32)
282304
if(RELEASE_MODE)
@@ -336,8 +358,8 @@ if(APPLE)
336358
endif()
337359

338360
if(CMAKE_C_COMPILER_LAUNCHER AND CMAKE_CXX_COMPILER_LAUNCHER)
339-
escape_path(${CMAKE_C_COMPILER_LAUNCHER} EP_CMAKE_C_COMPILER_LAUNCHER)
340-
escape_path(${CMAKE_CXX_COMPILER_LAUNCHER} EP_CMAKE_CXX_COMPILER_LAUNCHER)
361+
safe_path(${CMAKE_C_COMPILER_LAUNCHER} EP_CMAKE_C_COMPILER_LAUNCHER)
362+
safe_path(${CMAKE_CXX_COMPILER_LAUNCHER} EP_CMAKE_CXX_COMPILER_LAUNCHER)
341363

342364
list(APPEND CMAKE_ARGS
343365
-DCMAKE_C_COMPILER_LAUNCHER=${EP_CMAKE_C_COMPILER_LAUNCHER}
@@ -346,13 +368,20 @@ if(CMAKE_C_COMPILER_LAUNCHER AND CMAKE_CXX_COMPILER_LAUNCHER)
346368
endif()
347369

348370
if(EMSCRIPTEN)
371+
# Note: we are using the same CMake variables that we used to build libOpenCOR so that we can build our third-party
372+
# libraries in the same way that we built libOpenCOR.
373+
349374
list(APPEND CMAKE_ARGS
350375
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
351376
-DCMAKE_CROSSCOMPILING_EMULATOR=${CMAKE_CROSSCOMPILING_EMULATOR}
377+
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
378+
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
379+
-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}
380+
-DCMAKE_SHARED_LINKER_FLAGS=${CMAKE_SHARED_LINKER_FLAGS}
352381
)
353382
else()
354-
escape_path(${CMAKE_C_COMPILER} EP_CMAKE_C_COMPILER)
355-
escape_path(${CMAKE_CXX_COMPILER} EP_CMAKE_CXX_COMPILER)
383+
safe_path(${CMAKE_C_COMPILER} EP_CMAKE_C_COMPILER)
384+
safe_path(${CMAKE_CXX_COMPILER} EP_CMAKE_CXX_COMPILER)
356385

357386
list(APPEND CMAKE_ARGS
358387
-DCMAKE_C_COMPILER=${EP_CMAKE_C_COMPILER}

‎src/3rdparty/LLVMClang/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if(LIBOPENCOR_PREBUILT_LLVMCLANG)
2424
if(EMSCRIPTEN)
2525
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
2626
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
27-
8dcd04b80f13bec0c3fa37b277d06466dcb8ac4a)
27+
4f2906d4b6df1b0be5a636a88f7582425b30df49)
2828
else()
2929
if(WIN32)
3030
if(RELEASE_MODE)

‎src/3rdparty/SUNDIALS/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if(LIBOPENCOR_PREBUILT_SUNDIALS)
2424
if(EMSCRIPTEN)
2525
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
2626
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
27-
d51821a5f6edf151e72e53ad9edb700022e44b98)
27+
770a7e84f8e986310c6ece0ed662e4ef11035c8d)
2828
else()
2929
if(WIN32)
3030
if(RELEASE_MODE)

‎src/3rdparty/libCOMBINE/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if(LIBOPENCOR_PREBUILT_LIBCOMBINE)
2828
if(EMSCRIPTEN)
2929
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
3030
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
31-
136ff852592abaaaaf4fb8ec4ad65d09850d5d0a)
31+
607e967bb9cd5bb97f285fc732dc4ca77c03e154)
3232
else()
3333
if(WIN32)
3434
if(RELEASE_MODE)

‎src/3rdparty/libCellML/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if(LIBOPENCOR_PREBUILT_LIBCELLML)
3434
if(EMSCRIPTEN)
3535
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
3636
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
37-
5cb4721d595594e82506c2b100642f34a7426e67)
37+
e4739c98f7a79436185934be1882baaaac9b314a)
3838
else()
3939
if(WIN32)
4040
if(RELEASE_MODE)

‎src/3rdparty/libNuML/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if(LIBOPENCOR_PREBUILT_LIBNUML)
2828
if(EMSCRIPTEN)
2929
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
3030
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
31-
5f3ae380ed2234c11e62cc71739cbb54455d2de9)
31+
90fcef0fdf7d2b7521816411c99c149162bdaa13)
3232
else()
3333
if(WIN32)
3434
if(RELEASE_MODE)

‎src/3rdparty/libSBML/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if(LIBOPENCOR_PREBUILT_LIBSBML)
2828
if(EMSCRIPTEN)
2929
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
3030
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
31-
54f84ef32f6a70cb7cbe6ffc4251d7762ec3c755)
31+
a5548423665edde4e2d88a9db1b15d9d4abeadb3)
3232
else()
3333
if(WIN32)
3434
if(RELEASE_MODE)

‎src/3rdparty/libSEDML/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if(LIBOPENCOR_PREBUILT_LIBSEDML)
2828
if(EMSCRIPTEN)
2929
retrieve_package(${PACKAGE_NAME} ${PACKAGE_VERSION}
3030
${PACKAGE_REPOSITORY} ${RELEASE_TAG}
31-
26f6d51198456c6efc70b94f66a5a55d2a14ef47)
31+
48270118e62002f1fbb34c88d20c57b6b38d1cdf)
3232
else()
3333
if(WIN32)
3434
if(RELEASE_MODE)

0 commit comments

Comments
 (0)