diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..64728e3 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,34 @@ +FROM mcr.microsoft.com/devcontainers/cpp:2-ubuntu24.04 + +ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="none" + +# Optionally install the cmake for vcpkg +COPY ./reinstall-cmake.sh /tmp/ + +RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \ + chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \ + fi \ + && rm -f /tmp/reinstall-cmake.sh + +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ + && apt-get install -y --no-install-recommends \ + build-essential \ + clang-format \ + clang-tidy \ + cmake \ + cppcheck \ + distcc \ + gdb \ + git \ + ninja-build \ + valgrind \ + gcc-arm-none-eabi libnewlib-arm-none-eabi \ + doxygen graphviz \ + && rm -rf /var/lib/apt/lists/* + +# [Optional] Uncomment this section to install additional vcpkg ports. +# RUN su vscode -c "${VCPKG_ROOT}/vcpkg install " + +# [Optional] Uncomment this section to install additional packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends diff --git a/.devcontainer/devcontainer-lock.json b/.devcontainer/devcontainer-lock.json new file mode 100644 index 0000000..e69de29 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..314e66d --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,28 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/cpp +{ + "name": "C++", + "build": { + "dockerfile": "Dockerfile" + }, + "customizations": { + "vscode": { + "extensions": [ + "ms-vscode.cpptools-extension-pack", + "matepek.vscode-catch2-test-adapter" + ] + } + } + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "gcc -v", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.devcontainer/reinstall-cmake.sh b/.devcontainer/reinstall-cmake.sh new file mode 100644 index 0000000..a37a3c2 --- /dev/null +++ b/.devcontainer/reinstall-cmake.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +#------------------------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. +#------------------------------------------------------------------------------------------------------------- +# +set -e + +CMAKE_VERSION=${1:-"none"} + +if [ "${CMAKE_VERSION}" = "none" ]; then + echo "No CMake version specified, skipping CMake reinstallation" + exit 0 +fi + +# Cleanup temporary directory and associated files when exiting the script. +cleanup() { + EXIT_CODE=$? + set +e + if [[ -n "${TMP_DIR}" ]]; then + echo "Executing cleanup of tmp files" + rm -Rf "${TMP_DIR}" + fi + exit $EXIT_CODE +} +trap cleanup EXIT + + +echo "Installing CMake..." +apt-get -y purge --auto-remove cmake +mkdir -p /opt/cmake + +architecture=$(dpkg --print-architecture) +case "${architecture}" in + arm64) + ARCH=aarch64 ;; + amd64) + ARCH=x86_64 ;; + *) + echo "Unsupported architecture ${architecture}." + exit 1 + ;; +esac + +CMAKE_BINARY_NAME="cmake-${CMAKE_VERSION}-linux-${ARCH}.sh" +CMAKE_CHECKSUM_NAME="cmake-${CMAKE_VERSION}-SHA-256.txt" +TMP_DIR=$(mktemp -d -t cmake-XXXXXXXXXX) + +echo "${TMP_DIR}" +cd "${TMP_DIR}" + +curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_BINARY_NAME}" -O +curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_CHECKSUM_NAME}" -O + +sha256sum -c --ignore-missing "${CMAKE_CHECKSUM_NAME}" +sh "${TMP_DIR}/${CMAKE_BINARY_NAME}" --prefix=/opt/cmake --skip-license + +ln -s /opt/cmake/bin/ccmake /usr/local/bin/ccmake +ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake +ln -s /opt/cmake/bin/cmake-gui /usr/local/bin/cmake-gui +ln -s /opt/cmake/bin/cpack /usr/local/bin/cpack +ln -s /opt/cmake/bin/ctest /usr/local/bin/ctest diff --git a/CHANGELOG.md b/CHANGELOG.md index 7269809..9c55aef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,18 @@ Hotfix release. ### Security ### Known Issue +## [v1.2.0] 2026-07-12 +Based on the Raspberry Pi Pico SDK v2.0.0. +### Added +- [Issue #25](https://github.com/suikan4github/rpp_driver/issues/25) Add wider API support of RasPi Pico SDK +- [Issue #27](https://github.com/suikan4github/rpp_driver/issues/27) Add Devcontainer support +### Changed +### Deprecated +### Removed +### Fixed +### Security +### Known Issue + ## [v1.1.1] 2024-10-22 Hotfix release. @@ -79,7 +91,8 @@ First official release of the rpp_driver ( Raspberry Pi Pico Driver) class libra ## [v0.9.0] 2024-09-28 Pre-release version. -[Unreleased]: https://github.com/suikan4github/rpp_driver/compare/v1.1.1...develop +[Unreleased]: https://github.com/suikan4github/rpp_driver/compare/v1.2.0...develop +[v1.2.0]: https://github.com/suikan4github/rpp_driver/compare/v1.1.1...v1.2.0 [v1.1.1]: https://github.com/suikan4github/rpp_driver/compare/v1.1.0...v1.1.1 [v1.1.0]: https://github.com/suikan4github/rpp_driver/compare/v1.0.0...v1.1.0 [v1.0.0]: https://github.com/suikan4github/rpp_driver/compare/v0.9.0...v1.0.0 diff --git a/README.md b/README.md index 5a9f114..5da6cc3 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,10 @@ An online [HTML documentation](https://suikan4github.github.io/rpp_driver/) is a # Details This class collection ( or class library ) encapsules the certain data structure of Pico SDK behind the classes. And it also allows programmers to use the dependency-injection in their projects. So, programmers can test their code with [Google Test](https://github.com/google/googletest) before testing on the target hardware. - +k The following classes are provided in this version. -| Class | Header file | Description | +| Class | Header fkvile | Description | |---------------------------------|---- |----------------------------- | | ::rpp_driver::SdkWrapper | sdk/sdkwrapper.hpp | Wrapper class of Pico SDK | | ::rpp_driver::GpioBasic | gpio/gpiobasic.hpp | Basic GPIO controller | @@ -39,6 +39,9 @@ git clone --recursive https://github.com/suikan4github/rpp_driver-sample.git # Tools and building ## How to install the tools +> [!NOTE] +> These tools are automatically installed if you use the VSCode Dev Container. + To build the sample program and/or test program, you need to install the build tools. The followings are the command to install these tools on Ubuntu. diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d5c946b..bdbda19 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -8,6 +8,28 @@ file(GLOB SOURCES CMAKE_CONFIGURE_DEPENDS "./*.cpp") # Add the executable for the testcase which is using googletest add_executable(${PROJECT_NAME} ${SOURCES}) +# Remove coverage artifacts before running tests to avoid false positives +# This will prevent the error of the coverage report. +# On the other hande, this build cannot accumulate coverage data across +# multiple runs, but it is a tradeoff to avoid the error. +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/reset_coverage.cmake" [=[ +file(GLOB_RECURSE coverage_artifacts + "${PROJECT_BINARY_DIR}/CMakeFiles/${PROJECT_NAME}.dir/*.gcda" + "${PROJECT_BINARY_DIR}/CMakeFiles/${PROJECT_NAME}.dir/*.gcno") +if(coverage_artifacts) + file(REMOVE ${coverage_artifacts}) +endif() +]=]) + +add_custom_target(reset_coverage + COMMAND ${CMAKE_COMMAND} + -DPROJECT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR} + -DPROJECT_NAME=${PROJECT_NAME} + -P "${CMAKE_CURRENT_BINARY_DIR}/reset_coverage.cmake" + VERBATIM) + +add_dependencies(${PROJECT_NAME} reset_coverage) + # Add the library under test. target_link_libraries(${PROJECT_NAME} GTest::gmock_main