From fa75824948fa6fbf088d4a1fcdab7633fc46df48 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 6 Nov 2020 10:39:55 +1100 Subject: [PATCH] AP_DAL: added standalone link test useful to check for clean linking of EKF2/EKF3 Co-authored-by: Peter Barker --- .../examples/AP_DAL_Standalone/main.cpp | 67 +++++++++++++++++++ .../AP_DAL/examples/AP_DAL_Standalone/wscript | 24 +++++++ 2 files changed, 91 insertions(+) create mode 100644 libraries/AP_DAL/examples/AP_DAL_Standalone/main.cpp create mode 100644 libraries/AP_DAL/examples/AP_DAL_Standalone/wscript diff --git a/libraries/AP_DAL/examples/AP_DAL_Standalone/main.cpp b/libraries/AP_DAL/examples/AP_DAL_Standalone/main.cpp new file mode 100644 index 0000000000..0940deff9e --- /dev/null +++ b/libraries/AP_DAL/examples/AP_DAL_Standalone/main.cpp @@ -0,0 +1,67 @@ +// +// Ensure that AP_NavEKF3 can be compiled when not linked to anything +// except the DAL. +// + +#include + +#include + +#include + +void AP_Param::setup_object_defaults(void const*, AP_Param::GroupInfo const*) {} + +int AP_HAL::Util::vsnprintf(char*, unsigned long, char const*, va_list) { return -1; } + +void *nologger = nullptr; +AP_Logger &AP::logger() { + return *((AP_Logger*)nologger); // this is not usually a good idea... +} +void AP_Logger::WriteBlock(void const*, unsigned short) {} + +class AP_HAL_DAL_Standalone : public AP_HAL::HAL { +public: + AP_HAL_DAL_Standalone() : + AP_HAL::HAL( + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr + ) {} + void run(int argc, char* const argv[], Callbacks* callbacks) const override {} + void setup() { } + void loop() { } +}; + +AP_HAL_DAL_Standalone _hal; +const AP_HAL::HAL &hal = _hal; + +NavEKF2 navekf2; +NavEKF3 navekf3; + +int main(int argc, const char *argv[]) +{ + navekf2.InitialiseFilter(); + navekf3.InitialiseFilter(); + navekf2.UpdateFilter(); + navekf3.UpdateFilter(); + return navekf2.healthy() && navekf3.healthy()?0:1; +} diff --git a/libraries/AP_DAL/examples/AP_DAL_Standalone/wscript b/libraries/AP_DAL/examples/AP_DAL_Standalone/wscript new file mode 100644 index 0000000000..1cd5fd20cb --- /dev/null +++ b/libraries/AP_DAL/examples/AP_DAL_Standalone/wscript @@ -0,0 +1,24 @@ +#!/usr/bin/env python +# encoding: utf-8 + +def build(bld): + bld.ap_stlib( + name='AP_DAL' + '_libs', + ap_vehicle='AP_DAL_Standalone', + ap_libraries=[ + 'AP_NavEKF2', + 'AP_NavEKF3', + 'AP_NavEKF', + 'AP_Common', + 'AP_Math', + 'AP_DAL', + 'AP_InternalError', + 'AP_Declination', + 'AP_RTC', + ], + ) + + bld.ap_program( + program_groups=['examples'], + use='AP_DAL_libs', + )