From 75555398d5e1c20f64794c541257451e1cbb74a8 Mon Sep 17 00:00:00 2001 From: Jaswant Panchumarti Date: Tue, 27 Aug 2024 16:48:19 -0400 Subject: [PATCH 1/2] chore(dev): simplify VTK build script --- README.rst | 10 ++++++++-- utils/build_vtk.sh | 46 ++++------------------------------------------ 2 files changed, 12 insertions(+), 44 deletions(-) diff --git a/README.rst b/README.rst index 626e907..2b16d67 100644 --- a/README.rst +++ b/README.rst @@ -41,12 +41,18 @@ Install the library pip install -e . -Optionally, you can develop with bleeding edge VTK by following these steps +Optionally, you can develop with bleeding edge VTK by following these steps. Make sure you've these tools +1. git +2. CMake +3. Ninja +4. Python +5. NodeJS >= 22.0.0: https://nodejs.org/en/download/package-manager +6. Emscripten SDK: See https://emscripten.org/docs/getting_started/downloads.html#download-and-install .. code-block:: console # Compile VTK for wasm32 architecture using emscripten. Build artifacts can be found in dev/vtk/build/wasm - docker run --rm -it -v$PWD:/work kitware/vtk:ci-fedora39-20240731 /bin/bash -c "cd /work && ./utils/build_vtk.sh -u https://gitlab.kitware.com/vtk/vtk.git -b master -t wasm32 -p RelWithDebInfo" + ./utils/build_vtk.sh -u https://gitlab.kitware.com/vtk/vtk.git -b master -t wasm32 -p RelWithDebInfo # Compile VTK with python wrappings using system C++ compiler. Build artifacts can be found in dev/vtk/build/py ./utils/build_vtk.sh -u https://gitlab.kitware.com/vtk/vtk.git -b master -t py -p RelWithDebInfo diff --git a/utils/build_vtk.sh b/utils/build_vtk.sh index 7b007fd..a301ea2 100755 --- a/utils/build_vtk.sh +++ b/utils/build_vtk.sh @@ -12,7 +12,7 @@ # # Usage: # Build wasm binaries: -# docker run --rm -it -v$PWD:/work kitware/vtk:ci-fedora39-20240731 /bin/bash -c "cd /work && ./utils/build_vtk.sh -u https://gitlab.kitware.com/vtk/vtk.git -b master -t wasm32 -p RelWithDebInfo" +# ./utils/build_vtk.sh -u https://gitlab.kitware.com/vtk/vtk.git -b master -t wasm32 -p RelWithDebInfo # Build python libs: # ./utils/build_vtk.sh -u https://gitlab.kitware.com/vtk/vtk.git -b master -t py -p RelWithDebInfo # @@ -50,56 +50,20 @@ readonly build_dir="build/$build_type/$build_target" git config --global --add safe.directory "$git_clone_dir" [ -d "$git_clone_dir" ] && cd "$git_clone_dir" && git submodule update --init && git checkout $vtk_branch -# run the ci scripts to initialize VTK build tools -if ! [ -f .gitlab/cmake/bin/cmake ]; then - if [ -d .gitlab/cmake ]; then - rm -rf .gitlab/cmake - fi - .gitlab/ci/cmake.sh latest -fi - -export PATH=$PWD/.gitlab:$PWD/.gitlab/cmake/bin:$PATH +# Ensure required tools are available. cmake --version - -[ -f .gitlab/ninja ] || .gitlab/ci/ninja.sh ninja --version -[ -f .gitlab/sccache ] || .gitlab/ci/sccache.sh -sccache --start-server || echo "Server already started" - case "$build_target" in wasm32) - export CMAKE_CONFIGURATION="wasm32_emscripten_linux" - if ! [ -f .gitlab/node/bin/node ]; then - if [ -d .gitlab/node ]; then - rm -rf .gitlab/node - fi - cmake -P .gitlab/ci/download_node.cmake - fi - export PATH=$PWD/.gitlab/node/bin:$PATH - export NODE_DIR=$PWD/.gitlab/node node --version - - if ! [ -d .gitlab/emsdk ]; then - dnf install -y --setopt=install_weak_deps=False xz - .gitlab/ci/emsdk.sh - .gitlab/emsdk/emsdk install latest - fi - export PATH=$PWD/.gitlab/emsdk/upstream/bin:$PWD/.gitlab/emsdk/upstream/emscripten:$PATH - clang --version - wasm-as --version - wasm-ld --version - wasm-opt --version emcc --version # build vtk.wasm binaries - cmake \ + emcmake cmake \ -S . \ -B "$build_dir" \ -GNinja \ - -DCMAKE_TOOLCHAIN_FILE="$PWD/.gitlab/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake" \ - -DCMAKE_C_COMPILER_LAUNCHER=sccache \ - -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \ -DCMAKE_BUILD_TYPE:STRING=$build_type \ -DBUILD_SHARED_LIBS=OFF \ -DVTK_WRAP_SERIALIZATION=ON \ @@ -116,12 +80,10 @@ case "$build_target" in -S . \ -B "$build_dir" \ -GNinja \ - -DCMAKE_C_COMPILER_LAUNCHER=sccache \ - -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \ -DCMAKE_BUILD_TYPE:STRING=$build_type \ -DVTK_WRAP_PYTHON=ON \ -DVTK_WRAP_SERIALIZATION=ON \ - -DVTK_BUILD_TESTING=ON \ + -DVTK_BUILD_TESTING=OFF \ -DVTK_GROUP_ENABLE_Web=YES cmake --build "$build_dir" From e33f958250fee0a417af6550ff8ee54269eced5c Mon Sep 17 00:00:00 2001 From: Jaswant Panchumarti Date: Tue, 27 Aug 2024 16:54:53 -0400 Subject: [PATCH 2/2] fix(client): remove unnecessary calls to unregister state --- vue-components/src/components/VtkLocal.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/vue-components/src/components/VtkLocal.js b/vue-components/src/components/VtkLocal.js index 247d9b9..1e0af78 100644 --- a/vue-components/src/components/VtkLocal.js +++ b/vue-components/src/components/VtkLocal.js @@ -113,7 +113,6 @@ export default { function handleMessage([event]) { if (event.type === "state") { const { mtime, content, id } = event; - sceneManager.unRegisterState(id); sceneManager.registerState(content); stateMTimes[id] = mtime; } @@ -173,7 +172,6 @@ export default { if (serverState.length > 0) { stateMTimes[vtkId] = JSON.parse(serverState).MTime; // console.log(`vtkLocal::state(${vtkId})`); - sceneManager.unRegisterState(vtkId); sceneManager.registerState(serverState); } else { console.log(`Server returned empty state for ${vtkId}`);