[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] fix exception of gen-make.py using --with-libintl [Re: svn commit: r1504501 - in /subversion/trunk: build.conf build/generator/gen_win.py build/generator/gen_win_dependencies.py gen-make.py win-tests.py]

From: Masaru Tsuchiyama <m.tmatma_at_gmail.com>
Date: Wed, 31 Jul 2013 21:53:54 +0900

Hi.

Running gen-make.py with --with-libintl option raises AttributeError exception
when using svn-win32-libintl.zip
at http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=2627&expandFolde
r=2627&folderID=260

_find_libintl in SVNCommonLibrary assumes libintl.h has the defininiton of
LIBINTL_VERSION. But libintl.h in svn-win32-libintl.zip doesn't have.

I attach a patch to fix it by skipping the version check
if LIBINTL_VERSION can't be found.

[[[[
Fix exception when running gen-make.py with --with-libintl option

* build/generator/gen_win_dependencies.py
   (_find_libintl) : skip version check for libintl.h if LIBINTL_VERSION can't be found
]]]

This is the stack trace.

> Use '--with-berkeley-db' to configure BDB location.
> Traceback (most recent call last):
> File "D:\svnwork\subversion\32bit\exception\gen-make.py", line 330, in <module>
> main(conf, gentype, skip_depends=skip, other_options=rest.list)
> File "D:\svnwork\subversion\32bit\exception\gen-make.py", line 60, in main
> generator = gen_module.Generator(fname, verfname, other_options)
> File "build\generator\gen_vcnet_vcproj.py", line 36, in __init__
> 'vcnet-vcproj')
> File "build\generator\gen_win.py", line 83, in __init__
> self.find_libraries(True)
> File "build\generator\gen_win_dependencies.py", line 287, in find_libraries
> self._find_libintl(show_warnings)
> File "build\generator\gen_win_dependencies.py", line 1185, in _find_libintl
> ver = int(match.group(1), 0)
> AttributeError: 'NoneType' object has no attribute 'group'

