From a28cdae218c0a759ce0b070440a21a8480ecdef0 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Mon, 29 Apr 2024 18:34:48 +0200 Subject: [PATCH] Add recipe for ergocub-software --- recipes/ergocub-software/activate.msh | 27 +++++++++++ recipes/ergocub-software/bld_cxx.bat | 46 ++++++++++++++++++ recipes/ergocub-software/build_cxx.sh | 38 +++++++++++++++ recipes/ergocub-software/deactivate.msh | 27 +++++++++++ recipes/ergocub-software/meta.yaml | 63 +++++++++++++++++++++++++ 5 files changed, 201 insertions(+) create mode 100644 recipes/ergocub-software/activate.msh create mode 100644 recipes/ergocub-software/bld_cxx.bat create mode 100644 recipes/ergocub-software/build_cxx.sh create mode 100644 recipes/ergocub-software/deactivate.msh create mode 100644 recipes/ergocub-software/meta.yaml diff --git a/recipes/ergocub-software/activate.msh b/recipes/ergocub-software/activate.msh new file mode 100644 index 0000000000000..f716205dc2f8b --- /dev/null +++ b/recipes/ergocub-software/activate.msh @@ -0,0 +1,27 @@ +if_(is_set("COMSPEC")).then_([ + sys.list_append("YARP_DATA_DIRS", path.join(env("CONDA_PREFIX"), "Library\\share\\ergoCub")), + sys.list_append("ROS_PACKAGE_PATH", path.join(env("CONDA_PREFIX"), "Library\\share")), + sys.list_append("AMENT_PREFIX_PATH", path.join(env("CONDA_PREFIX"), "Library")), +]).else_([ + sys.list_append("YARP_DATA_DIRS", path.join(env("CONDA_PREFIX"), "share/ergoCub")), + sys.list_append("ROS_PACKAGE_PATH", path.join(env("CONDA_PREFIX"), "share")), + sys.list_append("AMENT_PREFIX_PATH", env("CONDA_PREFIX")), +]) + +# For some reason setting two times the same variable inside the same if does not work in command prompt +# As a workaround, we move each GAZEBO_MODEL_PATH and GZ_SIM_RESOURCE_PATH set to a separate if +if_(is_set("COMSPEC")).then_([ + sys.list_append("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "Library\\share\\ergoCub\\robots")), + sys.list_append("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "Library\\share\\ergoCub\\robots")) +]).else_([ + sys.list_append("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "share/ergoCub/robots")), + sys.list_append("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "share/ergoCub/robots")) +]) + +if_(is_set("COMSPEC")).then_([ + sys.list_append("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "Library\\share")), + sys.list_append("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "Library\\share")) +]).else_([ + sys.list_append("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "share")), + sys.list_append("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "share")) +]) diff --git a/recipes/ergocub-software/bld_cxx.bat b/recipes/ergocub-software/bld_cxx.bat new file mode 100644 index 0000000000000..2384a040bde3d --- /dev/null +++ b/recipes/ergocub-software/bld_cxx.bat @@ -0,0 +1,46 @@ +mkdir build +cd build + +cmake ^ + -G "Ninja" ^ + -DCMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% ^ + -DCMAKE_PREFIX_PATH=%LIBRARY_PREFIX% ^ + -DCMAKE_BUILD_TYPE=Release ^ + -DBUILD_SHARED_LIBS=ON ^ + -DCOMPILE_ergoCubEmotions:BOOL=ON ^ + %SRC_DIR% +if errorlevel 1 exit 1 + +:: Build. +cmake --build . --config Release +if errorlevel 1 exit 1 + +:: Install. +cmake --build . --config Release --target install +if errorlevel 1 exit 1 + +setlocal EnableDelayedExpansion +:: Generate and copy the [de]activate scripts to %PREFIX%\etc\conda\[de]activate.d. +:: This will allow them to be run on environment activation. +for %%F in (activate deactivate) DO ( + multisheller %RECIPE_DIR%\%%F.msh --output .\%%F + + if not exist %PREFIX%\etc\conda\%%F.d mkdir %PREFIX%\etc\conda\%%F.d + copy %%F.bat %PREFIX%\etc\conda\%%F.d\%PKG_NAME%_%%F.bat + if %errorlevel% neq 0 exit /b %errorlevel% + + copy %%F.sh %PREFIX%\etc\conda\%%F.d\%PKG_NAME%_%%F.sh + if %errorlevel% neq 0 exit /b %errorlevel% + + copy %%F.bash %PREFIX%\etc\conda\%%F.d\%PKG_NAME%_%%F.bash + if %errorlevel% neq 0 exit /b %errorlevel% + + copy %%F.ps1 %PREFIX%\etc\conda\%%F.d\%PKG_NAME%_%%F.ps1 + if %errorlevel% neq 0 exit /b %errorlevel% + + copy %%F.xsh %PREFIX%\etc\conda\%%F.d\%PKG_NAME%_%%F.xsh + if %errorlevel% neq 0 exit /b %errorlevel% + + copy %%F.zsh %PREFIX%\etc\conda\%%F.d\%PKG_NAME%_%%F.zsh + if %errorlevel% neq 0 exit /b %errorlevel% +) diff --git a/recipes/ergocub-software/build_cxx.sh b/recipes/ergocub-software/build_cxx.sh new file mode 100644 index 0000000000000..6dad087a042db --- /dev/null +++ b/recipes/ergocub-software/build_cxx.sh @@ -0,0 +1,38 @@ +#!/bin/sh + +rm -rf build +mkdir build +cd build + +if [[ "${target_platform}" == osx-* ]]; then + # See https://conda-forge.org/docs/maintainer/knowledge_base.html#newer-c-features-with-old-sdk + CXXFLAGS="${CXXFLAGS} -D_LIBCPP_DISABLE_AVAILABILITY" +fi + +cmake ${CMAKE_ARGS} -GNinja .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS:BOOL=ON \ + -DBUILD_TESTING:BOOL=ON \ + -DCOMPILE_ergoCubEmotions:BOOL=ON \ + .. + +cmake --build . --config Release + +if [[ ("${CONDA_BUILD_CROSS_COMPILATION:-}" != "1" || "${CROSSCOMPILING_EMULATOR}" != "") ]]; then + ctest --output-on-failure --repeat until-pass:5 -C Release +fi + +cmake --build . --config Release --target install + +# Generate and copy the [de]activate scripts to $PREFIX/etc/conda/[de]activate.d. +# This will allow them to be run on environment activation. +for CHANGE in "activate" "deactivate" +do + multisheller ${RECIPE_DIR}/${CHANGE}.msh --output ./${CHANGE} + mkdir -p "${PREFIX}/etc/conda/${CHANGE}.d" + cp "${CHANGE}.sh" "${PREFIX}/etc/conda/${CHANGE}.d/${PKG_NAME}_${CHANGE}.sh" + cp "${CHANGE}.bash" "${PREFIX}/etc/conda/${CHANGE}.d/${PKG_NAME}_${CHANGE}.bash" + cp "${CHANGE}.xsh" "${PREFIX}/etc/conda/${CHANGE}.d/${PKG_NAME}_${CHANGE}.xsh" + cp "${CHANGE}.zsh" "${PREFIX}/etc/conda/${CHANGE}.d/${PKG_NAME}_${CHANGE}.zsh" + cp "${CHANGE}.ps1" "${PREFIX}/etc/conda/${CHANGE}.d/${PKG_NAME}_${CHANGE}.ps1" +done \ No newline at end of file diff --git a/recipes/ergocub-software/deactivate.msh b/recipes/ergocub-software/deactivate.msh new file mode 100644 index 0000000000000..12fa88c95d598 --- /dev/null +++ b/recipes/ergocub-software/deactivate.msh @@ -0,0 +1,27 @@ +if_(is_set("COMSPEC")).then_([ + sys.list_remove("YARP_DATA_DIRS", path.join(env("CONDA_PREFIX"), "Library\\share\\ergoCub")), + sys.list_remove("ROS_PACKAGE_PATH", path.join(env("CONDA_PREFIX"), "Library\\share")), + sys.list_remove("AMENT_PREFIX_PATH", path.join(env("CONDA_PREFIX"), "Library")), +]).else_([ + sys.list_remove("YARP_DATA_DIRS", path.join(env("CONDA_PREFIX"), "share/ergoCub")), + sys.list_remove("ROS_PACKAGE_PATH", path.join(env("CONDA_PREFIX"), "share")), + sys.list_remove("AMENT_PREFIX_PATH", env("CONDA_PREFIX")), +]) + +# For some reason setting two times the same variable inside the same if does not work in command prompt +# As a workaround, we move each GAZEBO_MODEL_PATH and GZ_SIM_RESOURCE_PATH set to a separate if +if_(is_set("COMSPEC")).then_([ + sys.list_remove("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "Library\\share\\ergoCub\\robots")), + sys.list_remove("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "Library\\share\\ergoCub\\robots")) +]).else_([ + sys.list_remove("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "share/ergoCub/robots")), + sys.list_remove("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "share/ergoCub/robots")) +]) + +if_(is_set("COMSPEC")).then_([ + sys.list_remove("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "Library\\share")), + sys.list_remove("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "Library\\share")) +]).else_([ + sys.list_remove("GAZEBO_MODEL_PATH", path.join(env("CONDA_PREFIX"), "share")), + sys.list_remove("GZ_SIM_RESOURCE_PATH", path.join(env("CONDA_PREFIX"), "share")) +]) diff --git a/recipes/ergocub-software/meta.yaml b/recipes/ergocub-software/meta.yaml new file mode 100644 index 0000000000000..81ab61a16a157 --- /dev/null +++ b/recipes/ergocub-software/meta.yaml @@ -0,0 +1,63 @@ +{% set version = "0.7.3" %} + +package: + name: ergocub-software-split + version: {{ version }} + +source: + - url: https://github.com/icub-tech-iit/ergocub-software/archive/refs/tags/v{{ version }}.tar.gz + sha256: 346d3301da028dfe9e9d31bda259b39c8f6189a69d8bc713389ff0a0e42c02bb + +build: + number: 0 + +outputs: + - name: libergocub-software + script: build_cxx.sh # [unix] + script: bld_cxx.bat # [win] + build: + run_exports: + - {{ pin_subpackage("libergocub-software", max_pin='x.x.x') }} + ignore_run_exports_from: + # idyntree is just used for tests + - idyntree + requirements: + build: + - {{ compiler('c') }} + - {{ stdlib("c") }} + - {{ compiler('cxx') }} + - cmake + - pkg-config + - ninja + - multisheller + host: + - ycm-cmake-modules + - libyarp + - libopencv + - idyntree + + test: + commands: + - test -f ${PREFIX}/lib/yarp/yarp_couplingXCubHandMk5.so # [unix] + - if not exist %LIBRARY_LIB%\\yarp\\yarp_couplingXCubHandMk5.dll exit 1 # [win] + + - name: ergocub-software + requirements: + run: + - {{ pin_subpackage("libergocub-software", exact=True) }} + test: + commands: + - test -f ${PREFIX}/lib/yarp/yarp_couplingXCubHandMk5.so # [unix] + - if not exist %LIBRARY_LIB%\\yarp\\yarp_couplingXCubHandMk5.dll exit 1 # [win] + + +about: + home: https://github.com/icub-tech-iit/ergocub-software + license: BSD-3-Clause + license_file: LICENSE + summary: 'Software required to simulate and run the ergoCub humanoid robot.' + +extra: + feedstock-name: ergocub-software + recipe-maintainers: + - traversaro