Allow examples and test-suite to be built out of source tree
- Examples/Makefile.in rules use SRCDIR as the relative source directory - ./config.status replicates Examples/ source directory tree in build directory, and copies each Makefile to build directory, prefixed with a header which sets SRCDIR to source directory - Examples/test-suite/.../Makefile.in set SRCDIR from Autoconf-set srcdir - Examples/test-suite/errors/Makefile.in needs to filter out source directory from SWIG error messages - Lua: embedded interpreters are passed location of run-time test - Python: copy run-time scripts to build directory because of 2to3 conversion; import_packages example copies __init__.py from source directory; test-suite sets SCRIPTDIR to location of run-time tests - Javascript: binding.gyp renamed to binding.gyp.in so that $srcdir can be substituted with SRCDIR; removed './' from require() statements so that NODE_PATH can be used to point Node.js to build directory
This commit is contained in:
parent
72e6b5349e
commit
f574a34155
420 changed files with 1772 additions and 1510 deletions
|
|
@ -21,9 +21,16 @@ else
|
|||
SCRIPTSUFFIX = $(PY3SCRIPTSUFFIX)
|
||||
endif
|
||||
|
||||
SCRIPTDIR = .
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
ifeq (.,$(srcdir))
|
||||
SRCDIR =
|
||||
else
|
||||
SRCDIR = $(srcdir)/
|
||||
endif
|
||||
|
||||
|
||||
PY2TO3 = 2to3 -x import
|
||||
|
|
@ -128,39 +135,43 @@ VALGRIND_OPT += --suppressions=pythonswig.supp
|
|||
$(run_testcase)
|
||||
|
||||
|
||||
# Call 2to3 to generate Python 3.x test from the Python 2.x's *_runme.py file
|
||||
%$(PY3SCRIPTSUFFIX): %$(PY2SCRIPTSUFFIX)
|
||||
cp $< $@
|
||||
$(PY2TO3) -w $@ >/dev/null 2>&1
|
||||
|
||||
|
||||
# Runs the testcase. A testcase is only run if
|
||||
# a file is found which has _runme.py (or _runme3.py for Python 3) appended after the testcase name.
|
||||
|
||||
run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
|
||||
py_runme = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
|
||||
py2_runme = $(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
|
||||
py3_runme = $(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
|
||||
|
||||
py2_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
|
||||
py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
|
||||
run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(py_runme)
|
||||
|
||||
run_testcase = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
if [ -f $(SCRIPTDIR)/$(py_runme) ]; then \
|
||||
$(run_python);\
|
||||
fi
|
||||
|
||||
ifeq (,$(PY3))
|
||||
# No copying/conversion needed for in-source-tree Python 2 scripts
|
||||
ifeq ($(SCRIPTDIR)|$(SCRIPTSUFFIX),$(srcdir)|$(PY2SCRIPTSUFFIX))
|
||||
convert_testcase =
|
||||
else
|
||||
|
||||
convert_testcase = \
|
||||
if [ -f $(py2_runme) ]; then \
|
||||
$(MAKE) -f $(srcdir)/Makefile $(py3_runme); \
|
||||
if [ -f $(srcdir)/$(py2_runme) ]; then \
|
||||
$(MAKE) $(SCRIPTDIR)/$(py_runme); \
|
||||
fi
|
||||
|
||||
$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX): $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX)
|
||||
test x$< = x$@ || cp $< $@ || exit 1
|
||||
test x$(PY3) = x || $(PY2TO3) -w $@ >/dev/null 2>&1 || exit 1
|
||||
|
||||
endif
|
||||
|
||||
# Clean: remove the generated .py file
|
||||
# We only remove the _runme3.py if it is generated by 2to3 from a _runme.py.
|
||||
%.clean:
|
||||
@rm -f $*.py;
|
||||
@#We only remove the _runme3.py if it is generated by 2to3 from a _runme.py.
|
||||
@if [ -f $(py2_runme) ]; then rm -f $(py3_runme) $(py3_runme).bak; fi
|
||||
@rm -f $*.py
|
||||
@if [ -f $(srcdir)/$(py2_runme) ]; then \
|
||||
rm -f $(SCRIPTDIR)/$(py3_runme) $(SCRIPTDIR)/$(py3_runme).bak; \
|
||||
fi
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile python_clean
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue