Add rules for executing C / C++ tests directly

This commit is contained in:
Christophe de Dinechin 2017-04-01 17:10:27 +02:00
parent 5afb8df97e
commit c2edd48a05
1 changed files with 11 additions and 4 deletions

View File

@ -52,9 +52,9 @@ endif
# Configuration variables
OBJDIR:= $(OBJROOT)$(DIR)
OBJECTS:= $(SOURCES:%=$(OBJDIR)/%$(OBJ_EXT))
PRODUCTS_EXE:= $(patsubst %.exe,%$(EXE_EXT),$(filter %.exe %$(EXE_EXT),$(PRODUCTS)))
PRODUCTS_LIB:= $(patsubst %.lib,%$(LIB_EXT),$(filter %.lib %$(LIB_EXT),$(PRODUCTS)))
PRODUCTS_DLL:= $(patsubst %.dll,%$(DLL_EXT),$(filter %.dll %$(DLL_EXT),$(PRODUCTS)))
PRODUCTS_EXE:= $(patsubst %.exe,%$(EXE_EXT),$(filter %.exe,$(PRODUCTS)))
PRODUCTS_LIB:= $(patsubst %.lib,%$(LIB_EXT),$(filter %.lib,$(PRODUCTS)))
PRODUCTS_DLL:= $(patsubst %.dll,%$(DLL_EXT),$(filter %.dll,$(PRODUCTS)))
PRODUCTS_OTHER:= $(filter-out %.exe %.lib %.dll %$(EXE_EXT) %$(LIB_EXT) %$(DLL_EXT), $(PRODUCTS))
OBJROOT_EXE:= $(PRODUCTS_EXE:%=$(OBJROOT)/%)
OBJROOT_LIB:= $(PRODUCTS_LIB:%=$(OBJROOT)/%)
@ -83,7 +83,6 @@ BUILD_COUNT:= $(words $(SOURCES))
GIT_REVISION:= $(shell git rev-parse --short HEAD 2> /dev/null || echo "unknown")
PROFILE_OUTPUT:=$(subst $(EXE_EXT),,$(OBJROOT_EXE))_prof_$(GIT_REVISION).vsp
#------------------------------------------------------------------------------
# User targets
#------------------------------------------------------------------------------
@ -164,6 +163,14 @@ test tests: $(TESTS:%=%.runtest)
product.runtest: product .ALWAYS
$(PRINT_TEST) $(OBJROOT_EXE) $(PRODUCTS_OPTS)
# Run a test from a C or C++ file
%.c.runtest: product .ALWAYS
$(PRINT_TEST) $(MAKE) SOURCES=$*.c LIBRARIES=$(PRODUCTS_LIB) PRODUCTS=$*
$(PRINT_TEST) $(OBJROOT)/$*
%.cpp.runtest: product .ALWAYS
$(PRINT_TEST) $(MAKE) SOURCES=$*.cpp LIBRARIES=$(PRODUCTS_LIB) PRODUCTS=$*
$(PRINT_TEST) $(OBJROOT)/$*
# Installing the product: always need to build it first
%.install_exe: $(PREFIX_BIN).mkdir
$(PRINT_INSTALL) $(INSTALL) $* $(PREFIX_BIN)