in build/generator/gen_win_dependencies.py [0:0]
def _find_apr_util_etc(self):
"Find the APR-util library and version"
minimal_aprutil_version = (1, 3, 0)
inc_base = os.path.join(self.apr_util_path, 'include')
if os.path.isfile(os.path.join(inc_base, 'apr-1', 'apu_version.h')):
inc_path = os.path.join(inc_base, 'apr-1')
elif os.path.isfile(os.path.join(inc_base, 'apu_version.h')):
inc_path = inc_base
else:
sys.stderr.write("ERROR: 'apu_version' not found.\n")
sys.stderr.write("Use '--with-apr-util' option to configure APR-Util location.\n")
sys.exit(1)
version_file_path = os.path.join(inc_path, 'apu_version.h')
txt = open(version_file_path).read()
vermatch = re.search(r'^\s*#define\s+APU_MAJOR_VERSION\s+(\d+)', txt, re.M)
major = int(vermatch.group(1))
vermatch = re.search(r'^\s*#define\s+APU_MINOR_VERSION\s+(\d+)', txt, re.M)
minor = int(vermatch.group(1))
vermatch = re.search(r'^\s*#define\s+APU_PATCH_VERSION\s+(\d+)', txt, re.M)
patch = int(vermatch.group(1))
version = (major, minor, patch)
self.aprutil_version = aprutil_version = '%d.%d.%d' % version
if version < minimal_aprutil_version:
sys.stderr.write("ERROR: apr-util %s or higher is required "
"(%s found)\n" % (
'.'.join(str(v) for v in minimal_aprutil_version),
aprutil_version))
sys.exit(1)
suffix = ''
if major > 0:
suffix = '-%d' % major
defines = []
if self.static_apr:
lib_name = 'aprutil%s.lib' % suffix
lib_dir = os.path.join(self.apr_util_path, 'LibR')
dll_dir = None
debug_dll_dir = None
dll_name = None
defines.extend(["APU_DECLARE_STATIC"])
if not os.path.isdir(lib_dir) and \
os.path.isfile(os.path.join(self.apr_util_path, 'lib', lib_name)):
# Installed APR-Util instead of APR-Util-Source
lib_dir = os.path.join(self.apr_util_path, 'lib')
debug_lib_dir = None
else:
debug_lib_dir = os.path.join(self.apr_util_path, 'LibD')
else:
lib_name = 'libaprutil%s.lib' % suffix
lib_dir = os.path.join(self.apr_util_path, 'Release')
if not os.path.isdir(lib_dir) and \
os.path.isfile(os.path.join(self.apr_util_path, 'lib', lib_name)):
# Installed APR-Util instead of APR-Util-Source
lib_dir = os.path.join(self.apr_util_path, 'lib')
debug_lib_dir = lib_dir
else:
debug_lib_dir = os.path.join(self.apr_util_path, 'Debug')
dll_name = 'libaprutil%s.dll' % suffix
if os.path.isfile(os.path.join(lib_dir, dll_name)):
dll_dir = lib_dir
debug_dll_dir = debug_lib_dir
else:
dll_dir = os.path.join(self.apr_util_path, 'bin')
debug_dll_dir = None
extra_bin = []
if dll_dir:
bin_files = os.listdir(dll_dir)
if debug_dll_dir and os.path.isdir(debug_dll_dir):
debug_bin_files = os.listdir(debug_dll_dir)
else:
debug_bin_files = bin_files
for bin in bin_files:
if bin in debug_bin_files:
if re.match('^(lib)?aprutil[-_].*' + suffix + '(d)?.dll$', bin):
extra_bin.append(bin)
self._libraries['aprutil'] = SVNCommonLibrary('apr-util', inc_path, lib_dir,
lib_name,
aprutil_version,
debug_lib_dir=debug_lib_dir,
dll_dir=dll_dir,
dll_name=dll_name,
debug_dll_dir=debug_dll_dir,
defines=defines,
extra_bin=extra_bin)
# Perhaps apr-util can also provide memcached support
if version >= (1, 3, 0) :
self._libraries['apr_memcache'] = SVNCommonLibrary(
'apr_memcache', inc_path, lib_dir,
None, aprutil_version,
defines=['SVN_HAVE_MEMCACHE'])
# And now find expat
# If we have apr-util as a source location, it is in a subdir.
# If we have an install package it is in the lib subdir
if os.path.exists(os.path.join(self.apr_util_path, 'xml/expat')):
inc_path = os.path.join(self.apr_util_path, 'xml/expat/lib')
lib_dir = os.path.join(self.apr_util_path, 'xml/expat/lib/LibR')
debug_lib_dir = os.path.join(self.apr_util_path, 'xml/expat/lib/LibD')
else:
inc_path = os.path.join(self.apr_util_path, 'include')
lib_dir = os.path.join(self.apr_util_path, 'lib')
debug_lib_dir = None
version_file_path = os.path.join(inc_path, 'expat.h')
if not os.path.exists(version_file_path):
sys.stderr.write("ERROR: '%s' not found.\n" % version_file_path);
sys.stderr.write("Use '--with-apr-util' option to configure APR-Util's XML location.\n");
sys.exit(1)
txt = open(version_file_path).read()
vermatch = re.search(r'^\s*#define\s+XML_MAJOR_VERSION\s+(\d+)', txt, re.M)
major = int(vermatch.group(1))
vermatch = re.search(r'^\s*#define\s+XML_MINOR_VERSION\s+(\d+)', txt, re.M)
minor = int(vermatch.group(1))
vermatch = re.search(r'^\s*#define\s+XML_MICRO_VERSION\s+(\d+)', txt, re.M)
patch = int(vermatch.group(1))
# apr-Util 0.9-1.4 compiled expat to 'xml.lib', but apr-util 1.5 switched
# to the more common 'libexpat.lib'
if os.path.exists(os.path.join(lib_dir, 'libexpat.lib')):
# Shared or completely static build
libname = 'libexpat.lib'
elif os.path.exists(os.path.join(lib_dir, 'libexpatMD.lib')):
# libexpat CMake build. static build against Multithreaded DLL CRT
libname = 'libexpatMD.lib'
else:
libname = 'xml.lib'
version = (major, minor, patch)
xml_version = '%d.%d.%d' % version
self._libraries['xml'] = SVNCommonLibrary('expat', inc_path, lib_dir,
libname, xml_version,
debug_lib_dir = debug_lib_dir,
defines=['XML_STATIC'])