From f384085d1fdef05b8587f1f14834c7d7e493510f Mon Sep 17 00:00:00 2001 From: Paul Baksic <30337881+bakpaul@users.noreply.github.com> Date: Mon, 27 May 2024 05:49:32 +0200 Subject: [PATCH] [tools] Factorize and clean plugin list filtering (#4748) * Try to factorize plugin_list filtyering * Fix path error * Fix missing $ * Fix Windows specification * Remove all plugins, leaving only Sofa.Metis and MultiThreading --- tools/postinstall-fixup/CMakeLists.txt | 4 ++ tools/postinstall-fixup/common.sh | 43 ++++++++++++++ .../linux-postinstall-fixup.sh | 57 ++++++------------- .../macos-postinstall-fixup.sh | 50 +++------------- .../windows-postinstall-fixup.sh | 46 +++------------ 5 files changed, 79 insertions(+), 121 deletions(-) create mode 100644 tools/postinstall-fixup/common.sh diff --git a/tools/postinstall-fixup/CMakeLists.txt b/tools/postinstall-fixup/CMakeLists.txt index de95d7d99ad..702c896b108 100644 --- a/tools/postinstall-fixup/CMakeLists.txt +++ b/tools/postinstall-fixup/CMakeLists.txt @@ -25,6 +25,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux) COMPONENT resources) install(CODE "execute_process(COMMAND /bin/bash \"${CMAKE_CURRENT_LIST_DIR}/linux-postinstall-fixup.sh\" + \"${CMAKE_CURRENT_LIST_DIR}\" \"${CMAKE_BINARY_DIR}\" \"\$ENV{DESTDIR\}\${CMAKE_INSTALL_PREFIX\}\" \"${QT_LIB_DIR}\" @@ -36,6 +37,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin) include(macdeployqt) # set MACDEPLOYQT_EXECUTABLE install(CODE "execute_process(COMMAND /bin/bash \"${CMAKE_CURRENT_LIST_DIR}/macos-postinstall-fixup.sh\" + \"${CMAKE_CURRENT_LIST_DIR}\" \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/../..\" \"${QT_LIB_DIR}\" \"${QT_DATA_DIR}\" @@ -45,6 +47,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin) else() install(CODE "execute_process(COMMAND /bin/bash \"${CMAKE_CURRENT_LIST_DIR}/macos-postinstall-fixup.sh\" + \"${CMAKE_CURRENT_LIST_DIR}\" \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}\" \"${QT_LIB_DIR}\" \"${QT_DATA_DIR}\" @@ -59,6 +62,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL Windows) COMPONENT resources) install(CODE "execute_process(COMMAND bash \"${CMAKE_CURRENT_LIST_DIR}/windows-postinstall-fixup.sh\" + \"${CMAKE_CURRENT_LIST_DIR}\" \"${CMAKE_BINARY_DIR}\" \"\$ENV{DESTDIR\}\${CMAKE_INSTALL_PREFIX\}\" )" diff --git a/tools/postinstall-fixup/common.sh b/tools/postinstall-fixup/common.sh new file mode 100644 index 00000000000..9d8145eac01 --- /dev/null +++ b/tools/postinstall-fixup/common.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +function clean_default_plugins() +{ + # Keep plugin_list as short as possible + echo "" > "$1/plugin_list.conf" + disabled_plugins='plugins_ignored_by_default' + for plugin in \ + ArticulatedSystemPlugin \ + Geomagic \ + BeamAdapter \ + CGALPlugin \ + CImgPlugin \ + CollisionOBBCapsule \ + CSparseSolvers \ + DiffusionSolver \ + image \ + InvertibleFVM \ + ManifoldTopologies \ + ModelOrderReduction \ + PluginExample \ + Registration \ + SceneCreator \ + SensableEmulation \ + ShapeMatchingPlugin \ + SofaAssimp \ + SofaCarving \ + SofaCUDA \ + SofaDistanceGrid \ + SofaEulerianFluid \ + SofaImplicitField \ + SofaMatrix \ + SoftRobots \ + SofaSimpleGUI \ + SofaSphFluid \ + SofaValidation \ + STLIB \ + VolumetricRendering \ + ; do + disabled_plugins=$disabled_plugins'\|'$plugin + done + grep -v $disabled_plugins "$1/plugin_list.conf.default" >> "$1/plugin_list.conf" +} \ No newline at end of file diff --git a/tools/postinstall-fixup/linux-postinstall-fixup.sh b/tools/postinstall-fixup/linux-postinstall-fixup.sh index 12093a86b27..352602f6d7c 100644 --- a/tools/postinstall-fixup/linux-postinstall-fixup.sh +++ b/tools/postinstall-fixup/linux-postinstall-fixup.sh @@ -1,59 +1,34 @@ #!/bin/bash usage() { - echo "Usage: linux-postinstall-fixup.sh [qt-lib-dir] [qt-data-dir]" + echo "Usage: linux-postinstall-fixup.sh [qt-lib-dir] [qt-data-dir]" } if [ "$#" -ge 2 ]; then - BUILD_DIR="$(cd $1 && pwd)" - INSTALL_DIR="$(cd $2 && pwd)" - QT_LIB_DIR="$3" - QT_DATA_DIR="$4" + SCRIPT_DIR="$(cd $1 && pwd)" + BUILD_DIR="$(cd $2 && pwd)" + INSTALL_DIR="$(cd $3 && pwd)" + QT_LIB_DIR="$4" + QT_DATA_DIR="$5" else usage; exit 1 fi + +echo "SCRIPT_DIR = $SCRIPT_DIR" +echo "BUILD_DIR = $BUILD_DIR" +echo "INSTALL_DIR = $INSTALL_DIR" +echo "QT_LIB_DIR = $QT_LIB_DIR" +echo "QT_DATA_DIR = $QT_DATA_DIR" + + # Adapt INSTALL_DIR to IFW install if [ -d "$INSTALL_DIR/packages/Runtime/data" ]; then INSTALL_DIR="$INSTALL_DIR/packages/Runtime/data" fi -# Keep plugin_list as short as possible -echo "" > "$INSTALL_DIR/lib/plugin_list.conf" -disabled_plugins='plugins_ignored_by_default' -for plugin in \ - ArticulatedSystemPlugin \ - CollisionOBBCapsule \ - Compliant \ - DiffusionSolver \ - ExternalBehaviorModel \ - Flexible \ - Geomagic \ - image \ - InvertibleFVM \ - LMConstraint \ - ManifoldTopologies \ - ManualMapping \ - MultiThreading \ - OptiTrackNatNet \ - PluginExample \ - Registration \ - RigidScale \ - SensableEmulation \ - SofaAssimp \ - SofaCUDA \ - SofaCarving \ - SofaDistanceGrid \ - SofaEulerianFluid \ - SofaImplicitField \ - SofaPython \ - SofaSimpleGUI \ - SofaSphFluid \ - THMPGSpatialHashing \ - ; do - disabled_plugins=$disabled_plugins'\|'$plugin -done -grep -v $disabled_plugins "$INSTALL_DIR/lib/plugin_list.conf.default" >> "$INSTALL_DIR/lib/plugin_list.conf" +source $SCRIPT_DIR/common.sh +clean_default_plugins "$INSTALL_DIR/lib" echo "Fixing up libs..." diff --git a/tools/postinstall-fixup/macos-postinstall-fixup.sh b/tools/postinstall-fixup/macos-postinstall-fixup.sh index d29865ab2c4..240d3fd8e59 100644 --- a/tools/postinstall-fixup/macos-postinstall-fixup.sh +++ b/tools/postinstall-fixup/macos-postinstall-fixup.sh @@ -2,14 +2,15 @@ # set -o errexit # Exit on error usage() { - echo "Usage: macos-postinstall-fixup.sh [qt-lib-dir] [qt-data-dir] [macdeployqt]" + echo "Usage: macos-postinstall-fixup.sh [qt-lib-dir] [qt-data-dir] [macdeployqt]" } if [ "$#" -ge 1 ]; then - INSTALL_DIR="$(cd $1 && pwd)" - QT_LIB_DIR="$2" - QT_DATA_DIR="$3" - MACDEPLOYQT_EXE="$4" + SCRIPT_DIR="$(cd $1 && pwd)" + INSTALL_DIR="$(cd $2 && pwd)" + QT_LIB_DIR="$3" + QT_DATA_DIR="$4" + MACDEPLOYQT_EXE="$5" else usage; exit 1 fi @@ -19,48 +20,15 @@ if [[ $INSTALL_DIR == *".app" ]]; then INSTALL_DIR=$INSTALL_DIR/Contents/MacOS fi +echo "SCRIPT_DIR = $SCRIPT_DIR" echo "INSTALL_DIR = $INSTALL_DIR" echo "BUNDLE_DIR = $BUNDLE_DIR" echo "QT_LIB_DIR = $QT_LIB_DIR" echo "QT_DATA_DIR = $QT_DATA_DIR" echo "MACDEPLOYQT_EXE = $MACDEPLOYQT_EXE" -# Keep plugin_list as short as possible -echo "" > "$INSTALL_DIR/lib/plugin_list.conf" -disabled_plugins='plugins_ignored_by_default' -for plugin in \ - ArticulatedSystemPlugin \ - CollisionOBBCapsule \ - Compliant \ - DiffusionSolver \ - ExternalBehaviorModel \ - Flexible \ - Geomagic \ - image \ - InvertibleFVM \ - LMConstraint \ - ManifoldTopologies \ - ManualMapping \ - MultiThreading \ - OptiTrackNatNet \ - PluginExample \ - Registration \ - RigidScale \ - SensableEmulation \ - SofaAssimp \ - SofaCUDA \ - SofaCarving \ - SofaDistanceGrid \ - SofaEulerianFluid \ - SofaImplicitField \ - SofaPython \ - SofaSimpleGUI \ - SofaSphFluid \ - THMPGSpatialHashing \ - ; do - disabled_plugins=$disabled_plugins'\|'$plugin -done -grep -v $disabled_plugins "$INSTALL_DIR/lib/plugin_list.conf.default" >> "$INSTALL_DIR/lib/plugin_list.conf" +source $SCRIPT_DIR/common.sh +clean_default_plugins "$INSTALL_DIR/lib" # Make sure the bin folder exists and contains runSofa if [ ! -d "$INSTALL_DIR/bin" ]; then diff --git a/tools/postinstall-fixup/windows-postinstall-fixup.sh b/tools/postinstall-fixup/windows-postinstall-fixup.sh index 149a1f4df1d..aff7b028dba 100644 --- a/tools/postinstall-fixup/windows-postinstall-fixup.sh +++ b/tools/postinstall-fixup/windows-postinstall-fixup.sh @@ -1,12 +1,13 @@ #!bash usage() { - echo "Usage: windows-postinstall-fixup.sh " + echo "Usage: windows-postinstall-fixup.sh " } if [ "$#" -ge 2 ]; then - BUILD_DIR="$(cd $1 && pwd)" - INSTALL_DIR="$(cd $2 && pwd)" + SCRIPT_DIR="$(cd $1 && pwd)" + BUILD_DIR="$(cd $2 && pwd)" + INSTALL_DIR="$(cd $3 && pwd)" else usage; exit 1 fi @@ -18,46 +19,13 @@ if [[ "$INSTALL_DIR" == *"/NSIS/"* ]] && [[ -e "$INSTALL_DIR/../applications/bin INSTALL_DIR_BIN="$INSTALL_DIR/applications/bin" fi +echo "SCRIPT_DIR = $SCRIPT_DIR" echo "BUILD_DIR = $BUILD_DIR" echo "INSTALL_DIR = $INSTALL_DIR" echo "INSTALL_DIR_BIN = $INSTALL_DIR_BIN" -# Keep plugin_list as short as possible -echo "" > "$INSTALL_DIR_BIN/plugin_list.conf" -disabled_plugins='plugins_ignored_by_default' -for plugin in \ - ArticulatedSystemPlugin \ - CollisionOBBCapsule \ - Compliant \ - DiffusionSolver \ - ExternalBehaviorModel \ - Flexible \ - Geomagic \ - image \ - InvertibleFVM \ - LMConstraint \ - ManifoldTopologies \ - ManualMapping \ - MultiThreading \ - OptiTrackNatNet \ - PluginExample \ - Registration \ - RigidScale \ - SensableEmulation \ - SofaAssimp \ - SofaCUDA \ - SofaCarving \ - SofaDistanceGrid \ - SofaEulerianFluid \ - SofaImplicitField \ - SofaPython \ - SofaSimpleGUI \ - SofaSphFluid \ - THMPGSpatialHashing \ - ; do - disabled_plugins=$disabled_plugins'\|'$plugin -done -grep -v $disabled_plugins "$INSTALL_DIR_BIN/plugin_list.conf.default" >> "$INSTALL_DIR_BIN/plugin_list.conf" +source $SCRIPT_DIR/common.sh +clean_default_plugins "$INSTALL_DIR_BIN" # Copy all plugin libs in install/bin to make them easily findable cd "$INSTALL_DIR" && find -name "*.dll" -path "*/plugins/*" | while read lib; do