Author: rhuijben
Date: Fri Jul 12 17:11:51 2013
New Revision: 1502620
URL: http://svn.apache.org/r1502620
Log:
In the Windows projectfile generator: hook the ZLib dependency in the new
framework. This support for specifying a zlib install instead of source
directory. In this case no zlib makefile project is created.
* build/generator/gen_win.py
(get_install_targets): Filter on library instances instead of library
specific variables.
(get_win_depends): Allow retrieving all external library dependencies of a
project.
(get_externallib_depends): New function.
(get_win_includes): Determine the include directories based on the
dependencies instead of hardcoded on project name for the already
converted dependencies.
(get_win_lib_dirs): Determine the library directories based on the
dependencies instead of hardcoded.
(get_win_libs): Remove unhandled case for zlib.
(FILTER_EXTERNALLIBS): New global.
* build/generator/gen_win_dependencies.py
(SVNCommonLibrary): Add is_src variable.
(_find_apr_util_and_expat): Apply minimal version check
(_find_zlib): Parse version and locations of ZLib. Move to sane location.
(_find_zlib): Remove old function here.
Modified:
subversion/trunk/build/generator/gen_win.py
subversion/trunk/build/generator/gen_win_dependencies.py
Modified: subversion/trunk/build/generator/gen_win.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/build/generator/gen_win.py?rev=1502620&r1=1502619&r2=1502620&view=diff
==============================================================================
--- subversion/trunk/build/generator/gen_win.py (original)
+++ subversion/trunk/build/generator/gen_win.py Fri Jul 12 17:11:51 2013
@@ -188,7 +188,7 @@ class WinGeneratorBase(gen_win_dependenc
install_targets = [x for x in install_targets if not isinstance(x,
gen_base.TargetScript)]
# Drop the libsvn_fs_base target and tests if we don't have BDB
- if not self.bdb_lib:
+ if 'db' not in self._libraries:
install_targets = [x for x in install_targets if x.name !=
'libsvn_fs_base']
install_targets = [x for x in install_targets if not (isinstance(x,
gen_base.TargetExe)
and x.install ==
'bdb-test')]
@@ -214,6 +214,12 @@ class WinGeneratorBase(gen_win_dependenc
or x.name == '__JAVAHL_TESTS__'
or x.name == 'libsvnjavahl')]
+ # If we don't build 'ZLib' ourself, remove this target and all the
dependencies on it
+ if not self._libraries['zlib'].is_src:
+ install_targets = [x for x in install_targets if x.name != 'zlib']
+ # TODO: Fixup dependencies
+
+ # Create DLL targets for libraries
dll_targets = []
for target in install_targets:
if isinstance(target, gen_base.TargetLib):
@@ -538,8 +544,8 @@ class WinGeneratorBase(gen_win_dependenc
if self.enable_nls and name == '__ALL__':
depends.extend(self.sections['locale'].get_targets())
- # Build ZLib as a dependency of Serf if we have it
- if self.zlib_path and name == 'serf':
+ # Make ZLib a dependency of serf if we build the zlib src
+ if name == 'serf' and self._libraries['zlib'].is_src:
depends.extend(self.sections['zlib'].get_targets())
# To set the correct build order of the JavaHL targets, the javahl-javah
@@ -561,7 +567,9 @@ class WinGeneratorBase(gen_win_dependenc
dep_dict = {}
- if isinstance(target, gen_base.TargetLib) and target.msvc_static:
+ if mode == FILTER_EXTERNALLIBS:
+ self.get_externallib_depends(target, dep_dict)
+ elif isinstance(target, gen_base.TargetLib) and target.msvc_static:
self.get_static_win_depends(target, dep_dict)
else:
self.get_linked_win_depends(target, dep_dict)
@@ -576,6 +584,10 @@ class WinGeneratorBase(gen_win_dependenc
for dep, (is_proj, is_lib, is_static) in dep_dict.items():
if is_static or (is_lib and not is_proj):
deps.append(dep)
+ elif mode == FILTER_EXTERNALLIBS:
+ for dep, (is_proj, is_lib, is_static) in dep_dict.items():
+ if is_static or (is_lib and not is_proj):
+ deps.append(dep)
else:
raise NotImplementedError
@@ -659,6 +671,16 @@ class WinGeneratorBase(gen_win_dependenc
elif is_static:
self.get_linked_win_depends(dep, deps, 1)
+ def get_externallib_depends(self, target, deps):
+ """Find externallib dependencies for a project"""
+
+ direct_deps = self.get_direct_depends(target)
+ for dep, dep_kind in direct_deps:
+ self.get_externallib_depends(dep, deps)
+
+ if isinstance(target, gen_base.TargetLinked) and dep.external_lib:
+ deps[dep] = dep_kind
+
def get_win_defines(self, target, cfg):
"Return the list of defines for target"
@@ -723,18 +745,29 @@ class WinGeneratorBase(gen_win_dependenc
def get_win_includes(self, target):
"Return the list of include directories for target"
- fakeincludes = [ self.path("subversion/include"),
- self.path("subversion"),
- self.apath(self.apr_path, "include"),
- self.apath(self.apr_util_path, "include") ]
+ fakeincludes = [ self.apath("subversion/include"),
+ self.apath("subversion") ]
+
+ for dep in self.get_win_depends(target, FILTER_EXTERNALLIBS):
+ if dep.external_lib and \
+ dep.external_lib.startswith('$(SVN_') and \
+ dep.external_lib.endswith('_LIBS)'):
+
+ external_lib = dep.external_lib[6:-6].lower()
+
+ if external_lib in self._libraries:
+ lib = self._libraries[external_lib]
+ inc_dir = self.apath(lib.include_dir)
+
+ # Avoid duplicate items
+ if inc_dir and inc_dir not in fakeincludes:
+ fakeincludes.extend([inc_dir])
if target.name == 'mod_authz_svn':
fakeincludes.extend([ self.apath(self.httpd_path, "modules/aaa") ])
if isinstance(target, gen_base.TargetApacheMod):
- fakeincludes.extend([ self.apath(self.apr_util_path, "xml/expat/lib"),
- self.apath(self.httpd_path, "include"),
- self.apath(self.bdb_path, "include") ])
+ fakeincludes.extend([ self.apath(self.httpd_path, "include") ])
elif isinstance(target, gen_base.TargetSWIG):
util_includes = "subversion/bindings/swig/%s/libsvn_swig_%s" \
% (target.lang,
@@ -744,9 +777,7 @@ class WinGeneratorBase(gen_win_dependenc
self.path("subversion/bindings/swig/include"),
self.path(util_includes) ])
else:
- fakeincludes.extend([ self.apath(self.apr_util_path, "xml/expat/lib"),
- self.path("subversion/bindings/swig/proxy"),
- self.apath(self.bdb_path, "include") ])
+ fakeincludes.extend([ self.path("subversion/bindings/swig/proxy") ])
if self.libintl_path:
fakeincludes.append(self.apath(self.libintl_path, 'inc'))
@@ -772,8 +803,6 @@ class WinGeneratorBase(gen_win_dependenc
if target.lang == "ruby":
fakeincludes.extend(self.ruby_includes)
- fakeincludes.append(self.apath(self.zlib_path))
-
if self.sqlite_inline:
fakeincludes.append(self.apath(self.sqlite_path))
else:
@@ -794,15 +823,28 @@ class WinGeneratorBase(gen_win_dependenc
def get_win_lib_dirs(self, target, cfg):
"Return the list of library directories for target"
- expatlibcfg = cfg.replace("Debug", "LibD").replace("Release", "LibR")
- if self.static_apr:
- libcfg = expatlibcfg
- else:
- libcfg = cfg
+ debug = (cfg == 'Debug')
+
+ fakelibdirs = []
+
+ for dep in self.get_win_depends(target, FILTER_LIBS):
+ if dep.external_lib and \
+ dep.external_lib.startswith('$(SVN_') and \
+ dep.external_lib.endswith('_LIBS)'):
+
+ external_lib = dep.external_lib[6:-6].lower()
- fakelibdirs = [ self.apath(self.bdb_path, "lib"),
- self.apath(self.zlib_path),
- ]
+ if external_lib in self._libraries:
+ lib = self._libraries[external_lib]
+
+ if debug:
+ lib_dir = self.apath(lib.debug_lib_dir)
+ else:
+ lib_dir = self.apath(lib.lib_dir)
+
+ # Avoid duplicate items
+ if lib_dir and lib_dir not in fakelibdirs:
+ fakelibdirs.extend([lib_dir])
if not self.sqlite_inline:
fakelibdirs.append(self.apath(self.sqlite_path, "lib"))
@@ -812,11 +854,6 @@ class WinGeneratorBase(gen_win_dependenc
if self.serf_lib:
fakelibdirs.append(self.apath(msvc_path_join(self.serf_path, cfg)))
- fakelibdirs.append(self.apath(self.apr_path, libcfg))
- fakelibdirs.append(self.apath(self.apr_util_path, libcfg))
- fakelibdirs.append(self.apath(self.apr_util_path, 'xml', 'expat',
- 'lib', expatlibcfg))
-
if isinstance(target, gen_base.TargetApacheMod):
fakelibdirs.append(self.apath(self.httpd_path, cfg))
if target.name == 'mod_dav_svn':
@@ -849,7 +886,6 @@ class WinGeneratorBase(gen_win_dependenc
else:
serflib = 'serf.lib'
- zlib = (cfg == 'Debug' and 'zlibstatD.lib' or 'zlibstat.lib')
sasllib = None
if self.sasl_path:
sasllib = 'libsasl.lib'
@@ -861,7 +897,6 @@ class WinGeneratorBase(gen_win_dependenc
return []
nondeplibs = target.msvc_libs[:]
- nondeplibs.append(zlib)
if self.enable_nls:
if self.libintl_path:
nondeplibs.append(self.apath(self.libintl_path,
@@ -915,8 +950,7 @@ class WinGeneratorBase(gen_win_dependenc
if sasllib:
nondeplibs.append(sasllib)
- elif external_lib == 'zlib' or \
- external_lib == 'apr_memcache' or \
+ elif external_lib == 'apr_memcache' or \
external_lib == 'magic':
# Currently unhandled
lib = None
@@ -1067,6 +1101,7 @@ class ProjectItem:
FILTER_LIBS = 1
FILTER_PROJECTS = 2
+FILTER_EXTERNALLIBS = 3
class POFile:
"Item class for holding po file info"
Modified: subversion/trunk/build/generator/gen_win_dependencies.py
URL:
http://svn.apache.org/viewvc/subversion/trunk/build/generator/gen_win_dependencies.py?rev=1502620&r1=1502619&r2=1502620&view=diff
==============================================================================
--- subversion/trunk/build/generator/gen_win_dependencies.py (original)
+++ subversion/trunk/build/generator/gen_win_dependencies.py Fri Jul 12
17:11:51 2013
@@ -60,7 +60,8 @@ class SVNCommonLibrary:
def __init__(self, name, include_dir, lib_dir, lib_name, version=None,
debug_lib_dir=None, debug_lib_name=None, dll_dir=None,
- dll_name=None, debug_dll_dir=None, debug_dll_name=None):
+ dll_name=None, debug_dll_dir=None, debug_dll_name=None,
+ is_src=False):
self.name = name
self.include_dir = include_dir
self.lib_dir = lib_dir
@@ -68,6 +69,7 @@ class SVNCommonLibrary:
self.version = version
self.dll_dir = dll_dir
self.dll_name = dll_name
+ self.is_src = is_src
if debug_lib_dir:
self.debug_lib_dir = debug_lib_dir
@@ -402,6 +404,13 @@ class GenDependenciesBase(gen_base.Gener
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:
@@ -485,6 +494,64 @@ class GenDependenciesBase(gen_base.Gener
'xml.lib', xml_version,
debug_lib_dir = debug_lib_dir)
+ def _find_zlib(self):
+ "Find the ZLib library and version"
+
+ minimal_zlib_version = (1, 2, 5)
+
+ if not self.zlib_path or not os.path.isdir(self.zlib_path):
+ sys.stderr.write("ERROR: '%s' not found.\n" % self.zlib_path);
+ sys.stderr.write("Use '--with-zlib' option to configure ZLib
location.\n");
+ sys.exit(1)
+
+ if os.path.isdir(os.path.join(self.zlib_path, 'include')):
+ # We have an install location
+ inc_path = os.path.join(self.zlib_path, 'include')
+ lib_path = os.path.join(self.zlib_path, 'lib')
+ is_src = False
+
+ # Different build options produce different library names :(
+ if os.path.exists(os.path.join(lib_path, 'zlibstatic.lib')):
+ # CMake default: zlibstatic.lib (static) and zlib.lib (dll)
+ lib_name = 'zlibstatic.lib'
+ else:
+ # Standard makefile produces zlib.lib (static) and zdll.lib (dll)
+ lib_name = 'zlib.lib'
+ debug_lib_name = None
+ else:
+ # We have a source location
+ inc_path = lib_path = self.zlib_path
+ is_src = True
+ lib_name = 'zlibstat.lib'
+ debug_lib_name = 'zlibstatD.lib'
+
+ version_file_path = os.path.join(inc_path, 'zlib.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-zlib' option to configure ZLib
location.\n");
+ sys.exit(1)
+
+ txt = open(version_file_path).read()
+ vermatch = re.search(
+ r'^\s*#define\s+ZLIB_VERSION\s+"(\d+)\.(\d+)\.(\d+)(?:\.\d)?"',
+ txt, re.M)
+
+ version = tuple(map(int, vermatch.groups()))
+ self.zlib_version = '%d.%d.%d' % version
+
+ if version < minimal_zlib_version:
+ sys.stderr.write("ERROR: ZLib %s or higher is required "
+ "(%s found)\n" % (
+ '.'.join(str(v) for v in minimal_zlib_version),
+ self.zlib_version))
+ sys.exit(1)
+
+ self._libraries['zlib'] = SVNCommonLibrary('zlib', inc_path, lib_path,
lib_name,
+ self.zlib_version,
+ debug_lib_name=debug_lib_name,
+ is_src=is_src)
+
def _find_bdb(self, show_warnings):
"Find the Berkeley DB library and version"
@@ -857,30 +924,6 @@ class GenDependenciesBase(gen_base.Gener
else:
print('Found SQLite %s' % self.sqlite_version)
- def _find_zlib(self):
- "Find the ZLib library and version"
-
- if not self.zlib_path:
- self.zlib_version = '1'
- return
-
- header_file = os.path.join(self.zlib_path, 'zlib.h')
-
- if not os.path.exists(header_file):
- self.zlib_version = '1'
- return
-
- fp = open(header_file)
- txt = fp.read()
- fp.close()
- vermatch =
re.search(r'^\s*#define\s+ZLIB_VERSION\s+"(\d+)\.(\d+)\.(\d+)(?:\.\d)?"', txt,
re.M)
-
- version = tuple(map(int, vermatch.groups()))
-
- self.zlib_version = '%d.%d.%d' % version
-
- print('Found ZLib %s' % self.zlib_version)
-
# ============================================================================
# This is a cut-down and modified version of code from:
# subversion/subversion/bindings/swig/python/svn/core.py