Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Checks: '-*,clang-analyzer-core.DivideZero,clang-analyzer-core.NullDereference,clang-analyzer-cplusplus.NewDelete,clang-analyzer-cplusplus.NewDeleteLeaks,clang-analyzer-unix.Malloc,bugprone-integer-division,bugprone-use-after-move'
WarningsAsErrors: 'clang-analyzer-core.DivideZero,clang-analyzer-core.NullDereference,clang-analyzer-cplusplus.NewDelete,clang-analyzer-cplusplus.NewDeleteLeaks,clang-analyzer-unix.Malloc,bugprone-integer-division,bugprone-use-after-move'
HeaderFilterRegex: '(^|/)(code/|extras/(rtkNmea|utils)/|extras/libcamera/LibCameraWrapper\.h$)'
41 changes: 29 additions & 12 deletions .github/workflows/sanity-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,25 @@ on:

jobs:
sanity-build:
name: Sanity Build
name: Sanity Build (${{ matrix.compiler.name }}, ${{ matrix.profile.name }})
runs-on: ubuntu-latest
permissions:
contents: read
container:
image: debian:bookworm
strategy:
fail-fast: false
matrix:
compiler:
- { name: gcc, cc: gcc, cxx: g++ }
- { name: clang, cc: clang, cxx: clang++ }
profile:
- { name: rpi5, header: mandeye-standard-rpi5.h, libcamera: 'OFF' }
- { name: cm5, header: mandeye-direct-cm5.h, libcamera: 'OFF' }
env:
CC: ${{ matrix.compiler.cc }}
CXX: ${{ matrix.compiler.cxx }}
BUILD_DIR: build-${{ matrix.compiler.name }}-${{ matrix.profile.name }}

steps:
- name: Install dependencies
Expand All @@ -21,22 +34,26 @@ jobs:
apt-get install -y -qq --no-install-recommends \
build-essential cmake git pkg-config ca-certificates \
libserial-dev libgpiod-dev libzmq3-dev libboost-all-dev \
libpistache-dev rapidjson-dev nlohmann-json3-dev libzmq3-dev cppzmq-dev \
libcamera-dev libopencv-dev pps-tools
libpistache-dev rapidjson-dev nlohmann-json3-dev cppzmq-dev pps-tools
update-ca-certificates

- name: Install Clang and clang-tidy
if: matrix.compiler.name == 'clang'
run: apt-get install -y -qq --no-install-recommends clang clang-tidy

- uses: actions/checkout@v4
with:
submodules: true

- name: Build - mandeye-standard-rpi5.h
- name: Configure
env:
HARDWARE_HEADER: ${{ matrix.profile.header }}
USE_LIBCAMERA: ${{ matrix.profile.libcamera }}
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Release \
-DMANDEYE_HARDWARE_HEADER=mandeye-standard-rpi5.h -DMANDEYE_USE_LIBCAMERA=FALSE
cmake --build build -j$(nproc)
cmake -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release \
-DMANDEYE_HARDWARE_HEADER="$HARDWARE_HEADER" \
-DMANDEYE_USE_LIBCAMERA="$USE_LIBCAMERA" \
-DMANDEYE_STRICT_BUILD=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

- name: Build - mandeye-direct-cm5.h
run: |
cmake -B build -DCMAKE_BUILD_TYPE=Release \
-DMANDEYE_HARDWARE_HEADER=mandeye-direct-cm5.h
cmake --build build -j$(nproc)
- name: Build
run: cmake --build "$BUILD_DIR" --parallel "$(nproc)"
31 changes: 31 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,37 @@ add_subdirectory(extras/FakePPS)
add_subdirectory(extras/SlavePPS)
add_subdirectory(extras/oled_status)

