Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4d4ec65

Browse files
committed
Merge issue #15819: additional fixes for out-of-tree builds from read-only src.
Specifically, make sure the 'Object', 'Python' and 'Include' directories in the build directory take precedence over the source directory if we're an out-of-tree build. Fix typeslots.inc so that it gets generated into the build directory. In addition, for 3.3, make sure importlib.h gets generated into the build directory.
2 parents c101bf3 + 9effe69 commit 4d4ec65

3 files changed

Lines changed: 47 additions & 6 deletions

File tree

Makefile.pre.in

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ MODLIBS= _MODLIBS_
2727
VERSION= @VERSION@
2828
srcdir= @srcdir@
2929
VPATH= @srcdir@
30+
BUILDDIR= @BUILDDIR@
31+
3032

3133
CC= @CC@
3234
CXX= @CXX@
@@ -66,6 +68,7 @@ MAKESETUP= $(srcdir)/Modules/makesetup
6668
# Compiler options
6769
OPT= @OPT@
6870
BASECFLAGS= @BASECFLAGS@
71+
BASECPPFLAGS= @BASECPPFLAGS@
6972
CONFIGURE_CFLAGS= @CFLAGS@
7073
CONFIGURE_CPPFLAGS= @CPPFLAGS@
7174
CONFIGURE_LDFLAGS= @LDFLAGS@
@@ -76,7 +79,7 @@ PY_CFLAGS= $(BASECFLAGS) $(OPT) $(CONFIGURE_CFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)
7679
# Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to
7780
# be able to build extension modules using the directories specified in the
7881
# environment variables
79-
PY_CPPFLAGS= -I. -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)
82+
PY_CPPFLAGS= $(BASECPPFLAGS) -I. -IInclude -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)
8083
PY_LDFLAGS= $(CONFIGURE_LDFLAGS) $(LDFLAGS)
8184
NO_AS_NEEDED= @NO_AS_NEEDED@
8285
LDLAST= @LDLAST@
@@ -310,7 +313,7 @@ ASDLGEN= @DISABLE_ASDLGEN@ $(srcdir)/Parser/asdl_c.py
310313
# Python
311314

312315
OPCODETARGETS_H= \
313-
$(srcdir)/Python/opcode_targets.h
316+
Python/opcode_targets.h
314317

315318
OPCODETARGETGEN= \
316319
$(srcdir)/Python/makeopcodetargets.py
@@ -725,11 +728,11 @@ Python/ceval.o: $(OPCODETARGETS_H) $(srcdir)/Python/ceval_gil.h
725728
Python/formatter_unicode.o: $(srcdir)/Python/formatter_unicode.c \
726729
$(BYTESTR_DEPS)
727730

728-
Python/frozen.o: $(srcdir)/Python/importlib.h
731+
Python/frozen.o: Python/importlib.h
729732

730-
Objects/typeobject.o: $(srcdir)/Objects/typeslots.inc
731-
$(srcdir)/Objects/typeslots.inc: $(srcdir)/Include/typeslots.h $(srcdir)/Objects/typeslots.py
732-
$(PYTHON) $(srcdir)/Objects/typeslots.py < $(srcdir)/Include/typeslots.h > $(srcdir)/Objects/typeslots.inc
733+
Objects/typeobject.o: Objects/typeslots.inc
734+
Objects/typeslots.inc: $(srcdir)/Include/typeslots.h $(srcdir)/Objects/typeslots.py
735+
$(PYTHON) $(srcdir)/Objects/typeslots.py < $(srcdir)/Include/typeslots.h > Objects/typeslots.inc
733736

734737
############################################################################
735738
# Header files

configure

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,8 @@ HAS_HG
714714
HGBRANCH
715715
HGTAG
716716
HGVERSION
717+
BASECPPFLAGS
718+
BUILDDIR
717719
target_alias
718720
host_alias
719721
build_alias
@@ -2719,6 +2721,24 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
27192721

27202722

27212723

2724+
BUILDDIR="`pwd`"
2725+
2726+
2727+
if test "$srcdir" != "$BUILDDIR"; then
2728+
# If we're building out-of-tree, we need to make sure the following
2729+
# resources get picked up before their $srcdir counterparts.
2730+
# Objects/ -> typeslots.inc
2731+
# Include/ -> Python-ast.h, graminit.h
2732+
# Python/ -> importlib.h
2733+
# (A side effect of this is that these resources will automatically be
2734+
# regenerated when building out-of-tree, regardless of whether or not
2735+
# the $srcdir counterpart is up-to-date. This is an acceptable trade
2736+
# off.)
2737+
BASECPPFLAGS="-IObjects -IInclude -IPython"
2738+
else
2739+
BASECPPFLAGS=""
2740+
fi
2741+
27222742

27232743

27242744

configure.ac

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,24 @@ AC_PREREQ(2.65)
99

1010
AC_INIT(python, PYTHON_VERSION, http://bugs.python.org/)
1111

12+
BUILDDIR="`pwd`"
13+
AC_SUBST(BUILDDIR)
14+
AC_SUBST(BASECPPFLAGS)
15+
if test "$srcdir" != "$BUILDDIR"; then
16+
# If we're building out-of-tree, we need to make sure the following
17+
# resources get picked up before their $srcdir counterparts.
18+
# Objects/ -> typeslots.inc
19+
# Include/ -> Python-ast.h, graminit.h
20+
# Python/ -> importlib.h
21+
# (A side effect of this is that these resources will automatically be
22+
# regenerated when building out-of-tree, regardless of whether or not
23+
# the $srcdir counterpart is up-to-date. This is an acceptable trade
24+
# off.)
25+
BASECPPFLAGS="-IObjects -IInclude -IPython"
26+
else
27+
BASECPPFLAGS=""
28+
fi
29+
1230
AC_SUBST(HGVERSION)
1331
AC_SUBST(HGTAG)
1432
AC_SUBST(HGBRANCH)

0 commit comments

Comments
 (0)