-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
413 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
name: C++ CI Workflow | ||
|
||
# template derived from https://github.com/robotology/human-dynamics-estimation/blob/master/.github/workflows/ci.yml | ||
|
||
on: | ||
push: | ||
pull_request: | ||
schedule: | ||
# run a cron job for a nightly build | ||
# * is a special character in YAML so you have to quote this string | ||
# Execute a "nightly" build at 2 AM UTC | ||
- cron: '0 2 * * *' | ||
|
||
env: | ||
#TODO change with first release after this commit | ||
BipedalLocomotionFramework_TAG: b045e79229ed25a8562c7dfaebb1b6b9cb722f5c | ||
action-restore-cache: 'true' | ||
jobs: | ||
build: | ||
name: '[${{matrix.os}}@${{matrix.build_type}}]' | ||
runs-on: ${{matrix.os}} | ||
strategy: | ||
matrix: | ||
build_type: [Release] | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
fail-fast: false | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Get current day | ||
shell: bash -l {0} | ||
run: | | ||
echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | ||
# Use conda for main dependencies | ||
- uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
miniforge-variant: Mambaforge | ||
miniforge-version: latest | ||
|
||
# Print the environment variables to simplify development and debugging | ||
- name: Environment Variables | ||
# Use bash in order to have same basic commands in all OSs | ||
shell: bash | ||
run: env | ||
|
||
# Remove apt repos on Ubuntu that are known to break from time to time | ||
# See https://github.com/actions/virtual-environments/issues/323 | ||
- name: Remove broken apt repos [Ubuntu] | ||
if: matrix.os == 'ubuntu-latest' | ||
run: | | ||
for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done | ||
# ============ | ||
# DEPENDENCIES | ||
# ============ | ||
- name: Restore cached conda based dependencies | ||
if: ${{ env.action-restore-cache == 'true' }} | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: ${{ env.CONDA }}/envs/test | ||
key: ${{ matrix.os }}-conda-${{ hashFiles('.github/workflows/conda-deps.yml') }}-${{ env.DATE }} | ||
id: cache-restore-conda-deps | ||
|
||
- name: Dependencies (using conda) | ||
shell: bash -l {0} | ||
if: steps.cache-restore-conda-deps.outputs.cache-hit != 'true' | ||
run: | | ||
mamba env update -f .github/workflows/conda-deps.yml | ||
- name: Cache conda based dependencies | ||
if: ${{ steps.cache-restore-conda-deps.outputs.cache-hit != 'true' }} | ||
uses: actions/cache/save@v3 | ||
with: | ||
path: ${{ env.CONDA }}/envs/test | ||
key: ${{ matrix.os }}-conda-${{ hashFiles('.github/workflows/conda-deps.yml') }}-${{ env.DATE }} | ||
id: cache-save-conda-deps | ||
|
||
- name: Restore cached source-based dependencies | ||
if: ${{ env.action-restore-cache == 'true' && steps.cache-restore-conda-deps.outputs.cache-hit == 'true' }} | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: ${{ github.workspace }}/install/deps | ||
key: ${{ matrix.os }}-${{ matrix.build_type }}-source-${{env.BipedalLocomotionFramework_TAG}}-${{ env.DATE }} | ||
id: cache-restore-source-deps | ||
|
||
- name: Source-based dependencies | ||
if: ${{ steps.cache-restore-conda-deps.outputs.cache-hit != 'true' || steps.cache-restore-source-deps.outputs.cache-hit != 'true' }} | ||
shell: bash -l {0} | ||
run: | | ||
# bipedal-locomotion-framework | ||
cd ${GITHUB_WORKSPACE} | ||
git clone https://github.com/ami-iit/bipedal-locomotion-framework blf | ||
cd blf | ||
git checkout ${BipedalLocomotionFramework_TAG} | ||
mkdir -p build | ||
cd build | ||
cmake -GNinja .. \ | ||
-DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/install/deps \ | ||
-DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install/deps | ||
cmake --build . --config ${{matrix.build_type}} --target install | ||
- name: Cache source-based dependencies | ||
if: ${{ steps.cache-restore-source-deps.outputs.cache-hit != 'true' }} | ||
uses: actions/cache/save@v3 | ||
with: | ||
path: ${{ github.workspace }}/install/deps | ||
key: ${{ matrix.os }}-${{ matrix.build_type }}-source-${{env.BipedalLocomotionFramework_TAG}}-${{ env.DATE }} | ||
id: cache-save-source-deps | ||
|
||
|
||
|
||
# =================== | ||
# CMAKE-BASED PROJECT | ||
# =================== | ||
# We will just configure and build the project now. Further modifications and tests can be added | ||
# Configure step | ||
- name: Configure | ||
shell: bash -l {0} | ||
run: | | ||
mkdir -p build | ||
cd build | ||
cmake -G"Ninja" .. \ | ||
-DCMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/install/deps \ | ||
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ | ||
-DFRAMEWORK_COMPILE_YarpImplementation=ON \ | ||
-DBUILD_TESTING:BOOL=ON \ | ||
-DCMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/install | ||
# Build step | ||
- name: Build | ||
shell: bash -l {0} | ||
run: | | ||
cd build | ||
cmake --build . --config ${{matrix.build_type}} --verbose | ||
# Test step | ||
- name: Test | ||
shell: bash -l {0} | ||
run: | | ||
cd build | ||
export PATH=$PATH:${GITHUB_WORKSPACE}/build/install/bin:${GITHUB_WORKSPACE}/install/deps/bin | ||
ctest --output-on-failure -C ${{ matrix.build_type }} . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#we use the default conda-incubator/setup-miniconda env name | ||
name: test | ||
dependencies: | ||
- cmake | ||
- clangxx>=14.0.0 | ||
- make | ||
- ninja | ||
- pkg-config | ||
- yarp | ||
- idyntree | ||
- spdlog | ||
- catch2>=3.3.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
function(add_baf_test) | ||
|
||
if(FRAMEWORK_COMPILE_tests) | ||
|
||
set(options ) | ||
set(oneValueArgs NAME) | ||
set(multiValueArgs SOURCES LINKS) | ||
|
||
set(prefix "baf") | ||
|
||
cmake_parse_arguments(${prefix} | ||
"${options}" | ||
"${oneValueArgs}" | ||
"${multiValueArgs}" | ||
${ARGN}) | ||
|
||
set(name ${${prefix}_NAME}) | ||
set(unit_test_files ${${prefix}_SOURCES}) | ||
|
||
set(targetname ${name}UnitTests) | ||
add_executable(${targetname} | ||
"${unit_test_files}") | ||
|
||
target_link_libraries(${targetname} PRIVATE Catch2::Catch2WithMain ${${prefix}_LINKS}) | ||
target_compile_definitions(${targetname} PRIVATE CATCH_CONFIG_FAST_COMPILE CATCH_CONFIG_DISABLE_MATCHERS) | ||
target_compile_features(${targetname} PUBLIC cxx_std_17) | ||
target_compile_definitions(${targetname} PRIVATE -D_USE_MATH_DEFINES) | ||
|
||
add_test(NAME ${targetname} COMMAND ${targetname}) | ||
|
||
endif() | ||
|
||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
cmake/BiomechanicalAnalysisFrameworkFindDependencies.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
include(CMakeDependentOption) | ||
|
||
macro(FRAMEWORK_DEPENDENT_OPTION _option _doc _default _deps _force) | ||
|
||
if(DEFINED ${_option}) | ||
get_property(_option_strings_set CACHE ${_option} PROPERTY STRINGS SET) | ||
if(_option_strings_set) | ||
# If the user thinks he is smarter than the machine, he deserves an error | ||
get_property(_option_strings CACHE ${_option} PROPERTY STRINGS) | ||
list(GET _option_strings 0 _option_strings_first) | ||
string(REGEX REPLACE ".+\"(.+)\".+" "\\1" _option_strings_first "${_option_strings_first}") | ||
list(LENGTH _option_strings _option_strings_length) | ||
math(EXPR _option_strings_last_index "${_option_strings_length} - 1") | ||
list(GET _option_strings ${_option_strings_last_index} _option_strings_last) | ||
if("${${_option}}" STREQUAL "${_option_strings_last}") | ||
message(SEND_ERROR "That was a trick, you cannot outsmart me! I will never let you win! ${_option} stays OFF until I say so! \"${_option_strings_first}\" is needed to enable ${_option}. Now stop bothering me, and install your dependencies, if you really want to enable this option.") | ||
endif() | ||
unset(${_option} CACHE) | ||
endif() | ||
endif() | ||
|
||
cmake_dependent_option(${_option} "${_doc}" ${_default} "${_deps}" ${_force}) | ||
|
||
unset(_missing_deps) | ||
foreach(_dep ${_deps}) | ||
string(REGEX REPLACE " +" ";" _depx "${_dep}") | ||
if(NOT (${_depx})) | ||
list(APPEND _missing_deps "${_dep}") | ||
endif() | ||
endforeach() | ||
|
||
if(DEFINED _missing_deps) | ||
set(${_option}_disable_reason " (dependencies unsatisfied: \"${_missing_deps}\")") | ||
# Set a value that can be visualized on ccmake and on cmake-gui, but | ||
# still evaluates to false | ||
set(${_option} "OFF - Dependencies unsatisfied: '${_missing_deps}' - ${_option}-NOTFOUND" CACHE STRING "${_option_doc}" FORCE) | ||
string(REPLACE ";" "\;" _missing_deps "${_missing_deps}") | ||
set_property(CACHE ${_option} | ||
PROPERTY STRINGS "OFF - Dependencies unsatisfied: '${_missing_deps}' - ${_option}-NOTFOUND" | ||
"OFF - You can try as much as you want, but '${_missing_deps}' is needed to enable ${_option} - ${_option}-NOTFOUND" | ||
"OFF - Are you crazy or what? '${_missing_deps}' is needed to enable ${_option} - ${_option}-NOTFOUND" | ||
"OFF - Didn't I already tell you that '${_missing_deps}' is needed to enable ${_option}? - ${_option}-NOTFOUND" | ||
"OFF - Stop it! - ${_option}-NOTFOUND" | ||
"OFF - This is insane! Leave me alone! - ${_option}-NOTFOUND" | ||
"ON - All right, you win. The option is enabled. Are you happy now? You just broke the build.") | ||
# Set non-cache variable that will override the value in current scope | ||
# For parent scopes, the "-NOTFOUND ensures that the variable still | ||
# evaluates to false | ||
set(${_option} ${_force}) | ||
endif() | ||
|
||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
add_subdirectory(Logging) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
add_biomechanical_analysis_library( | ||
NAME Logging | ||
PUBLIC_HEADERS include/BiomechanicalAnalysis/Logging/Logger.h | ||
SOURCES src/Logger.cpp | ||
PUBLIC_LINK_LIBRARIES BipedalLocomotion::TextLogging | ||
SUBDIRECTORIES YarpImplementation tests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
if(FRAMEWORK_COMPILE_YarpImplementation) | ||
|
||
add_biomechanical_analysis_library( | ||
NAME TextLoggingYarpImplementation | ||
SOURCES src/YarpLogger.cpp | ||
PUBLIC_HEADERS include/BiomechanicalAnalysis/Logging/YarpLogger.h | ||
PUBLIC_LINK_LIBRARIES BiomechanicalAnalysis::Logging | ||
BipedalLocomotion::TextLoggingYarpImplementation | ||
YARP::YARP_os | ||
INSTALLATION_FOLDER Logging) | ||
|
||
endif() |
18 changes: 18 additions & 0 deletions
18
src/Logging/YarpImplementation/include/BiomechanicalAnalysis/Logging/YarpLogger.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef BIOMECHANICAL_ANALYSIS_YARP_LOGGER_H | ||
#define BIOMECHANICAL_ANALYSIS_YARP_LOGGER_H | ||
|
||
namespace BiomechanicalAnalysis | ||
{ | ||
namespace Logging | ||
{ | ||
|
||
/** | ||
* Use YARP logger instead of the default one. | ||
* The method works only if the log has not yet been used | ||
*/ | ||
void useYarpLogger(); | ||
|
||
} | ||
} | ||
|
||
#endif // BIOMECHANICAL_ANALYSIS_YARP_LOGGER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <BiomechanicalAnalysis/Logging/Logger.h> | ||
#include <BiomechanicalAnalysis/Logging/YarpLogger.h> | ||
|
||
#include <BipedalLocomotion/TextLogging/YarpLogger.h> | ||
|
||
using namespace BipedalLocomotion::TextLogging; | ||
|
||
void BiomechanicalAnalysis::Logging::useYarpLogger() | ||
{ | ||
const static std::shared_ptr<YarpLoggerFactory> _bafYarpLoggerFactoryBasePtr = std::make_shared<YarpLoggerFactory>("baf"); | ||
const static std::shared_ptr<LoggerFactory> _bafYarpLogFactory = std::dynamic_pointer_cast<LoggerFactory>(_bafYarpLoggerFactoryBasePtr); | ||
BiomechanicalAnalysis::Logging::setLoggerFactory(_bafYarpLogFactory); | ||
} |
Oops, something went wrong.