Skip to content

Commit

Permalink
Merge pull request #12 from Kitware/more-cleanups
Browse files Browse the repository at this point in the history
More cleanup for VTK build script and client code
  • Loading branch information
jourdain authored Aug 27, 2024
2 parents fcf8a4a + e33f958 commit 385afbc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 46 deletions.
10 changes: 8 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 4 additions & 42 deletions utils/build_vtk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down Expand Up @@ -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 \
Expand All @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions vue-components/src/components/VtkLocal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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}`);
Expand Down

0 comments on commit 385afbc

Please sign in to comment.