From 285df2c4efdada63623bd78fa0a4ab215388b705 Mon Sep 17 00:00:00 2001 From: Quentin Date: Wed, 5 Feb 2025 09:33:00 +0100 Subject: [PATCH] Added check tools --- .cppcheck_suppressions.txt | 1 - .github/workflows/arduino.yml | 2 +- .github/workflows/platformio.yml | 8 ++++---- platformio.ini | 8 ++++++++ py_scripts/make_cpp_files.py | 13 ++++++++++++- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/.cppcheck_suppressions.txt b/.cppcheck_suppressions.txt index 740f6f2..e69de29 100644 --- a/.cppcheck_suppressions.txt +++ b/.cppcheck_suppressions.txt @@ -1 +0,0 @@ -unusedStructMember:src/event_source.h diff --git a/.github/workflows/arduino.yml b/.github/workflows/arduino.yml index e48fa32..e8e0091 100644 --- a/.github/workflows/arduino.yml +++ b/.github/workflows/arduino.yml @@ -3,7 +3,7 @@ name: Arduino Library on: pull_request: branches: - - master + - main jobs: Arduino-Checks: diff --git a/.github/workflows/platformio.yml b/.github/workflows/platformio.yml index 5cf2cdd..3d3e7c6 100644 --- a/.github/workflows/platformio.yml +++ b/.github/workflows/platformio.yml @@ -3,10 +3,10 @@ name: PlatformIO Library on: pull_request: branches: - - master + - main push: branches: - - master + - main tags: - "[0-9]+.[0-9]+.[0-9]+" @@ -16,11 +16,11 @@ jobs: with: pio-environment-list: '["selfManagedWifiUsage", "delegatedWifiUsage"]' - PilatformIO-Build: + PlatformIO-Build: uses: sensirion/.github/.github/workflows/upt.platformio.build.yml@main needs: PlatformIO-Check with: - pio-environment-list: '["selfManagedWifUsage", "delegatedWifiUsage"]' + pio-environment-list: '["selfManagedWifiUsage", "delegatedWifiUsage"]' PlatformIO-Package: if: ${{ (github.ref_type != 'tag') && (github.ref_name == 'master') }} diff --git a/platformio.ini b/platformio.ini index 1abafec..7d6fe69 100644 --- a/platformio.ini +++ b/platformio.ini @@ -27,6 +27,14 @@ lib_deps = sensirion/Sensirion UPT Core@^0.5.1 lib_extra_dirs = ${PROJECT_DIR}/src/* +check_tool = cppcheck, clangtidy +check_skip_packages = yes +check_flags= + clangtidy: --style=file + cppcheck: --suppress=unusedFunction +check_src_filters = + +<${PROJECT_DIR}/src/> + +<${PROJECT_DIR}/examples/> [env:selfManagedWifiUsage] build_src_filter = +<*> -<.git/> -<.svn/> +<${common.selfManagedWifiUsage_srcdir}> diff --git a/py_scripts/make_cpp_files.py b/py_scripts/make_cpp_files.py index 389c629..042c786 100644 --- a/py_scripts/make_cpp_files.py +++ b/py_scripts/make_cpp_files.py @@ -1,5 +1,16 @@ import os +import shutil + +ARDUINO_FILE_EXTENSION = ".ino" +TARGET_FILE_EXTENSION = ".cpp" +EXAMPLE_FOLDER = "examples" # Create a .cpp file for all the .ino files in the examples dir (CAUTION: will overwrite existing) print("PRE_SCRIPT: Copying .ino file contents to .cpp files.") -os.system(f'find examples -type f -name "*.ino" -exec bash -c \'for file; do cp "$file" "$(dirname "$file")/$(basename "$file" .ino).cpp"; done\' _ {{}} +') +for e in os.listdir(EXAMPLE_FOLDER): + if os.path.isdir(f"{EXAMPLE_FOLDER}/{e}") and os.path.isfile(f"{EXAMPLE_FOLDER}/{e}/{e}{ARDUINO_FILE_EXTENSION}"): + arduino_file =f"{EXAMPLE_FOLDER}/{e}/{e}{ARDUINO_FILE_EXTENSION}" + cpp_file = f"{EXAMPLE_FOLDER}/{e}/{e}{TARGET_FILE_EXTENSION}" + shutil.copyfile(arduino_file, cpp_file) + print(f'\tcopied {arduino_file} to {cpp_file}') +print("\t>> Done.") \ No newline at end of file