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.
This commit is contained in:
parent
0f734e1164
commit
2ab549611b
2 changed files with 22 additions and 17 deletions
|
|
@ -1363,8 +1363,6 @@ C_LDSHARED = @C_LDSHARED@
|
||||||
CXX_LDSHARED = @CXX_LDSHARED@
|
CXX_LDSHARED = @CXX_LDSHARED@
|
||||||
C_SO = @C_SO@
|
C_SO = @C_SO@
|
||||||
|
|
||||||
SYNTAX_CHECK := $(CC) -fsyntax-only -x c
|
|
||||||
|
|
||||||
c: $(SRCDIR_SRCS)
|
c: $(SRCDIR_SRCS)
|
||||||
$(SWIG) -c $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
$(SWIG) -c $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
|
||||||
$(CC) -c $(CCSHARED) -I$(SRCDIR) $(CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES)
|
$(CC) -c $(CCSHARED) -I$(SRCDIR) $(CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES)
|
||||||
|
|
@ -1385,9 +1383,14 @@ $(eval c_compile: c_compile_$(RUNME_EXT))
|
||||||
|
|
||||||
# This target is used for the unit tests: if we don't have any test code to
|
# This target is used for the unit tests: if we don't have any test code to
|
||||||
# run, we at least can check that the generated header can be included without
|
# run, we at least can check that the generated header can be included without
|
||||||
# giving any syntax errors.
|
# giving any syntax errors, both when compiling it as C and C++ code.
|
||||||
c_syntax_check:
|
c_syntax_check: c_syntax_check_c c_syntax_check_cxx
|
||||||
$(SYNTAX_CHECK) -I$(SRCDIR)$(INTERFACEDIR) $(C_HEADER)
|
|
||||||
|
c_syntax_check_c:
|
||||||
|
$(CC) -fsyntax-only -x c -I$(SRCDIR)$(INTERFACEDIR) $(C_HEADER)
|
||||||
|
|
||||||
|
c_syntax_check_cxx:
|
||||||
|
$(CXX) -fsyntax-only -x c++ -I$(SRCDIR)$(INTERFACEDIR) $(C_HEADER)
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
# Run C example
|
# Run C example
|
||||||
|
|
|
||||||
|
|
@ -117,12 +117,20 @@ endef
|
||||||
%.cpptest:
|
%.cpptest:
|
||||||
$(setup)
|
$(setup)
|
||||||
+(cd $* && $(swig_and_compile_cpp))
|
+(cd $* && $(swig_and_compile_cpp))
|
||||||
$(run_testcase)
|
+if [ $(call has_runme,$*) ]; then \
|
||||||
|
$(do_run_testcase); \
|
||||||
|
else \
|
||||||
|
cd $* && $(call syntax_check_testcase,$*); \
|
||||||
|
fi
|
||||||
|
|
||||||
%.ctest:
|
%.ctest:
|
||||||
$(setup)
|
$(setup)
|
||||||
+(cd $* && $(swig_and_compile_c))
|
+(cd $* && $(swig_and_compile_c))
|
||||||
$(run_testcase)
|
+if [ $(call has_runme,$*) ]; then \
|
||||||
|
$(do_run_testcase); \
|
||||||
|
else \
|
||||||
|
cd $* && $(call syntax_check_testcase,$*,_c); \
|
||||||
|
fi
|
||||||
|
|
||||||
%.multicpptest:
|
%.multicpptest:
|
||||||
$(setup)
|
$(setup)
|
||||||
|
|
@ -147,12 +155,15 @@ setup = \
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
# Checks the header syntax if there is no runnable testcase for it.
|
# 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 = \
|
syntax_check_testcase = \
|
||||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
|
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
|
||||||
SRCDIR='$(SRCDIR)' \
|
SRCDIR='$(SRCDIR)' \
|
||||||
INTERFACEDIR='$(INTERFACEDIR)' \
|
INTERFACEDIR='$(INTERFACEDIR)' \
|
||||||
C_HEADER=$1_wrap.h \
|
C_HEADER=$1_wrap.h \
|
||||||
c_syntax_check
|
c_syntax_check$2
|
||||||
|
|
||||||
# Compiles C files then runs the testcase unconditionally.
|
# Compiles C files then runs the testcase unconditionally.
|
||||||
do_run_testcase = \
|
do_run_testcase = \
|
||||||
|
|
@ -163,15 +174,6 @@ do_run_testcase = \
|
||||||
TARGET='$*' \
|
TARGET='$*' \
|
||||||
c_run
|
c_run
|
||||||
|
|
||||||
# Only compile and run testcase if we have a runme for it, otherwise only check
|
|
||||||
# the syntax of the generated files.
|
|
||||||
run_testcase = \
|
|
||||||
+if [ $(call has_runme,$*) ]; then \
|
|
||||||
$(do_run_testcase); \
|
|
||||||
else \
|
|
||||||
cd $* && $(call syntax_check_testcase,$*); \
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Clean: remove testcase directories
|
# Clean: remove testcase directories
|
||||||
%.clean:
|
%.clean:
|
||||||
@if [ -d $* ]; then \
|
@if [ -d $* ]; then \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue