consolidate EFI_UNIT_TEST and friends (#1940)

* restructure

* guard c++

* idle too

* status_loop.h

* consolidate definitions

* use 1/0 instead, check for existence

* missed a few

* dead define

* defs for bootloader
This commit is contained in:
Matthew Kennedy 2020-11-11 17:34:39 -08:00 committed by GitHub
parent 8f40edf539
commit bb8650179c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 22 additions and 57 deletions

View File

@ -43,7 +43,10 @@ ifeq ($(USE_OPT),)
USE_OPT = $(EXTRA_PARAMS) $(DEBUG_LEVEL_OPT) $(RFLAGS) -fomit-frame-pointer -falign-functions=16 -fsingle-precision-constant
endif
USE_OPT += $(RUSEFI_OPT)
# EFI_UNIT_TEST determines if we are running in a unit test (hide things from hw/sim)
# EFI_PROD_CODE determines if we are running on real hardware (hide things from tests/sim)
# EFI_SIMULATOR determines if we are running in the simulator (hide things from hw/tests)
USE_OPT += $(RUSEFI_OPT) -DEFI_UNIT_TEST=0 -DEFI_PROD_CODE=1 -DEFI_SIMULATOR=0
# C specific options here (added to USE_OPT).
ifeq ($(USE_COPT),)

View File

@ -28,6 +28,8 @@ DDEFS += -DEFI_USB_SERIAL=FALSE -DHAL_USE_SERIAL_USB=FALSE -DHAL_USE_USB=FALSE -
# disable CAN
DDEFS += -DEFI_CAN_SUPPORT=FALSE
DDEFS += -DEFI_UNIT_TEST=0 -DEFI_PROD_CODE=1 -DEFI_SIMULATOR=0
# Compiler options here.
ifeq ($(USE_OPT),)
USE_OPT = $(EXTRA_PARAMS) $(DEBUG_LEVEL_OPT) $(RFLAGS) -Wno-error=implicit-fallthrough -Wno-error=bool-operation -fomit-frame-pointer -falign-functions=16 -Werror -Wno-error=pointer-sign -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=sign-compare -Wno-error=unused-parameter -Wno-error=missing-field-initializers -Werror=type-limits -Wno-error=strict-aliasing -Wno-error=attributes

View File

@ -200,12 +200,6 @@
#define EFI_EMULATE_POSITION_SENSORS TRUE
/**
* This macros is used to hide pieces of the code from unit tests, so it only makes sense in folders exposed to the tests project.
* This macros is NOT about taking out logging in general.
*/
#define EFI_PROD_CODE TRUE
/**
* Do we need file logging (like SD card) logic?
*/
@ -352,8 +346,6 @@
#define EFI_WARNING_LED FALSE
#define EFI_UNIT_TEST FALSE
#undef CONSOLE_MODE_SWITCH_PORT
#undef CONFIG_RESET_SWITCH_PORT
@ -391,7 +383,6 @@
[7] = {.port = NULL, .pad = 0},
#define EFI_BOSCH_YAW FALSE
#define ADC_SNIFFER FALSE
#define GPTDEVICE GPTD1
@ -404,8 +395,6 @@
#define EXTREME_TERM_LOGGING FALSE
#define EFI_PRINTF_FUEL_DETAILS FALSE
#define EFI_SIMULATOR FALSE
#define RAM_UNUSED_SIZE 1
#define CCM_UNUSED_SIZE 1

View File

@ -188,12 +188,6 @@
#define EFI_EMULATE_POSITION_SENSORS FALSE
#endif
/**
* This macros is used to hide pieces of the code from unit tests, so it only makes sense in folders exposed to the tests project.
* This macros is NOT about taking out logging in general.
*/
#define EFI_PROD_CODE TRUE
/**
* Do we need file logging (like SD card) logic?
*/
@ -321,8 +315,6 @@
#define EFI_WARNING_LED FALSE
#define EFI_UNIT_TEST FALSE
#undef CONSOLE_MODE_SWITCH_PORT
#undef CONFIG_RESET_SWITCH_PORT
@ -360,7 +352,6 @@
[7] = {.port = NULL, .pad = 0},
#define EFI_BOSCH_YAW FALSE
#define ADC_SNIFFER FALSE
#define GPTDEVICE GPTD1
@ -373,8 +364,6 @@
#define EXTREME_TERM_LOGGING FALSE
#define EFI_PRINTF_FUEL_DETAILS FALSE
#define EFI_SIMULATOR FALSE
#define RAM_UNUSED_SIZE 1
#define CCM_UNUSED_SIZE 1

View File

@ -202,16 +202,6 @@
#define EFI_EMULATE_POSITION_SENSORS TRUE
#endif
/**
* This macros is used to hide hardware-specific pieces of the code from unit tests and simulator, so it only makes
* sense in folders exposed to the tests projects (simulator and unit tests).
* This macros is NOT about taking out logging in general.
* See also EFI_UNIT_TEST
* See also EFI_SIMULATOR
* todo: do we want to rename any of these three options?
*/
#define EFI_PROD_CODE TRUE
/**
* Do we need file logging (like SD card) logic?
*/

View File

@ -243,16 +243,6 @@
#define EFI_EMULATE_POSITION_SENSORS TRUE
#endif
/**
* This macros is used to hide hardware-specific pieces of the code from unit tests and simulator, so it only makes
* sense in folders exposed to the tests projects (simulator and unit tests).
* This macros is NOT about taking out logging in general.
* See also EFI_UNIT_TEST
* See also EFI_SIMULATOR
* todo: do we want to rename any of these three options?
*/
#define EFI_PROD_CODE TRUE
/**
* Do we need file logging (like SD card) logic?
*/

View File

@ -1,6 +1,16 @@
#pragma once
#include "efifeatures.h"
#ifndef EFI_UNIT_TEST
#error EFI_UNIT_TEST must be defined!
#endif
#ifndef EFI_SIMULATOR
#error EFI_SIMULATOR must be defined!
#endif
#ifndef EFI_PROD_CODE
#error EFI_PROD_CODE must be defined!
#endif
#ifdef __cplusplus
class Engine;

View File

@ -590,10 +590,6 @@ void initHardware(Logging *l) {
initServo();
#endif
#if ADC_SNIFFER
initAdcDriver();
#endif
#if EFI_AUX_SERIAL
initAuxSerial();
#endif /* EFI_AUX_SERIAL */

View File

@ -40,7 +40,8 @@ ifeq ($(USE_OPT),)
endif
endif
USE_OPT += $(RUSEFI_OPT)
# See explanation in main firmware Makefile for these three defines
USE_OPT += $(RUSEFI_OPT) -DEFI_UNIT_TEST=0 -DEFI_PROD_CODE=0 -DEFI_SIMULATOR=1
ifeq ($(CCACHE_DIR),)
$(info No CCACHE_DIR)

View File

@ -67,8 +67,6 @@
#define CONSOLE_MAX_ACTIONS 256
#define EFI_SIMULATOR TRUE
#define EFI_PROD_CODE FALSE
#define TS_UART_DMA_MODE FALSE
#define EFI_MAP_AVERAGING TRUE
@ -157,7 +155,5 @@
*/
#define INTERMEDIATE_LOGGING_BUFFER_SIZE 2000
#define EFI_UNIT_TEST FALSE
#define EFI_BOARD_TEST FALSE
#define EFI_JOYSTICK FALSE

View File

@ -26,8 +26,6 @@
#define efiSetPadMode(msg, brainPin, mode) {}
#define EFI_UNIT_TEST FALSE
#define hasOsPanicError() (FALSE)
#define US_TO_NT_MULTIPLIER 100

View File

@ -35,6 +35,9 @@ endif
#USE_OPT += $(RUSEFI_OPT)
#USE_OPT += -Wno-error=format= -Wno-error=register -Wno-error=write-strings
# See explanation in main firmware Makefile for these three defines
USE_OPT += -DEFI_UNIT_TEST=1 -DEFI_PROD_CODE=0 -DEFI_SIMULATOR=0
ifeq ($(CCACHE_DIR),)
$(info No CCACHE_DIR)
else

View File

@ -42,8 +42,6 @@
#define DEBUG_INTERPOLATION TRUE
#define EFI_UNIT_TEST TRUE
#define EFI_FSIO TRUE
#define EFI_TEXT_LOGGING TRUE