Skip to content

Commit

Permalink
msys cygwin semi native build sysconfig
Browse files Browse the repository at this point in the history
Co-authored-by: Алексей <alexey.pawlow@gmail.com>
  • Loading branch information
Alexpux authored and naveen521kk committed Jul 1, 2021
1 parent 6bd3b90 commit ae4be49
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Lib/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,14 @@ def _parse_makefile(filename, vars=None):
if isinstance(v, str):
done[k] = v.strip()

# any keys that have one with the same name suffixed with _b2h
# need to be replaced with the value of the _b2h key.
# This converts from MSYS*/Cygwin paths to Windows paths.
for k, v in dict(done).items():
if isinstance(k, str):
if k.endswith("_b2h"):
done[k[:-4]]=v

# save the results in the global dictionary
vars.update(done)
return vars
Expand Down
7 changes: 7 additions & 0 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ exec_prefix= @exec_prefix@
# Install prefix for data files
datarootdir= @datarootdir@

# Locations needed for semi-native fixup of sysconfig.
srcdir_b2h= @srcdir_b2h@
VPATH_b2h= @VPATH_b2h@
abs_srcdir_b2h= @abs_srcdir_b2h@
abs_builddir_b2h= @abs_builddir_b2h@
prefix_b2h= @prefix_b2h@

# Expanded directories
BINDIR= @bindir@
LIBDIR= @libdir@
Expand Down
59 changes: 59 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,65 @@ then
AC_DEFINE(_INCLUDE__STDC_A1_SOURCE, 1, Define to include mbstate_t for mbrtowc)
fi

# On 'semi-native' build systems (MSYS*/Cygwin targeting MinGW-w64)
# _sysconfigdata.py will contain paths that are correct only in the
# build environment. This means external modules will fail to build
# without setting up the same env and also that the build of Python
# itself will fail as the paths are not correct for the host tools.
#
# Also, getpath.c uses GetModuleFileNameW (replacing \ with /) and
# compares that with the define VPATH (passed in via command-line)
# to determine whether it's the build- or the installed-Python.
#
# To work around these issues a set of _b2h variables are created:
# VPATH_b2h, prefix_b2h, srcdir_b2h, abs_srcdir_b2h
# and abs_builddir_b2h
# .. where b2h stands for build to host. sysconfig.py replaces path
# prefixes matching the non-b2h versions with the b2h equivalents.
#
# (note this assumes the host compilers are native and *not* cross
# - in the 'semi-native' scenario only that is.)

AC_DEFUN([ABS_PATH_HOST],
[$1=$(cd $$2 && pwd)
case $build_os in
mingw*)
case $host_os in
mingw*) $1=$(cd $$2 && pwd -W) ;;
*) ;;
esac
;;
cygwin*)
case $host_os in
mingw*) $1=$(cygpath -w -m $$2) ;;
*) ;;
esac
;;
esac
AC_SUBST([$1])
])

AC_MSG_CHECKING(absolute host location of VPATH)
ABS_PATH_HOST([VPATH_b2h],[srcdir])
AC_MSG_RESULT([$VPATH_b2h])

AC_MSG_CHECKING(absolute host location of prefix)
ABS_PATH_HOST([prefix_b2h],[prefix])
AC_MSG_RESULT([$prefix_b2h])

AC_MSG_CHECKING(absolute host location of srcdir)
ABS_PATH_HOST([srcdir_b2h],[srcdir])
AC_MSG_RESULT([$srcdir_b2h])

AC_MSG_CHECKING(absolute host location of abs_srcdir)
ABS_PATH_HOST([abs_srcdir_b2h],[srcdir])
AC_MSG_RESULT([$abs_srcdir_b2h])

my_builddir=.
AC_MSG_CHECKING(Absolute host location of abs_builddir)
ABS_PATH_HOST([abs_builddir_b2h],[my_builddir])
AC_MSG_RESULT([$abs_builddir_b2h])

AC_MSG_CHECKING([for init system calls])
AC_SUBST(INITSYS)
case $host in
Expand Down

0 comments on commit ae4be49

Please sign in to comment.