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 537f28cbb8
commit 6b0c533d2c
10 changed files with 22 additions and 25 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 USE_OPT = $(EXTRA_PARAMS) $(DEBUG_LEVEL_OPT) $(RFLAGS) -fomit-frame-pointer -falign-functions=16 -fsingle-precision-constant
endif 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). # C specific options here (added to USE_OPT).
ifeq ($(USE_COPT),) 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 # disable CAN
DDEFS += -DEFI_CAN_SUPPORT=FALSE DDEFS += -DEFI_CAN_SUPPORT=FALSE
DDEFS += -DEFI_UNIT_TEST=0 -DEFI_PROD_CODE=1 -DEFI_SIMULATOR=0
# Compiler options here. # Compiler options here.
ifeq ($(USE_OPT),) 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 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

@ -243,16 +243,6 @@
#define EFI_EMULATE_POSITION_SENSORS TRUE #define EFI_EMULATE_POSITION_SENSORS TRUE
#endif #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? * Do we need file logging (like SD card) logic?
*/ */

View File

@ -1,6 +1,16 @@
#pragma once #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 #ifdef __cplusplus
class Engine; class Engine;

View File

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

View File

@ -40,7 +40,8 @@ ifeq ($(USE_OPT),)
endif endif
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),) ifeq ($(CCACHE_DIR),)
$(info No CCACHE_DIR) $(info No CCACHE_DIR)

View File

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

View File

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

View File

@ -35,6 +35,9 @@ endif
#USE_OPT += $(RUSEFI_OPT) #USE_OPT += $(RUSEFI_OPT)
#USE_OPT += -Wno-error=format= -Wno-error=register -Wno-error=write-strings #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),) ifeq ($(CCACHE_DIR),)
$(info No CCACHE_DIR) $(info No CCACHE_DIR)
else else

View File

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