fome-fw/unit_tests/unit_test_rules.mk

204 lines
5.5 KiB
Makefile
Raw Normal View History

2021-05-07 14:43:24 -07:00
UNIT_TESTS_DIR=$(PROJECT_DIR)/../unit_tests
CPPSRC += gtest-all.cpp \
gmock-all.cpp \
2021-05-07 14:43:24 -07:00
2021-05-07 14:18:18 -07:00
2021-05-07 14:43:24 -07:00
INCDIR += $(UNIT_TESTS_DIR)/googletest/googlemock/include \
$(UNIT_TESTS_DIR)/googletest/googletest \
$(UNIT_TESTS_DIR)/googletest/googletest/include \
2021-05-07 14:43:24 -07:00
PCH_DIR = ../firmware/pch
PCHSRC = $(PCH_DIR)/pch.h
PCHSUB = unit_tests
2021-05-07 14:43:24 -07:00
include $(PROJECT_DIR)/rusefi_rules.mk
2021-05-07 14:18:18 -07:00
BOARDS_DIR = $(PROJECT_DIR)/config/boards
# User may want to pass in a forced value for SANITIZE
2024-03-17 03:13:28 -07:00
# ifeq ($(SANITIZE),)
# SANITIZE = yes
2024-03-17 03:13:28 -07:00
# endif
SANITIZE = no
IS_MAC = no
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
IS_MAC = yes
endif
2021-05-07 14:18:18 -07:00
# Compiler options here.
ifeq ($(USE_OPT),)
# -O2 is needed for mingw, without it there is a linking issue to isnanf?!?!
#USE_OPT = $(RFLAGS) -O2 -fgnu89-inline -ggdb -fomit-frame-pointer -falign-functions=16 -std=gnu99 -Werror-implicit-function-declaration -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
USE_OPT = -c -Wall -O0 -ggdb -g
USE_OPT += -Werror=missing-field-initializers
endif
ifeq ($(COVERAGE),yes)
USE_OPT += -fprofile-arcs -ftest-coverage
endif
2021-05-07 14:18:18 -07:00
#TODO! this is a nice goal
#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
2021-09-07 14:39:04 -07:00
2021-05-07 14:18:18 -07:00
# Pretend we are all different hardware so that all canned engine configs are included
2021-07-02 13:31:10 -07:00
USE_OPT += -DHW_MICRO_RUSEFI=1 -DHW_PROTEUS=1 -DHW_FRANKENSO=1 -DHW_HELLEN=1
2021-05-07 14:18:18 -07:00
# C specific options here (added to USE_OPT).
ifeq ($(USE_COPT),)
USE_COPT = -std=gnu99 -fgnu89-inline
endif
# C++ specific options here (added to USE_OPT).
ifeq ($(USE_CPPOPT),)
USE_CPPOPT = -std=gnu++2a -fno-rtti -fno-use-cxa-atexit
2021-05-07 14:18:18 -07:00
endif
2023-11-01 15:37:00 -07:00
USE_CPPOPT += $(RUSEFI_CPPOPT)
# Enable address sanitizer for C++ files, but not on Windows since x86_64-w64-mingw32-g++ doesn't support it.
# only c++ because lua does some things asan doesn't like, but don't actually cause overruns.
ifeq ($(SANITIZE),yes)
ifeq ($(IS_MAC),yes)
USE_CPPOPT += -fsanitize=address
else
USE_CPPOPT += -fsanitize=address -fsanitize=bounds-strict -fno-sanitize-recover=all
endif
endif
2021-05-07 14:18:18 -07:00
# Enable this if you want the linker to remove unused code and data
ifeq ($(USE_LINK_GC),)
USE_LINK_GC = yes
endif
# Enable this if you want to see the full log while compiling.
ifeq ($(USE_VERBOSE_COMPILE),)
USE_VERBOSE_COMPILE = no
endif
# C sources to be compiled in ARM mode regardless of the global setting.
ACSRC =
# C++ sources to be compiled in ARM mode regardless of the global setting.
ACPPSRC =
# List ASM source files here
ASMSRC =
2021-05-07 09:36:30 -07:00
##############################################################################
# Compiler settings
#
TRGT =
2021-05-07 09:36:30 -07:00
2023-11-02 11:28:14 -07:00
CC = $(TRGT)gcc
CPPC = $(TRGT)g++
2021-05-07 09:36:30 -07:00
# Enable loading with g++ only if you need C++ runtime support.
# NOTE: You can use C++ even without C++ support if you are careful. C++
# runtime support makes code size explode.
#LD = $(TRGT)gcc
LD = $(TRGT)g++
CP = $(TRGT)objcopy
AS = $(TRGT)gcc -x assembler-with-cpp
OD = $(TRGT)objdump
HEX = $(CP) -O ihex
BIN = $(CP) -O binary
# Define C warning options here
CWARN = -Wall -Wextra -Wstrict-prototypes -pedantic -Wmissing-prototypes -Wold-style-definition
# Define C++ warning options here
CPPWARN = -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -Wno-unused-variable -Wno-format -Wno-unused-parameter -Wno-unused-private-field
#
# Compiler settings
##############################################################################
##############################################################################
# Start of default section
#
# List all default ASM defines here, like -D_DEBUG=1
DADEFS =
# List all default directories to look for include files here
DINCDIR =
# List the default directory to look for the libraries here
DLIBDIR =
# List all default libraries here
ifeq ($(OS),Windows_NT)
# Windows
$(error Builds on windows are not supported by FOME")
2021-05-07 09:36:30 -07:00
else
# Linux
DLIBS = -pthread
endif
#
# End of default section
##############################################################################
##############################################################################
# Start of user section
#
# List all user C define here, like -D_DEBUG=1
UDEFS =
# Define ASM defines here
UADEFS =
# List all user directories here
UINCDIR =
# List the user directory to look for the libraries here
ULIBDIR =
# List all user libraries here
ULIBS = -lm
ifeq ($(COVERAGE),yes)
ULIBS += --coverage
endif
2021-09-07 14:39:04 -07:00
ifeq ($(SANITIZE),yes)
ULIBS += -fsanitize=address -fsanitize=undefined
2021-09-07 14:39:04 -07:00
endif
2021-05-07 09:36:30 -07:00
#
# End of user defines
##############################################################################
2021-05-06 13:33:10 -07:00
# Define project name here
2023-04-11 16:26:15 -07:00
PROJECT = fome_test
2021-05-06 13:33:10 -07:00
2024-03-07 22:59:47 -08:00
# TODO: remove me when unit tests include board.mk
SHORT_BOARD_NAME = f407-discovery
2021-05-06 13:33:10 -07:00
ifeq ("$(wildcard $(UNIT_TESTS_DIR)/googletest/LICENSE)","")
$(info Invoking "git submodule update --init")
$(shell git submodule update --init)
$(info Invoked "git submodule update --init")
# make is not happy about newly checked out module for some reason but next invocation would work
$(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
2024-02-22 10:58:03 -08:00
include $(PROJECT_DIR)/fome_generated.mk
include $(PROJECT_DIR)/gitversion.mk
2024-03-15 01:06:00 -07:00
.PHONY: CLEAN_RULE_HOOK CLEAN_PCH_HOOK CLEAN_BUNDLE_HOOK
CLEAN_RULE_HOOK: CLEAN_PCH_HOOK CLEAN_GENERATED_HOOK