-- 
Masaru Tsuchiyama <m.tmatma_at_gmail.com>
> Author: rhuijben
> Date: Thu Jul 18 15:41:35 2013
> New Revision: 1504501
> 
> URL: http://svn.apache.org/r1504501
> Log:
> In the Windows project generator: Make libintl a proper optional dependency,
> instead of specializing the includes/libpath/library everywhere.
> 
> * build.conf
>   (libsvn_subr): Use libintl.
>   (intl): New marker project
> 
> * build/generator/gen_win.py
>   (get_win_includes): Just add includes. Remove libintl support.
>     Remove duplicated items.
>   (get_win_lib_dirs): Simplify addition. Remove duplicated items.
>   (get_win_libs): Remove specialized handling of libintl.
> 
> * build/generator/gen_win_dependencies.py
>   (SVNCommonLibrary): Add extra_include_dir option.
>   (find_libraries): Call _find_libintl.
>   (_find_apr): Really handle an install location.
>   (_find_openssl): Properly set bin_dir
>   (_find_libintl): New function.
> 
> * gen-make.py
>   (Options.add): Make overwriting old values optional.
>   (.): Don't override every --apr-* argument via --with-httpd.
> 
> * win-tests.py
>   (locate_libs): Remove libintl specific copying.
> 
> Modified:
>     subversion/trunk/build.conf
>     subversion/trunk/build/generator/gen_win.py
>     subversion/trunk/build/generator/gen_win_dependencies.py
>     subversion/trunk/gen-make.py
>     subversion/trunk/win-tests.py
> 
> Modified: subversion/trunk/build.conf
> URL: http://svn.apache.org/viewvc/subversion/trunk/build.conf?rev=1504501&r1=1504500&r2=1504501&view=diff
> ==============================================================================
> --- subversion/trunk/build.conf (original)
> +++ subversion/trunk/build.conf Thu Jul 18 15:41:35 2013
> @@ -340,7 +340,7 @@ description = Subversion General Utility
>  type = lib
>  install = fsmod-lib
>  path = subversion/libsvn_subr
> -libs = aprutil apriconv apr xml zlib apr_memcache sqlite magic
> +libs = aprutil apriconv apr xml zlib apr_memcache sqlite magic intl
>  msvc-libs = kernel32.lib advapi32.lib shfolder.lib ole32.lib
>              crypt32.lib version.lib psapi.lib
>  msvc-export = 
> @@ -1220,6 +1220,10 @@ type = lib
>  external-lib = $(SVN_OPENSSL_LIBS)
>  msvc-libs = ssleay32.lib libeay32.lib
>  
> +[intl]
> +type = lib
> +external-lib = $(SVN_INTL_LIBS)
> +
>  [zlib]
>  type = lib
>  external-lib = $(SVN_ZLIB_LIBS)
> 
> Modified: subversion/trunk/build/generator/gen_win.py
> URL: http://svn.apache.org/viewvc/subversion/trunk/build/generator/gen_win.py?rev=1504501&r1=1504500&r2=1504501&view=diff
> ==============================================================================
> --- subversion/trunk/build/generator/gen_win.py (original)
> +++ subversion/trunk/build/generator/gen_win.py Thu Jul 18 15:41:35 2013
> @@ -756,11 +756,8 @@ class WinGeneratorBase(gen_win_dependenc
>  
>          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])
> +
> +          fakeincludes.append(self.apath(lib.include_dir))
>  
>      if target.name == 'mod_authz_svn':
>        fakeincludes.extend([ self.apath(self.httpd_path, "modules/aaa") ])
> @@ -778,9 +775,6 @@ class WinGeneratorBase(gen_win_dependenc
>      else:
>        fakeincludes.extend([ self.path("subversion/bindings/swig/proxy") ])
>  
> -    if self.libintl_path:
> -      fakeincludes.append(self.apath(self.libintl_path, 'inc'))
> -
>      if self.swig_libdir \
>         and (isinstance(target, gen_base.TargetSWIG)
>              or isinstance(target, gen_base.TargetSWIGLib)):
> @@ -811,7 +805,7 @@ class WinGeneratorBase(gen_win_dependenc
>      if target.name.find('cxxhl') != -1:
>        fakeincludes.append(self.path("subversion/bindings/cxxhl/include"))
>  
> -    return fakeincludes
> +    return gen_base.unique(fakeincludes)
>  
>    def get_win_lib_dirs(self, target, cfg):
>      "Return the list of library directories for target"
> @@ -819,7 +813,7 @@ class WinGeneratorBase(gen_win_dependenc
>      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 \
> @@ -835,9 +829,7 @@ class WinGeneratorBase(gen_win_dependenc
>            else:
>              lib_dir = self.apath(lib.lib_dir)
>        
> -          # Avoid duplicate items
> -          if lib_dir and lib_dir not in fakelibdirs:
> -            fakelibdirs.extend([lib_dir])
> +          fakelibdirs.append(lib_dir)
>  
>      if not self.sqlite_inline:
>        fakelibdirs.append(self.apath(self.sqlite_path, "lib"))
> @@ -857,7 +849,7 @@ class WinGeneratorBase(gen_win_dependenc
>        if target.lang == "ruby" and self.ruby_libdir:
>          fakelibdirs.append(self.ruby_libdir)
>  
> -    return fakelibdirs
> +    return gen_base.unique(fakelibdirs)
>  
>    def get_win_libs(self, target, cfg):
>      "Return the list of external libraries needed for target"
> @@ -875,12 +867,6 @@ class WinGeneratorBase(gen_win_dependenc
>        return []
>  
>      nondeplibs = target.msvc_libs[:]
> -    if self.enable_nls:
> -      if self.libintl_path:
> -        nondeplibs.append(self.apath(self.libintl_path,
> -                                     'lib', 'intl3_svn.lib'))
> -      else:
> -        nondeplibs.append('intl3_svn.lib')
>  
>      if isinstance(target, gen_base.TargetExe):
>        nondeplibs.append('setargv.obj')
> @@ -924,6 +910,7 @@ class WinGeneratorBase(gen_win_dependenc
>            lib = None
>            
>          elif external_lib in ['db',
> +                              'intl',
>                                'serf',
>                                'sasl']:
>            lib = None # Suppress warnings for optional library
> 
> Modified: subversion/trunk/build/generator/gen_win_dependencies.py
> URL: http://svn.apache.org/viewvc/subversion/trunk/build/generator/gen_win_dependencies.py?rev=1504501&r1=1504500&r2=1504501&view=diff
> ==============================================================================
> --- subversion/trunk/build/generator/gen_win_dependencies.py (original)
> +++ subversion/trunk/build/generator/gen_win_dependencies.py Thu Jul 18 15:41:35 2013
> @@ -260,6 +260,7 @@ class GenDependenciesBase(gen_base.Gener
>      self._find_openssl(show_warnings)
>      self._find_serf(show_warnings)
>      self._find_sasl(show_warnings)
> +    self._find_libintl(show_warnings)
>  
>      if show_warnings:
>        # Find the right Ruby include and libraries dirs and
> @@ -300,14 +301,18 @@ class GenDependenciesBase(gen_base.Gener
>                         "location.\n")
>        sys.exit(1)                       
>  
> -    inc_path = os.path.join(self.apr_path, 'include')
> -    version_file_path = os.path.join(inc_path, 'apr_version.h')
> +    inc_base = os.path.join(self.apr_path, 'include')
>  
> -    if not os.path.exists(version_file_path):
> +    if os.path.isfile(os.path.join(inc_base, 'apr-1', 'apr_version.h')):
> +      inc_path = os.path.join(inc_base, 'apr-1')
> +    elif os.path.isfile(os.path.join(inc_path, 'apr_version.h')):
> +      inc_path = inc_base
> +    else:
>        sys.stderr.write("ERROR: '%s' not found.\n" % version_file_path)
>        sys.stderr.write("Use '--with-apr' option to configure APR location.\n")
>        sys.exit(1)
>  
> +    version_file_path = os.path.join(inc_path, 'apr_version.h')
>      txt = open(version_file_path).read()
>  
>      vermatch = re.search(r'^\s*#define\s+APR_MAJOR_VERSION\s+(\d+)', txt, re.M)
> @@ -363,8 +368,8 @@ class GenDependenciesBase(gen_base.Gener
>          dll_dir = lib_dir
>          debug_dll_dir = debug_lib_dir
>        else:
> -        dll_dir = lib_dir
> -        debug_dll_dir = debug_lib_dir
> +        dll_dir = os.path.join(self.apr_path, 'bin')
> +        debug_dll_dir = None
>        
>      self._libraries['apr'] = SVNCommonLibrary('apr', inc_path, lib_dir, lib_name,
>                                                apr_version,
> @@ -377,8 +382,18 @@ class GenDependenciesBase(gen_base.Gener
>      "Find the APR-util library and version"
>  
>      minimal_aprutil_version = (0, 9, 0)
> -    
> -    inc_path = os.path.join(self.apr_util_path, 'include')
> +
> +    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_path, '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')
>  
>      if not os.path.exists(version_file_path):
> @@ -413,7 +428,7 @@ class GenDependenciesBase(gen_base.Gener
>  
>      if self.static_apr:
>        lib_name = 'aprutil%s.lib' % suffix
> -      lib_dir = os.path.join(self.aprutil_path, 'LibR')
> +      lib_dir = os.path.join(self.apr_util_path, 'LibR')
>        dll_dir = None
>        debug_dll_dir = None
>        
> @@ -431,7 +446,7 @@ class GenDependenciesBase(gen_base.Gener
>        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(apr_util_path, 'lib')
> +        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')
> @@ -441,9 +456,9 @@ class GenDependenciesBase(gen_base.Gener
>          dll_dir = lib_dir
>          debug_dll_dir = debug_lib_dir
>        else:
> -        dll_dir = lib_dir
> -        debug_dll_dir = debug_lib_dir
> -      
> +        dll_dir = os.path.join(self.apr_util_path, 'bin')
> +        debug_dll_dir = None
> +
>      self._libraries['aprutil'] = SVNCommonLibrary('apr-util', inc_path, lib_dir,
>                                                     lib_name,
>                                                     aprutil_version,
> @@ -636,9 +651,10 @@ class GenDependenciesBase(gen_base.Gener
>        inc_dir = os.path.join(self.openssl_path, 'inc32')
>        if self.static_openssl:
>          lib_dir = os.path.join(self.openssl_path, 'out32')
> +        bin_dir = None
>        else:
>          lib_dir = os.path.join(self.openssl_path, 'out32dll')
> -        bin_dir = os.path.join(self.openssl_path, 'out32dll')
> +        bin_dir = lib_dir
>      elif os.path.isfile(os.path.join(self.openssl_path,
>                          'include/openssl/opensslv.h')):
>        version_path = os.path.join(self.openssl_path,
> @@ -646,9 +662,9 @@ class GenDependenciesBase(gen_base.Gener
>        inc_dir = os.path.join(self.openssl_path, 'include')
>        lib_dir = os.path.join(self.openssl_path, 'lib')
>        if self.static_openssl:
> -        self.bin_dir = None
> +        bin_dir = None
>        else:
> -        self.bin_dir = os.path.join(self.openssl_path, 'bin')
> +        bin_dir = os.path.join(self.openssl_path, 'bin')
>      else:
>        if show_warning:
>          print('WARNING: \'opensslv.h\' not found')
> @@ -676,7 +692,7 @@ class GenDependenciesBase(gen_base.Gener
>                                                      'libeay32.lib',
>                                                      openssl_version,
>                                                      dll_name='libeay32.dll',
> -                                                    dll_dir=bin_dir)                                                    
> +                                                    dll_dir=bin_dir)
>  
>    def _find_perl(self):
>      "Find the right perl library name to link swig bindings with"
> @@ -1019,6 +1035,59 @@ class GenDependenciesBase(gen_base.Gener
>                                                 dll_dir=dll_dir,
>                                                 dll_name=dll_name)
>  
> +  def _find_libintl(self, show_warning):
> +    "Find gettext support"
> +    minimal_libintl_version = (0, 14, 1)
> +
> +    if not self.enable_nls or not self.libintl_path:
> +      return;
> +
> +    # We support 2 scenarios.
> +    if os.path.isfile(os.path.join(self.libintl_path, 'inc', 'libintl.h')) and\
> +       os.path.isfile(os.path.join(self.libintl_path, 'lib', 'intl3_svn.lib')):
> +
> +      # 1. Subversion's custom libintl based on gettext 0.14.1
> +      inc_dir = os.path.join(self.libintl_path, 'inc')
> +      lib_dir = os.path.join(self.libintl_path, 'lib')
> +      dll_dir = os.path.join(self.libintl_path, 'bin')
> +
> +      lib_name = 'intl3_svn.lib'
> +      dll_name = 'intl3_svn.dll'
> +    elif os.path.isfile(os.path.join(self.libintl_path, \
> +                                     'include', 'libintl.h')):
> +      # 2. A gettext install
> +      inc_dir = os.path.join(self.libintl_path, 'include')
> +      lib_dir = os.path.join(self.libintl_path, 'lib')
> +      dll_dir = os.path.join(self.libintl_path, 'bin')
> +
> +      lib_name = 'intl.lib'
> +      dll_name = 'intl.dll'
> +    else:
> +      if (show_warning):
> +        print('WARNING: \'libintl.h\' not found')
> +        print("Use '--with-libintl' to configure libintl location.")
> +      return
> +
> +    version_file_path = os.path.join(inc_dir, 'libintl.h')
> +    txt = open(version_file_path).read()
> +
> +    vermatch = re.search(r'^\s*#define\s+LIBINTL_VERSION\s+((0x)?[0-9A-Fa-f]+)', txt, re.M)
> +
> +    ver = int(vermatch.group(1), 0)
> +    version = (ver >> 16, (ver >> 8) & 0xFF, ver & 0xFF)
> +
> +    libintl_version = '.'.join(str(v) for v in version)
> +
> +    if version < minimal_libintl_version:
> +      msg = 'Found libintl %s, but >= %s is required.\n' % \
> +            (libintl_version, '.'.join(str(v) for v in minimal_libintl_version))
> +      return
> +
> +    self._libraries['intl'] = SVNCommonLibrary('libintl', inc_dir, lib_dir,
> +                                               lib_name, libintl_version,
> +                                               dll_dir=dll_dir,
> +                                               dll_name=dll_name)
> +
>    def _find_sqlite(self):
>      "Find the Sqlite library and version"
>  
> 
> Modified: subversion/trunk/gen-make.py
> URL: http://svn.apache.org/viewvc/subversion/trunk/gen-make.py?rev=1504501&r1=1504500&r2=1504501&view=diff
> ==============================================================================
> --- subversion/trunk/gen-make.py (original)
> +++ subversion/trunk/gen-make.py Thu Jul 18 15:41:35 2013
> @@ -224,9 +224,10 @@ class Options:
>      self.list = []
>      self.dict = {}
>  
> -  def add(self, opt, val):
> +  def add(self, opt, val, overwrite=True):
>      if opt in self.dict:
> -      self.list[self.dict[opt]] = (opt, val)
> +      if overwrite:
> +        self.list[self.dict[opt]] = (opt, val)
>      else:
>        self.dict[opt] = len(self.list)
>        self.list.append((opt, val))
> @@ -309,9 +310,12 @@ if __name__ == '__main__':
>        gentype = val
>      else:
>        if opt == '--with-httpd':
> -        rest.add('--with-apr', os.path.join(val, 'srclib', 'apr'))
> -        rest.add('--with-apr-util', os.path.join(val, 'srclib', 'apr-util'))
> -        rest.add('--with-apr-iconv', os.path.join(val, 'srclib', 'apr-iconv'))
> +        rest.add('--with-apr', os.path.join(val, 'srclib', 'apr'),
> +                 overwrite=False)
> +        rest.add('--with-apr-util', os.path.join(val, 'srclib', 'apr-util'),
> +                 overwrite=False)
> +        rest.add('--with-apr-iconv', os.path.join(val, 'srclib', 'apr-iconv'),
> +                 overwrite=False)
>  
>    # Remember all options so that --reload and other scripts can use them
>    opt_conf = open('gen-make.opts', 'w')
> 
> Modified: subversion/trunk/win-tests.py
> URL: http://svn.apache.org/viewvc/subversion/trunk/win-tests.py?rev=1504501&r1=1504500&r2=1504501&view=diff
> ==============================================================================
> --- subversion/trunk/win-tests.py (original)
> +++ subversion/trunk/win-tests.py Thu Jul 18 15:41:35 2013
> @@ -336,9 +336,6 @@ def locate_libs():
>      if name and dir:
>        dlls.append(os.path.join(dir, name))
>  
> -  if gen_obj.libintl_path:
> -    dlls.append(os.path.join(gen_obj.libintl_path, 'bin', 'intl3_svn.dll'))
> -
>    for dll in dlls:
>      copy_changed_file(dll, abs_objdir)
>  
> 

Received on 2013-07-31 14:54:34 CEST

This is an archived mail posted to the Subversion Dev mailing list.