From fa8979eb56e611d71257487baa4adbe44856d955 Mon Sep 17 00:00:00 2001 From: Jules BOURDAIS Date: Fri, 6 Dec 2024 13:29:23 +0100 Subject: [PATCH] split wasm_to_py from wasm_to_js - disable wasm_to_js which needs pthread and boost headers --- src/CMakeLists.txt | 3 +- src/{webassembly => wasm_to_js}/Bindings.cxx | 0 src/wasm_to_js/CMakeLists.txt | 59 ++++++++++++ src/{webassembly => wasm_to_js}/app.html | 0 src/{webassembly => wasm_to_js}/server.py | 0 src/wasm_to_py/CMakeLists.txt | 34 +++++++ src/{webassembly => wasm_to_py}/smeshpy.i | 0 src/webassembly/CMakeLists.txt | 95 -------------------- 8 files changed, 95 insertions(+), 96 deletions(-) rename src/{webassembly => wasm_to_js}/Bindings.cxx (100%) create mode 100644 src/wasm_to_js/CMakeLists.txt rename src/{webassembly => wasm_to_js}/app.html (100%) rename src/{webassembly => wasm_to_js}/server.py (100%) create mode 100644 src/wasm_to_py/CMakeLists.txt rename src/{webassembly => wasm_to_py}/smeshpy.i (100%) delete mode 100644 src/webassembly/CMakeLists.txt diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index eb8001a7d..2a823ff6c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -69,7 +69,8 @@ IF(SALOME_BUILD_GUI) ENDIF(SALOME_BUILD_GUI) IF (DEFINED EMSCRIPTEN) - SET(SUBDIRS_WASM webassembly) + SET(SUBDIRS_WASM wasm_to_py) + # SET(SUBDIRS_WASM wasm_to_js wasm_to_py) ENDIF() SET(SUBDIRS diff --git a/src/webassembly/Bindings.cxx b/src/wasm_to_js/Bindings.cxx similarity index 100% rename from src/webassembly/Bindings.cxx rename to src/wasm_to_js/Bindings.cxx diff --git a/src/wasm_to_js/CMakeLists.txt b/src/wasm_to_js/CMakeLists.txt new file mode 100644 index 000000000..416181b5e --- /dev/null +++ b/src/wasm_to_js/CMakeLists.txt @@ -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) diff --git a/src/webassembly/app.html b/src/wasm_to_js/app.html similarity index 100% rename from src/webassembly/app.html rename to src/wasm_to_js/app.html diff --git a/src/webassembly/server.py b/src/wasm_to_js/server.py similarity index 100% rename from src/webassembly/server.py rename to src/wasm_to_js/server.py diff --git a/src/wasm_to_py/CMakeLists.txt b/src/wasm_to_py/CMakeLists.txt new file mode 100644 index 000000000..32785182f --- /dev/null +++ b/src/wasm_to_py/CMakeLists.txt @@ -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 +) diff --git a/src/webassembly/smeshpy.i b/src/wasm_to_py/smeshpy.i similarity index 100% rename from src/webassembly/smeshpy.i rename to src/wasm_to_py/smeshpy.i diff --git a/src/webassembly/CMakeLists.txt b/src/webassembly/CMakeLists.txt deleted file mode 100644 index 6ea984e97..000000000 --- a/src/webassembly/CMakeLists.txt +++ /dev/null @@ -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)