set up precompiled header (#2971)

* ignore

* set up precompiled header

* makefile

* fixes

* cleanup

* only depend cpp on pch

* efifeatures in pch

* f7 efifeatures

* consolidate

* simulator

* proteus build

* error handling is a good one

* bootloader pch

* don't auto include pch

* dirs

* delete on clean

* bootloader cleans

* clean.sh deletes pch

* disable in bl for now

* there was a typo so maybe it'll work now

* remove todo

* don't need that any more

* don't need these parts

* don't need this part

* undo changes

* use a different cpp as example

* s

* Revert "cleanup"

This reverts commit 8de8698490f5d09c2df753f00a89751aa898be9a.

* also unnecessary now

* buh

* comment

Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
Matthew Kennedy 2021-07-25 18:23:23 -07:00 committed by GitHub
parent 4b3345a6dd
commit f44a84b40c
13 changed files with 96 additions and 20 deletions

4
firmware/.gitignore vendored
View File

@ -4,3 +4,7 @@ gen_*.log
deliver/
rusefi_tool.log
build*
# precompiled headers
*.h.gch
*.h.gcno

View File

@ -13,6 +13,10 @@ include rusefi_rules.mk
PROJECT = rusefi
PROJECT_DIR = .
# Configure precompiled header
PCH_DIR = $(PROJECT_DIR)/pch
PCHSRC = $(PCH_DIR)/pch.h
# Imported source files and paths
CHIBIOS_CONTRIB = ChibiOS-Contrib
@ -55,7 +59,7 @@ endif
# C++ specific options here (added to USE_OPT).
ifeq ($(USE_CPPOPT),)
USE_CPPOPT = -std=c++17 -Wno-register -fno-rtti -fno-threadsafe-statics -fno-exceptions -fno-use-cxa-atexit
USE_CPPOPT = -std=c++17 -Wno-register -fno-rtti -fno-threadsafe-statics -fno-exceptions -fno-use-cxa-atexit -Winvalid-pch
endif
# Hellen is one of the boards which cares
@ -270,7 +274,9 @@ TCPPSRC =
ASMXSRC = $(ALLXASMSRC) \
$(RUSEFIASM)
INCDIR = $(ALLINC) \
INCDIR = \
$(PCH_DIR) \
$(ALLINC) \
$(TESTINC) \
$(BOOTLOADERINC) \
$(CHIBIOS)/os/various \
@ -372,3 +378,6 @@ ULIBS = -lm --specs=nano.specs
##############################################################################
include $(RULESFILE)
# Enable precompiled header
include rusefi_pch.mk

0
firmware/bootloader/compile_bootloader.sh Normal file → Executable file
View File

View File

@ -39,7 +39,7 @@ endif
# C++ specific options here (added to USE_OPT).
ifeq ($(USE_CPPOPT),)
# constexpr float expf_taylor_impl probably needs just c++14 but why not go with 17?
USE_CPPOPT = -std=c++17 -Wno-register -fno-rtti -fno-exceptions -fno-use-cxa-atexit -Werror=write-strings -Werror=type-limits
USE_CPPOPT = -std=c++17 -Wno-register -fno-rtti -fno-exceptions -fno-use-cxa-atexit -Werror=write-strings -Werror=type-limits -Winvalid-pch
endif
# Enable this if you want the linker to remove unused code and data
@ -117,6 +117,10 @@ endif
PROJECT = bootloader
PROJECT_DIR = ..
# Configure precompiled header
PCH_DIR = $(PROJECT_DIR)/pch
PCHSRC = $(PCH_DIR)/pch.h
# Imported source files and paths
CHIBIOS = $(PROJECT_DIR)/ChibiOS
# todo: looks like 'CHIBIOS_CONTRIB' path is universal shall we defined it only once?
@ -209,6 +213,7 @@ TCPPSRC =
ASMXSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
INCDIR = $(ALLINC) \
$(PCH_DIR) \
.. \
$(CHIBIOS)/os/various \
$(CHIBIOS)/os/ex/ST \
@ -317,3 +322,4 @@ ULIBS = -lm --specs=nano.specs
##############################################################################
include $(RULESFILE)
include $(PROJECT_DIR)/rusefi_pch.mk

View File

@ -3,3 +3,4 @@
echo "Entering firmware/clean.sh"
rm -rf .dep
rm -rf build
rm -f pch/pch.h.gch

View File

@ -30,7 +30,7 @@ endif
# disable hardware serial ports on H7
ifeq ($(PROJECT_CPU),ARCH_STM32H7)
DDEFS += -DTS_NO_PRIMARY -DTS_NO_SECONDARY
DDEFS += -DTS_NO_PRIMARY -DTS_NO_SECONDARY
else
# Hardware serial port on UART 2 -> PD5/PD6
DDEFS += -DSTM32_UART_USE_USART2=TRUE

View File

@ -9,19 +9,15 @@
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#include "engine.h"
#include "allsensors.h"
#include "efi_gpio.h"
#include "pin_repository.h"
#include "pch.h"
#include "trigger_central.h"
#include "fuel_math.h"
#include "engine_math.h"
#include "advance_map.h"
#include "speed_density.h"
#include "advance_map.h"
#include "os_util.h"
#include "os_access.h"
#include "settings.h"
#include "aux_valves.h"
#include "map_averaging.h"
#include "fsio_impl.h"
@ -29,7 +25,6 @@
#include "backup_ram.h"
#include "idle_thread.h"
#include "idle_hardware.h"
#include "sensor.h"
#include "gppwm.h"
#include "tachometer.h"
#include "dynoview.h"
@ -40,10 +35,6 @@
#include "mc33816.h"
#endif // EFI_MC33816
#if EFI_TUNER_STUDIO
#include "tunerstudio_outputs.h"
#endif /* EFI_TUNER_STUDIO */
#if EFI_PROD_CODE
#include "trigger_emulator_algo.h"
#include "bench_test.h"

26
firmware/pch/pch.h Normal file
View File

@ -0,0 +1,26 @@
/**
* @file pch.h
*
* This file is rusEFI's precompiled header. Most cpp files should include
* this file in lieu of any of the files below.
*
* This helps compilation performance by parsing/analyzing these files only
* once, then re-loading that precompiled data for every file that includes
* this file.
*/
#include "efifeatures.h"
#include "engine_ptr.h"
#include "global.h"
#include "efi_gpio.h"
#include "engine.h"
#include "engine_configuration.h"
#include "engine_controller.h"
#include "tunerstudio_outputs.h"
#include "engine_math.h"
#include "pwm_generator_logic.h"
#include "allsensors.h"
#include "sensor.h"
#include "error_handling.h"
#include "settings.h"

24
firmware/rusefi_pch.mk Normal file
View File

@ -0,0 +1,24 @@
# Add the PCH dir to source path
SRCPATHS += $(PCH_DIR)
PCHOBJ = $(addprefix $(PCH_DIR)/, $(notdir $(PCHSRC:.h=.h.gch)))
# Compile precompiled header file(s) as a cpp file, but output to .h.gch file
$(PCHOBJ) : $(PCH_DIR)/%.h.gch : %.h Makefile
ifeq ($(USE_VERBOSE_COMPILE),yes)
@echo
$(CPPC) -c $(CPPFLAGS) $(AOPT) -I. $(IINCDIR) $< -o $@
else
@echo Compiling $(<F)
@$(CPPC) -c $(CPPFLAGS) $(AOPT) -I. $(IINCDIR) $< -o $@
endif
# Make all cpp objects explicitly depend on the PCH
$(TCPPOBJS) : $(PCHOBJ)
$(ACPPOBJS) : $(PCHOBJ)
# Delete PCH output on clean
CLEAN_RULE_HOOK:
rm -f $(PCHOBJ)

View File

@ -23,6 +23,10 @@ PROJECT_CPU=simulator
include ../firmware/rusefi.mk
RULESFILE = ../firmware/rusefi_rules.mk
# Configure precompiled header
PCH_DIR = $(PROJECT_DIR)/pch
PCHSRC = $(PCH_DIR)/pch.h
# used by USE_SMART_BUILD
CONFDIR = .
@ -60,7 +64,7 @@ endif
# C++ specific options here (added to USE_OPT).
ifeq ($(USE_CPPOPT),)
USE_CPPOPT = -std=c++17 -Wno-register -fno-rtti
USE_CPPOPT = -std=c++17 -Wno-register -fno-rtti -Winvalid-pch
endif
# Enable this if you want the linker to remove unused code and data.
@ -193,6 +197,7 @@ CPPSRC = $(ALLCPPSRC) \
ASMSRC = $(PORTASM)
INCDIR = . \
$(PCH_DIR) \
$(ALLINC) \
$(CHIBIOS)/os/various/cpp_wrappers \
$(UTIL_INC) \
@ -290,3 +295,6 @@ endif
##############################################################################
include $(RULESPATH)/rules.mk
# Enable precompiled header
include $(PROJECT_DIR)/rusefi_pch.mk

View File

@ -62,7 +62,9 @@ CPPSRC += $(ALLCPPSRC) \
$(PROJECT_DIR)/console/binary/tooth_logger.cpp \
$(PROJECT_DIR)/console/binary_log/log_field.cpp \
INCDIR += $(UNIT_TESTS_DIR) \
INCDIR += \
$(PCH_DIR) \
$(UNIT_TESTS_DIR) \
$(ALLINC) \
$(UTIL_INC) \
$(PROJECT_DIR)/config/engines \

View File

@ -174,11 +174,13 @@ else
@$(LD) $(OBJS) $(LDFLAGS) $(LIBS) -o $@
endif
clean:
clean: CLEAN_RULE_HOOK
@echo Cleaning
-rm -fR .dep $(BUILDDIR)
@echo Done
CLEAN_RULE_HOOK:
#
# Include the dependency files, should be the last of the makefile
#

View File

@ -8,6 +8,8 @@ INCDIR += $(UNIT_TESTS_DIR)/googletest/googlemock/include \
$(UNIT_TESTS_DIR)/googletest/googletest \
$(UNIT_TESTS_DIR)/googletest/googletest/include \
PCH_DIR = ../firmware/pch
PCHSRC = $(PCH_DIR)/pch.h
include $(PROJECT_DIR)/rusefi_rules.mk
@ -45,7 +47,7 @@ endif
# C++ specific options here (added to USE_OPT).
ifeq ($(USE_CPPOPT),)
USE_CPPOPT = -std=gnu++17 -fno-rtti -fpermissive -fexceptions -fno-use-cxa-atexit
USE_CPPOPT = -std=gnu++17 -fno-rtti -fpermissive -fexceptions -fno-use-cxa-atexit -Winvalid-pch
endif
# Enable this if you want the linker to remove unused code and data
@ -191,3 +193,4 @@ $(error Please run 'make' again. Please make sure you have 'git' command in PATH
endif
include $(UNIT_TESTS_DIR)/rules.mk
include $(PROJECT_DIR)/rusefi_pch.mk