Skip to content

Commit f121f28

Browse files
committed
pythongh-92584: Add Makefile rules for test cpp extensions
`make test_cppmods` compiles C++ test extension modules.
1 parent 834064c commit f121f28

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Makefile.pre.in

+25
Original file line numberDiff line numberDiff line change
@@ -1686,6 +1686,31 @@ buildbottest: all
16861686
fi
16871687
$(TESTRUNNER) -j 1 -u all -W --slowest --fail-env-changed --timeout=$(TESTTIMEOUT) $(TESTOPTS)
16881688

1689+
TEST_CPPMODS= \
1690+
Modules/_testcpp03ext$(EXT_SUFFIX) \
1691+
Modules/_testcpp11ext$(EXT_SUFFIX)
1692+
1693+
.PHONY: test_cppmods
1694+
test_cppmods: $(TEST_CPPMODS) pybuilddir.txt
1695+
@target=`cat pybuilddir.txt`; \
1696+
$(MKDIR_P) $$target; \
1697+
for mod in $(TEST_CPPMODS); do \
1698+
$(LN) -sf ../../$$mod $$target/`basename $$mod`; \
1699+
done
1700+
1701+
# gh-91321: Build a basic C++ test extension to check that the Python C API is
1702+
# compatible with C++ and does not emit C++ compiler warnings. The purpose of
1703+
# _testcppext extension is to check that building a C++ extension using the
1704+
# Python C API does not emit C++ compiler warnings
1705+
Modules/_testcpp03ext.o: $(srcdir)/Lib/test/_testcppext.cpp $(PYTHON_HEADERS)
1706+
$(CXX) -Werror -std=c++03 $(CCSHARED) $(PY_CPPFLAGS) $(PY_CFLAGS) -c $(srcdir)/Lib/test/_testcppext.cpp -o $@
1707+
Modules/_testcpp03ext$(EXT_SUFFIX): Modules/_testcpp03ext.o
1708+
$(LDCXXSHARED) $< -o $@
1709+
Modules/_testcpp11ext.o: $(srcdir)/Lib/test/_testcppext.cpp $(PYTHON_HEADERS)
1710+
$(CXX) -Werror -std=c++11 $(CCSHARED) $(PY_CPPFLAGS) $(PY_CFLAGS) -c $(srcdir)/Lib/test/_testcppext.cpp -o $@
1711+
Modules/_testcpp11ext$(EXT_SUFFIX): Modules/_testcpp11ext.o
1712+
$(LDCXXSHARED) $< -o $@
1713+
16891714
pythoninfo: all
16901715
$(RUNSHARED) $(HOSTRUNNER) ./$(BUILDPYTHON) -m test.pythoninfo
16911716

0 commit comments

Comments
 (0)