option(MANDEYE_STRICT_BUILD "Enable CI compiler warnings and Clang static analysis" OFF)
if(MANDEYE_STRICT_BUILD)
set(mandeye_warnings -Wall -Wextra -Werror=array-bounds -Werror=return-type -Werror=format -Werror=format=2)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
list(APPEND mandeye_warnings -Werror=address)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
list(APPEND mandeye_warnings -Werror=pointer-bool-conversion)
find_program(MANDEYE_CLANG_TIDY clang-tidy)
if(NOT MANDEYE_CLANG_TIDY)
message(FATAL_ERROR "MANDEYE_STRICT_BUILD with Clang requires clang-tidy")
endif()
if(TARGET livox_lidar_sdk_static)
# Keep diagnostics from the vendored SDK visible without its blanket -Werror.
target_compile_options(livox_lidar_sdk_static PRIVATE -Wno-error)
target_compile_options(livox_lidar_sdk_shared PRIVATE -Wno-error)
endif()
endif()

foreach(target IN ITEMS control_program led_demo button_demo
livox2_lib ouster_lib ouster_client_example sick_lib sick_client_example hesai_lib
mandeye_extra_utils mandeye_libcamera mandeye_extra_gnss mandeye_murata_uart_driver
mandeye_fake_pps slave_pps oled_status)
if(TARGET ${target})
target_compile_options(${target} PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${mandeye_warnings}>")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set_target_properties(${target} PROPERTIES CXX_CLANG_TIDY "${MANDEYE_CLANG_TIDY}")
endif()
endif()
endforeach()
endif()

install(FILES packing/helpers.sh DESTINATION /opt/mandeye/)
install(FILES packing/services/mandeye_controller.service DESTINATION /usr/lib/systemd/system)

Expand Down
3 changes: 2 additions & 1 deletion code/gnss.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <cstdint>
#include <deque>
#include <mutex>
#include <nlohmann/json.hpp>
Expand Down Expand Up @@ -60,6 +61,6 @@ class GNSSClient : public mandeye_utils::TimeStampReceiver
std::string RawEntryToLine(const std::string& line, double laserTimestamp);
//! Callbacks to call when new data is received
std::function<void(const minmea_sentence_gga& gga)> m_dataCallback;
std::atomic<unsigned uint32_t> m_messageCount{0};
std::atomic<std::uint32_t> m_messageCount{0};
};
} // namespace mandeye
4 changes: 2 additions & 2 deletions code/gpios.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ GpioClient::GpioClient(bool sim)
for(auto& [buttonID, ButtonName] : ButtonToName)
{
{
addButtonCallback(buttonID, "DBG" + ButtonName, [this, ButtonName]() {
addButtonCallback(buttonID, "DBG" + ButtonName, [this, name = ButtonName]() {
auto buzzerGPIO = m_ledGpio[LED::BUZZER];
setLed(buzzerGPIO, true);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
setLed(buzzerGPIO, false);
std::cout << "Button : " << ButtonName << std::endl;
std::cout << "Button : " << name << std::endl;
});
}
};
Expand Down
2 changes: 1 addition & 1 deletion code/led_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ int main(int arc, char* argv[])
{
using namespace hardware;
std::cout << "led_demo" << std::endl;
std::cout << mandeyeHarwareType << std::endl;
std::cout << mandeyeHarwareType() << std::endl;

std::shared_ptr<mandeye::GpioClient> gpioClientPtr;

Expand Down
6 changes: 3 additions & 3 deletions code/save_laz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ std::optional<mandeye::LazStats> mandeye::saveLaz(const std::string& filename, L
coordinates[2] = p.z;
if(laszip_set_coordinates(laszip_writer, coordinates))
{
fprintf(stderr, "DLL ERROR: setting coordinates for point %I64d\n", p_count);
fprintf(stderr, "DLL ERROR: setting coordinates for point %lld\n", static_cast<long long>(p_count));
return nullopt;
}

if(laszip_write_point(laszip_writer))
{
fprintf(stderr, "DLL ERROR: writing point %I64d\n", p_count);
fprintf(stderr, "DLL ERROR: writing point %lld\n", static_cast<long long>(p_count));
return nullopt;
}
}
Expand All @@ -175,7 +175,7 @@ std::optional<mandeye::LazStats> mandeye::saveLaz(const std::string& filename, L
return nullopt;
}

fprintf(stderr, "successfully written %I64d points\n", p_count);
fprintf(stderr, "successfully written %lld points\n", static_cast<long long>(p_count));
stats.m_pointsCount = p_count;
// close the writer

Expand Down
Loading