mirror of
https://github.com/meshtastic/firmware.git
synced 2026-11-07 14:54:44 -05:00
Load optional modules dropped into src/modules/optional/ (#11673)
* Load optional modules dropped into src/modules/optional/ bin/optional-modules.py scans src/modules/optional/ for a directory <Name>/ holding <Name>.h and generates $BUILD_DIR/OptionalModules.h with an include and a setup<Name>() call for each, which Modules.cpp picks up through __has_include. The directory does not exist in a stock checkout, so a stock build generates a header that defines nothing, OPTIONAL_MODULES_SETUP compiles away, and nothing is registered. Sources under the directory are already covered by the default recursive build_src_filter, so dropping a module in needs no platformio.ini edit. * Address review: skip a module directory that is not a usable identifier The directory name becomes a setup<Name>() call, so foo-bar/ would have generated setupfoo-bar() and failed to compile with the error pointing at generated code rather than at the directory. Names that cannot form an identifier are now skipped with a message that names the directory.
This commit is contained in:
1 parent
b823c8d7fe
commit
427ed0f1a0
3 files changed
+77
No files matched your search
@@ -34,6 +34,11 @@
|
||||
#if !MESHTASTIC_EXCLUDE_BEACON
|
||||
#include "modules/MeshBeaconModule.h"
|
||||
#endif
|
||||
// Generated by bin/optional-modules.py from whatever sits in src/modules/optional/. Absent from a
|
||||
// stock checkout, and empty unless a module has been dropped in.
|
||||
#if __has_include("OptionalModules.h")
|
||||
#include "OptionalModules.h"
|
||||
#endif
|
||||
#if !MESHTASTIC_EXCLUDE_GPS
|
||||
#include "modules/PositionModule.h"
|
||||
#endif
|
||||
@@ -283,6 +288,11 @@ void setupModules()
|
||||
#endif
|
||||
#if defined(HAS_HARDWARE_WATCHDOG)
|
||||
watchdogThread = new WatchdogThread();
|
||||
#endif
|
||||
// Anything dropped into src/modules/optional/. Undefined, so compiled away, unless a module is
|
||||
// actually present.
|
||||
#ifdef OPTIONAL_MODULES_SETUP
|
||||
OPTIONAL_MODULES_SETUP();
|
||||
#endif
|
||||
// NOTE! This module must be added LAST because it likes to check for replies from other modules and avoid sending extra
|
||||
// acks
|
||||
|
||||
Reference in new issue
Block a user