diff options
Diffstat (limited to 'build/generator/gen_win_dependencies.py')
-rw-r--r-- | build/generator/gen_win_dependencies.py | 65 |
1 files changed, 59 insertions, 6 deletions
diff --git a/build/generator/gen_win_dependencies.py b/build/generator/gen_win_dependencies.py index da59599..03048c0 100644 --- a/build/generator/gen_win_dependencies.py +++ b/build/generator/gen_win_dependencies.py @@ -32,6 +32,7 @@ import fnmatch import re import subprocess import string +from collections import namedtuple if sys.version_info[0] >= 3: # Python >=3.0 @@ -46,6 +47,8 @@ else: import gen_base import ezt +UserMacro = namedtuple('UserMacro', ['name', 'value']) + class SVNCommonLibrary: def __init__(self, name, include_dirs, lib_dir, lib_name, version=None, @@ -117,6 +120,7 @@ class GenDependenciesBase(gen_base.GeneratorBase): 'swig', 'perl', 'python', + 'py3c', 'ruby', 'java_sdk', 'openssl', @@ -148,6 +152,7 @@ class GenDependenciesBase(gen_base.GeneratorBase): self.jdk_path = None self.junit_path = None self.swig_path = None + self.py3c_path = None self.vs_version = '2002' self.sln_version = '7.00' self.vcproj_version = '7.00' @@ -167,6 +172,7 @@ class GenDependenciesBase(gen_base.GeneratorBase): self.instrument_purify_quantify = None self.sasl_path = None self.cpp_defines = [] + self.user_macros = [] # NLS options self.enable_nls = None @@ -198,6 +204,8 @@ class GenDependenciesBase(gen_base.GeneratorBase): self.zlib_path = val elif opt == '--with-swig': self.swig_path = val + elif opt == '--with-py3c': + self.py3c_path = val elif opt == '--with-sqlite': self.sqlite_path = val elif opt == '--with-sasl': @@ -329,13 +337,15 @@ class GenDependenciesBase(gen_base.GeneratorBase): # Swig (optional) dependencies if self._find_swig(show_warnings): self._find_perl(show_warnings) - self._find_python(show_warnings) + # py3c is required to build python bindings, show check it first + if self._find_py3c(show_warnings): + self._find_python(show_warnings) self._find_ruby(show_warnings) def _find_apr(self): "Find the APR library and version" - minimal_apr_version = (1, 3, 0) + minimal_apr_version = (1, 5, 0) if not self.apr_path: sys.stderr.write("ERROR: Use '--with-apr' option to configure APR " + \ @@ -770,7 +780,7 @@ class GenDependenciesBase(gen_base.GeneratorBase): if self.bdb_path: bdb_path = self.bdb_path - + inc_path = os.path.join(bdb_path, 'include') db_h_path = os.path.join(inc_path, 'db.h') @@ -1027,9 +1037,52 @@ class GenDependenciesBase(gen_base.GeneratorBase): except ImportError: return + if sys.version_info[0] >= 3: + self.user_macros.append(UserMacro("SWIG_PY_OPTS", "-python -py3")) + else: + self.user_macros.append(UserMacro("SWIG_PY_OPTS", "-python -classic")) + self._libraries['python'] = SVNCommonLibrary('python', inc_dir, lib_dir, None, sys.version.split(' ')[0]) + def _find_py3c(self, show_warnings): + "Find the py3c library which is used in SWIG python bindings" + show_warnings = True + # Assume a default path, unless otherwise specified + py3c_path = "py3c" + + if self.py3c_path: + py3c_path = self.py3c_path + + py3c_path = os.path.abspath(py3c_path) + inc_path = os.path.join(py3c_path, 'include') + py3c_hdr_path = os.path.join(inc_path, 'py3c.h') + + pc_path = os.path.join(py3c_path, 'py3c.pc.in') + + if not os.path.isfile(py3c_hdr_path): + if show_warnings: + print('WARNING: "%s" not found' % py3c_hdr_path) + print('Use "--with-py3c" to configure py3c location.') + return False + + with open(pc_path) as fp: + txt = fp.read() + + ver_match = re.search(r'Version:\s+([0-9.]+)', txt) + + if not ver_match: + if show_warnings: + print("WARNING: Failed to find version in '%s'" % pc_path) + return False + + py3c_version = ver_match.group(1) + + self._libraries['py3c'] = SVNCommonLibrary('py3c', inc_path, None, + None, py3c_version) + + return True + def _find_jdk(self, show_warnings): "Find details about an installed jdk" @@ -1080,7 +1133,7 @@ class GenDependenciesBase(gen_base.GeneratorBase): outfp = subprocess.Popen([os.path.join(jdk_path, 'bin', 'javac.exe'), '-version'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT).stdout - line = outfp.read() + line = outfp.read().decode('utf8') if line: vermatch = re.search(r'(([0-9]+(\.[0-9]+)+)(_[._0-9]+)?)', line, re.M) else: @@ -1138,7 +1191,7 @@ class GenDependenciesBase(gen_base.GeneratorBase): try: fp = subprocess.Popen([self.swig_exe, '-version'], stdout=subprocess.PIPE).stdout - txt = fp.read() + txt = fp.read().decode('utf8') if txt: vermatch = re.search(r'^SWIG\ Version\ (\d+)\.(\d+)\.(\d+)', txt, re.M) else: @@ -1166,7 +1219,7 @@ class GenDependenciesBase(gen_base.GeneratorBase): try: fp = subprocess.Popen([self.swig_exe, '-swiglib'], stdout=subprocess.PIPE).stdout - lib_dir = fp.readline().strip() + lib_dir = fp.readline().decode('utf8').strip() fp.close() except OSError: lib_dir = None |