Skip to content

Commit

Permalink
bump conan ant build GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
martukas committed May 5, 2024
1 parent 22c7742 commit a9afaac
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 59 deletions.
5 changes: 4 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ jobs:
name: Run tests & publish coverage
command: |
export FORCED_ROOT=1
./software/gui/gui.sh test -j --upload-cov
./software/gui/gui.sh test -j
- codecov/upload:
file: './software/gui/coverage_reports/coverage.info'
flags: 'gui'

debug-tests:
machine:
Expand Down
44 changes: 9 additions & 35 deletions software/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,49 +1,23 @@
cmake_minimum_required(VERSION 3.7.0 FATAL_ERROR)
project(ventilator_gui
LANGUAGES CXX C
VERSION 0.0.1
)

set(EXTRA_MODULES_DIR ${CMAKE_CURRENT_LIST_DIR}/cmake)
list(APPEND CMAKE_MODULE_PATH ${EXTRA_MODULES_DIR})
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})

#=============================================================================
# ensure build type first
# ensure build type before calling ConanConfig
#=============================================================================

include(EnsureBuildType)

#=============================================================================
# Conan
#=============================================================================

if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/0.18.1/conan.cmake"
"${CMAKE_BINARY_DIR}/conan.cmake"
TLS_VERIFY ON)
endif()
# This MUST run before the call to project()
# Otherwise the appropriate variables will not be set
include(ConanConfig)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_BINARY_DIR}/conan_toolchain.cmake)

set(CONAN_PROFILE "default" CACHE STRING "Name of conan profile to use, uses default by default")
set(CONAN "AUTO" CACHE STRING "conan options AUTO (conan must be in path), MANUAL (expects conanbuildinfo.cmake in build directory) or DISABLE")
if(${CONAN} MATCHES "AUTO")
include(${CMAKE_BINARY_DIR}/conan.cmake)
conan_cmake_run(CONANFILE conanfile.txt
PROFILE ${CONAN_PROFILE}
BASIC_SETUP NO_OUTPUT_DIRS KEEP_RPATHS
BUILD_TYPE "None"
BUILD outdated)
elseif(${CONAN} MATCHES "MANUAL")
if(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
conan_basic_setup(NO_OUTPUT_DIRS KEEP_RPATHS)
else()
message(FATAL_ERROR "CONAN set to MANUAL but no file named conanbuildinfo.cmake found in build directory")
endif()
elseif(NOT ${CONAN} MATCHES "DISABLE")
message(FATAL_ERROR "Unrecognised option for CONAN (${CONAN}), use AUTO, MANUAL or DISABLE")
endif()
project(ventilator_gui
LANGUAGES CXX C
VERSION 0.0.1
)

include(CompilerConfig)
include(OutputDirConfig)
Expand Down
9 changes: 9 additions & 0 deletions software/gui/CMakeUserPresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"version": 4,
"vendor": {
"conan": {}
},
"include": [
"/home/martin/dev/ventilator2/software/gui/build/CMakePresets.json"
]
}
24 changes: 24 additions & 0 deletions software/gui/cmake/ConanConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
find_program(
CONAN
NAMES conan
HINT ENV PATH
DOC "conan executable location"
)

if(NOT CONAN)
message(FATAL_ERROR "Could not find the command 'conan', which is required")
else()
message(STATUS "Found conan executable at: ${CONAN}")
endif()

set(
CONAN_ARGS
"install" "${CMAKE_SOURCE_DIR}" "--output-folder=${CMAKE_CURRENT_BINARY_DIR}" "--build=missing" "--settings=build_type=${CMAKE_BUILD_TYPE}"
)

execute_process(
COMMAND ${CONAN} ${CONAN_ARGS}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND_ECHO STDOUT
COMMAND_ERROR_IS_FATAL ANY
)
13 changes: 7 additions & 6 deletions software/gui/conanfile.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[requires]
fmt/9.1.0
spdlog/1.11.0
spdlog/1.13.0
fmt/10.2.1

[generators]
cmake
cmake_find_package
virtualbuildenv
virtualrunenv
CMakeDeps
CMakeToolchain

[options]
date/*:use_system_tz_db=True

[imports]
., *.dylib* -> ./lib @ keep_path=False
Expand Down
18 changes: 2 additions & 16 deletions software/gui/gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# ./gui.sh --help

# \todo: keep CONAN_VERSION updated, test thoroughly whenever you do, leave this "todo" here
CONAN_VERSION=1.59
CONAN_VERSION=2.2.3

# Fail if any command fails
set -e
Expand Down Expand Up @@ -126,8 +126,7 @@ configure_conan() {
pip3 install gitpython
pip3 install conan==$CONAN_VERSION
source "${HOME}/.profile"
conan profile new --detect default
conan profile update settings.compiler.libcxx=libstdc++11 default
conan profile detect
}

run_cppcheck() {
Expand Down Expand Up @@ -203,15 +202,6 @@ launch_browser() {
python -m webbrowser "${COVERAGE_OUTPUT_DIR}/index.html"
}

upload_coverage_reports() {
echo "Uploading coverage reports to Codecov"

curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov -F gui
rm codecov
}

########
# HELP #
########
Expand Down Expand Up @@ -359,10 +349,6 @@ elif [ "$1" == "test" ]; then
if [ "$2" != "--no-cov" ] && [ "$3" != "--no-cov" ] \
&& [ "$4" != "--no-cov" ] && [ "$5" != "--no-cov" ]; then
generate_coverage_reports
if [ "$2" == "--upload-cov" ] || [ "$3" == "--upload-cov" ] \
|| [ "$4" == "--upload-cov" ] || [ "$5" == "--upload-cov" ]; then
upload_coverage_reports
fi
fi

exit $EXIT_SUCCESS
Expand Down
2 changes: 1 addition & 1 deletion software/gui/src/gui_state_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ GuiStatus GuiStateContainer::GetGuiStatus() {
return VentMode::VentMode_HIGH_FLOW_NASAL_CANNULA;
default:
// Should never happen.
CRIT("Unexpected commanded_mode: {}", commanded_mode_);
CRIT("Unexpected commanded_mode: {}", fmt::underlying(commanded_mode_));

Check warning on line 50 in software/gui/src/gui_state_container.cpp

View check run for this annotation

Codecov / codecov/patch

software/gui/src/gui_state_container.cpp#L50

Added line #L50 was not covered by tests
return VentMode::VentMode_PRESSURE_CONTROL;
}
}();
Expand Down

0 comments on commit a9afaac

Please sign in to comment.