split wasm_to_py from wasm_to_js

- disable wasm_to_js which needs pthread and boost headers
This commit is contained in:
Jules BOURDAIS 2024-12-06 13:29:23 +01:00
parent 833235848b
commit fa8979eb56
8 changed files with 95 additions and 96 deletions

View File

@ -69,7 +69,8 @@ IF(SALOME_BUILD_GUI)
ENDIF(SALOME_BUILD_GUI) ENDIF(SALOME_BUILD_GUI)
IF (DEFINED EMSCRIPTEN) IF (DEFINED EMSCRIPTEN)
SET(SUBDIRS_WASM webassembly) SET(SUBDIRS_WASM wasm_to_py)
# SET(SUBDIRS_WASM wasm_to_js wasm_to_py)
ENDIF() ENDIF()
SET(SUBDIRS SET(SUBDIRS

View File

@ -0,0 +1,59 @@
add_executable(smeshjs Bindings.cxx)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set_target_properties(smeshjs PROPERTIES
OUTPUT_NAME smesh
)
target_link_libraries(smeshjs PRIVATE SalomeIDLKernel GEOMImpl SMESHDS SMESHimpl StdMeshers SMESHEngine)
target_include_directories(smeshjs PRIVATE
${OpenCASCADE_INCLUDE_DIR}
${KERNEL_INCLUDE_DIRS}
${KERNEL_INCLUDE_DIRS}
${MEDFILE_INCLUDE_DIRS}
${MEDCOUPLING_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/src/Controls
${PROJECT_SOURCE_DIR}/src/SMDS
${PROJECT_SOURCE_DIR}/src/SMESH
${PROJECT_SOURCE_DIR}/src/SMESHDS
${PROJECT_SOURCE_DIR}/src/StdMeshers
${PROJECT_SOURCE_DIR}/src/SMESHUtils
)
target_link_options(smeshjs PRIVATE
"-O0"
"--bind"
"--closure 1"
"SHELL:-sEXPORT_NAME=smesh"
"SHELL:-sALLOW_MEMORY_GROWTH=1"
"SHELL:-sEMULATE_FUNCTION_POINTER_CASTS=0"
"SHELL:-sMODULARIZE=1"
"SHELL:-sWASM=1"
"SHELL:-sFORCE_FILESYSTEM"
"SHELL:-sEXPORTED_RUNTIME_METHODS=FS"
"SHELL:-sWASM_BIGINT"
"SHELL:-sNO_DISABLE_EXCEPTION_CATCHING"
)
target_compile_options(smeshjs PRIVATE
"-Oz" "-flto"
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/app.html"
"${CMAKE_BINARY_DIR}/wasm_to_js/index.html"
COPYONLY)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/server.py"
"${CMAKE_BINARY_DIR}/wasm_to_js/server.py"
COPYONLY)
install(FILES
${CMAKE_BINARY_DIR}/wasm_to_js/index.html
${CMAKE_BINARY_DIR}/wasm_to_js/server.py
${CMAKE_BINARY_DIR}/src/wasm_to_js/smesh.wasm
${CMAKE_BINARY_DIR}/src/wasm_to_js/smesh.js
DESTINATION wasm_to_js)

View File

@ -0,0 +1,34 @@
INCLUDE(${SWIG_USE_FILE})
set_source_files_properties(smeshpy.i PROPERTIES CPLUSPLUS ON)
SWIG_ADD_LIBRARY(smeshpy LANGUAGE python SOURCES smeshpy.i)
target_compile_options(${SWIG_MODULE_smeshpy_REAL_NAME} PRIVATE "-sSIDE_MODULE=2" "-Oz")
target_link_options(${SWIG_MODULE_smeshpy_REAL_NAME} PRIVATE "-sSIDE_MODULE=2" "-sEXPORTED_FUNCTIONS=_PyInit_smesh" "-sWARN_UNALIGNED=1" "-Oz")
target_link_libraries(${SWIG_MODULE_smeshpy_REAL_NAME} PRIVATE GEOMImpl SMESHEngine)
set_target_properties(${SWIG_MODULE_smeshpy_REAL_NAME} PROPERTIES
OUTPUT_NAME smesh
SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE
)
target_include_directories(${SWIG_MODULE_smeshpy_REAL_NAME} PRIVATE
${OpenCASCADE_INCLUDE_DIR}
${KERNEL_INCLUDE_DIRS}
${MEDFILE_INCLUDE_DIRS}
${MEDCOUPLING_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/src/Controls
${PROJECT_SOURCE_DIR}/src/SMDS
${PROJECT_SOURCE_DIR}/src/SMESH
${PROJECT_SOURCE_DIR}/src/SMESHDS
${PROJECT_SOURCE_DIR}/src/StdMeshers
${PROJECT_SOURCE_DIR}/src/SMESHUtils
${PYTHONWASM_INCLUDE_DIR}
)
install(FILES
${CMAKE_BINARY_DIR}/src/wasm_to_py/smesh.so
${CMAKE_BINARY_DIR}/src/wasm_to_py/smeshpy.py
DESTINATION smeshpywheel
)

View File

@ -1,95 +0,0 @@
INCLUDE(${SWIG_USE_FILE})
# add_executable(smeshjs Bindings.cxx)
set_source_files_properties(smeshpy.i PROPERTIES CPLUSPLUS ON)
SWIG_ADD_LIBRARY(smeshpy LANGUAGE python SOURCES smeshpy.i)
target_compile_options(${SWIG_MODULE_smeshpy_REAL_NAME} PRIVATE "-sSIDE_MODULE=2" "-Oz")
target_link_options(${SWIG_MODULE_smeshpy_REAL_NAME} PRIVATE "-sSIDE_MODULE=2" "-sEXPORTED_FUNCTIONS=_PyInit_smesh" "-sWARN_UNALIGNED=1" "-Oz")
# set(CMAKE_CXX_VISIBILITY_PRESET hidden)
target_link_libraries(${SWIG_MODULE_smeshpy_REAL_NAME} PRIVATE GEOMImpl SMESHEngine)
# set_target_properties(smeshjs PROPERTIES
# OUTPUT_NAME smesh
# )
set_target_properties(${SWIG_MODULE_smeshpy_REAL_NAME} PROPERTIES
OUTPUT_NAME smesh
SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE
)
# target_link_libraries(smeshjs PRIVATE SalomeIDLKernel GEOMImpl SMESHDS SMESHimpl StdMeshers SMESHEngine)
# target_include_directories(smeshjs PRIVATE
# ${OpenCASCADE_INCLUDE_DIR}
# ${KERNEL_INCLUDE_DIRS}
# ${KERNEL_INCLUDE_DIRS}
# ${MEDFILE_INCLUDE_DIRS}
# ${MEDCOUPLING_INCLUDE_DIRS}
# ${PROJECT_SOURCE_DIR}/src/Controls
# ${PROJECT_SOURCE_DIR}/src/SMDS
# ${PROJECT_SOURCE_DIR}/src/SMESH
# ${PROJECT_SOURCE_DIR}/src/SMESHDS
# ${PROJECT_SOURCE_DIR}/src/StdMeshers
# ${PROJECT_SOURCE_DIR}/src/SMESHUtils
# )
target_include_directories(${SWIG_MODULE_smeshpy_REAL_NAME} PRIVATE
${OpenCASCADE_INCLUDE_DIR}
${KERNEL_INCLUDE_DIRS}
${MEDFILE_INCLUDE_DIRS}
${MEDCOUPLING_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/src/Controls
${PROJECT_SOURCE_DIR}/src/SMDS
${PROJECT_SOURCE_DIR}/src/SMESH
${PROJECT_SOURCE_DIR}/src/SMESHDS
${PROJECT_SOURCE_DIR}/src/StdMeshers
${PROJECT_SOURCE_DIR}/src/SMESHUtils
${PYTHONWASM_INCLUDE_DIR}
)
install(FILES
${CMAKE_BINARY_DIR}/src/webassembly/smesh.so
${CMAKE_BINARY_DIR}/src/webassembly/smeshpy.py
DESTINATION smeshpywheel
)
# target_link_options(smeshjs PRIVATE
# "-O0"
# "--bind"
# "--closure 1"
# "SHELL:-sEXPORT_NAME=smesh"
# "SHELL:-sALLOW_MEMORY_GROWTH=1"
# "SHELL:-sEMULATE_FUNCTION_POINTER_CASTS=0"
# "SHELL:-sMODULARIZE=1"
# "SHELL:-sWASM=1"
# "SHELL:-sFORCE_FILESYSTEM"
# "SHELL:-sEXPORTED_RUNTIME_METHODS=FS"
# "SHELL:-sWASM_BIGINT"
# "SHELL:-sNO_DISABLE_EXCEPTION_CATCHING"
# )
# target_compile_options(smeshjs PRIVATE
# "-Oz" "-flto"
# )
# configure_file(
# "${CMAKE_CURRENT_SOURCE_DIR}/app.html"
# "${CMAKE_BINARY_DIR}/webassembly/index.html"
# COPYONLY)
# configure_file(
# "${CMAKE_CURRENT_SOURCE_DIR}/server.py"
# "${CMAKE_BINARY_DIR}/webassembly/server.py"
# COPYONLY)
# install(FILES
# ${CMAKE_BINARY_DIR}/webassembly/index.html
# ${CMAKE_BINARY_DIR}/webassembly/server.py
# ${CMAKE_BINARY_DIR}/webassembly/server.py
# ${CMAKE_BINARY_DIR}/src/webassembly/smesh.wasm
# ${CMAKE_BINARY_DIR}/src/webassembly/smesh.js
# DESTINATION webassembly)