swig/Examples/test-suite/c/Makefile.in
Vadim Zeitlin 2ab549611b Syntax check generated headers using both C and C++ compilers
For C++ tests, check header compilation using C++ compiler too, as this
detects constructs valid in C but invalid in C++ and will also be useful
for checking C++-specific parts of the headers that will be generated in
the future.
2021-11-19 00:08:44 +01:00

184 lines
4.6 KiB
Makefile

#######################################################################
# Makefile for C test-suite
#######################################################################
LANGUAGE = c
C = gcc
CXX = g++
RUNMESUFFIX = _runme
srcdir = @srcdir@
top_srcdir = ../@top_srcdir@
top_builddir = ../@top_builddir@
# This can be set to ":" to avoid progress messages.
ECHO_PROGRESS := echo
CPP_TEST_CASES := \
c_backend_cpp_natural_std_string \
c_backend_cpp_exception
CPP11_TEST_CASES := \
cpp11_shared_ptr_const \
cpp11_shared_ptr_nullptr_in_containers \
cpp11_shared_ptr_overload \
cpp11_shared_ptr_upcast \
# The following tests are currently broken and need to be fixed.
FAILING_C_TESTS := \
arrays \
funcptr \
function_typedef \
lextype \
li_carrays \
nested \
nested_extend_c \
nested_structs \
typedef_struct \
union_parameter \
unions \
FAILING_CPP_TESTS := \
apply_signed_char \
array_member \
array_typedef_memberin \
arrayref \
arrays_dimensionless \
arrays_global \
arrays_global_twodim \
constant_pointers \
director_smartptr \
enum_thorough \
extend \
extend_default \
extern_c \
extern_template_method \
funcptr_cpp \
global_scope_types \
grouping \
import_nomodule \
li_attribute \
li_boost_shared_ptr_attribute \
li_std_deque \
li_std_wstring \
li_windows \
member_funcptr_galore \
member_pointer \
member_pointer_const \
mixed_types \
nested_class \
template_basic \
template_default \
template_enum \
template_explicit \
template_typedef_fnc \
typedef_array_member \
typedef_funcptr \
typedef_struct_cpp \
typemap_array_qualifiers \
typemap_namespace \
typemap_various \
using_extend \
varargs \
varargs_overload \
virtual_poly \
cpp11_ref_qualifiers \
cpp11_ref_qualifiers_typemaps \
cpp11_result_of \
cpp11_rvalue_reference \
cpp11_rvalue_reference2 \
cpp11_rvalue_reference3 \
cpp11_type_aliasing \
FAILING_MULTI_CPP_TESTS := \
clientdata_prop \
imports \
import_stl \
template_typedef_import \
# Ignore warnings about failing to apply typemaps because none are defined:
# usually there is no need for special typemaps in C.
char_binary.cpptest director_binary_string.cpptest li_typemaps.cpptest li_typemaps_apply.cpptest long_long_apply.cpptest: SWIGOPT += -w453
include $(srcdir)/../common.mk
# Overridden variables here
SWIGOPT += -w524 # Suppress SWIGWARN_LANG_EXPERIMENTAL warning
%.cpptest: SWIGOPT += -namespace $*
SRCDIR = ../$(srcdir)/
# Make function to check if we have an executable test for the given test base name.
define has_runme
-f $(srcdir)/$1$(RUNMESUFFIX).c -o -f $(srcdir)/$1$(RUNMESUFFIX).cxx
endef
# Rules for the different types of tests
%.cpptest:
$(setup)
+(cd $* && $(swig_and_compile_cpp))
+if [ $(call has_runme,$*) ]; then \
$(do_run_testcase); \
else \
cd $* && $(call syntax_check_testcase,$*); \
fi
%.ctest:
$(setup)
+(cd $* && $(swig_and_compile_c))
+if [ $(call has_runme,$*) ]; then \
$(do_run_testcase); \
else \
cd $* && $(call syntax_check_testcase,$*,_c); \
fi
%.multicpptest:
$(setup)
+(cd $* && $(swig_and_compile_multi_cpp))
+if [ $(call has_runme,$*) ]; then \
$(do_run_testcase); \
else \
cd $* && for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list`; do \
$(call syntax_check_testcase,$${f}) || exit 1; \
done; \
fi
# Makes a directory for the testcase if it does not exist
setup = \
if [ $(call has_runme,$*) ]; then \
$(ECHO_PROGRESS) "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE)" ; \
else \
$(ECHO_PROGRESS) "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \
fi; \
if [ ! -d $* ]; then \
mkdir $*; \
fi;
# Checks the header syntax if there is no runnable testcase for it.
#
# The optional second argument can be "_c" to check syntax using C compiler only
# (by default both C and C++ compilers are used).
syntax_check_testcase = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
SRCDIR='$(SRCDIR)' \
INTERFACEDIR='$(INTERFACEDIR)' \
C_HEADER=$1_wrap.h \
c_syntax_check$2
# Compiles C files then runs the testcase unconditionally.
do_run_testcase = \
cd $* && $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
SRCDIR='$(SRCDIR)' \
RUNME=$*$(RUNMESUFFIX) \
RUNME_EXT=$(patsubst .%,%,$(suffix $(wildcard $(srcdir)/$*$(RUNMESUFFIX).c*))) \
TARGET='$*' \
c_run
# Clean: remove testcase directories
%.clean:
@if [ -d $* ]; then \
rm -rf $*; \
fi;
clean:
@rm -f *_wrap.* *~ *.exe *.dll *.so *.out *runme