⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gen_win.py

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 PY
📖 第 1 页 / 共 3 页
字号:
## gen_win.py -- base class for generating windows projects#import osimport sysimport stringimport fnmatchimport reimport globimport generator.swig.header_wrappersimport generator.swig.checkout_swig_headerimport generator.swig.external_runtimetry:  from cStringIO import StringIOexcept ImportError:  from StringIO import StringIOimport gen_baseimport eztclass GeneratorBase(gen_base.GeneratorBase):  """This intermediate base class exists to be instantiated by win-tests.py,  in order to obtain information from build.conf without actually doing  any generation."""  _extension_map = {    ('exe', 'target'): '.exe',    ('exe', 'object'): '.obj',    ('lib', 'target'): '.dll',    ('lib', 'object'): '.obj',    }class WinGeneratorBase(GeneratorBase):  "Base class for all Windows project files generators"  def parse_options(self, options):    self.apr_path = 'apr'    self.apr_util_path = 'apr-util'    self.apr_iconv_path = 'apr-iconv'    self.serf_path = None    self.bdb_path = 'db4-win32'    self.neon_path = 'neon'    self.neon_ver = 24007    self.httpd_path = None    self.libintl_path = None    self.zlib_path = 'zlib'    self.openssl_path = None    self.junit_path = None    self.swig_path = None    self.vsnet_version = '7.00'    self.vsnet_proj_ver = '7.00'    self.skip_sections = { 'mod_dav_svn': None,                           'mod_authz_svn': None }    # Instrumentation options    self.instrument_apr_pools = None    self.instrument_purify_quantify = None    self.configure_apr_util = None    self.have_gen_uri = None    # NLS options    self.enable_nls = None    for opt, val in options:      if opt == '--with-berkeley-db':        self.bdb_path = val      elif opt == '--with-apr':        self.apr_path = val      elif opt == '--with-apr-util':        self.apr_util_path = val      elif opt == '--with-apr-iconv':        self.apr_iconv_path = val      elif opt == '--with-serf':        self.serf_path = val      elif opt == '--with-neon':        self.neon_path = val      elif opt == '--with-httpd':        self.httpd_path = val        del self.skip_sections['mod_dav_svn']        del self.skip_sections['mod_authz_svn']      elif opt == '--with-libintl':        self.libintl_path = val        self.enable_nls = 1      elif opt == '--with-junit':        self.junit_path = val      elif opt == '--with-zlib':        self.zlib_path = val      elif opt == '--with-swig':        self.swig_path = val      elif opt == '--with-openssl':        self.openssl_path = val      elif opt == '--enable-purify':        self.instrument_purify_quantify = 1        self.instrument_apr_pools = 1      elif opt == '--enable-quantify':        self.instrument_purify_quantify = 1      elif opt == '--enable-pool-debug':        self.instrument_apr_pools = 1      elif opt == '--enable-nls':        self.enable_nls = 1      elif opt == '--enable-bdb-in-apr-util':        self.configure_apr_util = 1      elif opt == '--vsnet-version':        if val == '2002' or re.match('7(\.\d+)?', val):          self.vsnet_version = '7.00'          self.vsnet_proj_ver = '7.00'          sys.stderr.write('Generating for VS.NET 2002\n')        elif val == '2003' or re.match('8(\.\d+)?', val):          self.vsnet_version = '8.00'          self.vsnet_proj_ver = '7.10'          sys.stderr.write('Generating for VS.NET 2003\n')        elif val == '2005' or re.match('9(\.\d+)?', val):          self.vsnet_version = '9.00'          self.vsnet_proj_ver = '8.00'          sys.stderr.write('Generating for VS.NET 2005\n')        else:          sys.stderr.write('WARNING: Unknown VS.NET version "%s",'                           ' assumimg "%s"\n' % (val, self.vsnet_version))  def __init__(self, fname, verfname, options, subdir):    """    Do some Windows specific setup    Build the list of Platforms & Configurations &    create the necessary paths    """    # parse (and save) the options that were passed to us    self.parse_options(options)    # Find db-4.0.x or db-4.1.x    self._find_bdb()    # Find the right Perl library name to link SWIG bindings with    self._find_perl()    # Find the installed SWIG version to adjust swig options    self._find_swig()    # Look for ML    if self.zlib_path:      self._find_ml()          # Find neon version    if self.neon_path:      self._find_neon()          # Check for gen_uri_delims project in apr-util    gen_uri_path = os.path.join(self.apr_util_path, 'uri',                                'gen_uri_delims.dsp')    if os.path.exists(gen_uri_path):      self.have_gen_uri = 1    # Run apr-util's w32locatedb.pl script    self._configure_apr_util()    #Make some files for the installer so that we don't need to    #require sed or some other command to do it    ### GJS: don't do this right now    if 0:      buf = open(os.path.join("packages","win32-innosetup","svn.iss.in"), 'rb').read()      buf = buf.replace("@VERSION@", "0.16.1+").replace("@RELEASE@", "4365")      buf = buf.replace("@DBBINDLL@", self.dbbindll)      svnissrel = os.path.join("packages","win32-innosetup","svn.iss.release")      svnissdeb = os.path.join("packages","win32-innosetup","svn.iss.debug")      if self.write_file_if_changed(svnissrel, buf.replace("@CONFIG@", "Release")):        print 'Wrote %s' % svnissrel      if self.write_file_if_changed(svnissdeb, buf.replace("@CONFIG@", "Debug")):        print 'Wrote %s' % svnissdeb    # Generate the build_zlib.bat file    if self.zlib_path:      data = {'zlib_path': os.path.abspath(self.zlib_path),              'use_ml': self.have_ml and 1 or None}      bat = os.path.join('build', 'win32', 'build_zlib.bat')      self.write_with_template(bat, 'build_zlib.ezt', data)    # Generate the build_locale.bat file    pofiles = []    if self.enable_nls:      for po in os.listdir(os.path.join('subversion', 'po')):        if fnmatch.fnmatch(po, '*.po'):          pofiles.append(POFile(po[:-3]))    data = {'pofiles': pofiles}    self.write_with_template(os.path.join('build', 'win32', 'build_locale.bat'),                             'build_locale.ezt', data)    #Initialize parent    GeneratorBase.__init__(self, fname, verfname, options)    #Make the project files directory if it doesn't exist    #TODO win32 might not be the best path as win64 stuff will go here too    self.projfilesdir=os.path.join("build","win32",subdir)    self.rootpath = ".." + "\\.." * string.count(self.projfilesdir, os.sep)    if not os.path.exists(self.projfilesdir):      os.makedirs(self.projfilesdir)    #Here we can add additional platforms to compile for    self.platforms = ['Win32']    #Here we can add additional modes to compile for    self.configs = ['Debug','Release']    if self.swig_libdir:      # Generate SWIG header wrappers and external runtime      for swig in (generator.swig.header_wrappers,                   generator.swig.checkout_swig_header,                   generator.swig.external_runtime):        swig.Generator(self.conf, self.swig_exe).write()    else:      print "%s not found; skipping SWIG file generation..." % self.swig_exe        def path(self, *paths):    """Convert build path to msvc path and prepend root"""    return msvc_path_join(self.rootpath, *map(msvc_path, paths))    def apath(self, path, *paths):    """Convert build path to msvc path and prepend root if not absolute"""    ### On Unix, os.path.isabs won't do the right thing if "item"    ### contains backslashes or drive letters    if os.path.isabs(path):      return msvc_path_join(msvc_path(path), *map(msvc_path, paths))    else:      return msvc_path_join(self.rootpath, msvc_path(path),                            *map(msvc_path, paths))  def get_install_targets(self):    "Generate the list of targets"    # Get list of targets to generate project files for    install_targets = self.graph.get_all_sources(gen_base.DT_INSTALL) \                      + self.projects    # Don't create projects for scripts    install_targets = filter(lambda x: not isinstance(x, gen_base.TargetScript),                             install_targets)    # Drop the serf target if we don't have it    if not self.serf_path:      install_targets = filter(lambda x: x.name != 'serf', install_targets)    # Drop the gen_uri_delims target unless we're on an old apr-util    if not self.have_gen_uri:      install_targets = filter(lambda x: x.name != 'gen_uri_delims',                               install_targets)          # Drop the libsvn_fs_base target and tests if we don't have BDB    if not self.bdb_lib:      install_targets = filter(lambda x: x.name != 'libsvn_fs_base',                               install_targets)      install_targets = filter(lambda x: not (isinstance(x, gen_base.TargetExe)                                              and x.install == 'bdb-test'),                               install_targets)    for target in install_targets:      if isinstance(target, gen_base.TargetLib) and target.msvc_fake:        install_targets.append(self.create_fake_target(target))    # sort these for output stability, to watch out for regressions.    install_targets.sort(lambda t1, t2: cmp(t1.name, t2.name))    return install_targets  def create_fake_target(self, dep):    "Return a new target which depends on another target but builds nothing"    section = gen_base.TargetProject.Section(gen_base.TargetProject,                                             dep.name + "_fake",                                             {'path': 'build/win32'}, self)    section.create_targets()    section.target.msvc_name = dep.msvc_name and dep.msvc_name + "_fake"    self.graph.add(gen_base.DT_LINK, section.target.name, dep)    dep.msvc_fake = section.target    return section.target  def get_configs(self, target):    "Get the list of configurations for the project"    configs = [ ]    for cfg in self.configs:      configs.append(        ProjectItem(name=cfg,                    lower=string.lower(cfg),                    defines=self.get_win_defines(target, cfg),                    libdirs=self.get_win_lib_dirs(target, cfg),                    libs=self.get_win_libs(target, cfg),                    ))    return configs    def get_proj_sources(self, quote_path, target):    "Get the list of source files for each project"    sources = [ ]    if not isinstance(target, gen_base.TargetProject):      cbuild = None      ctarget = None      for source, object, reldir in self.get_win_sources(target):        if isinstance(target, gen_base.TargetJavaHeaders):          classes = self.path(target.classes)          if self.junit_path is not None:            classes = "%s;%s" % (classes, self.junit_path)          headers = self.path(target.headers)          classname = target.package + "." + source.class_name          cbuild = "javah -verbose -force -classpath %s -d %s %s" \                   % (self.quote(classes), self.quote(headers), classname)          ctarget = self.path(object.filename_win)        elif isinstance(target, gen_base.TargetJavaClasses):          classes = targetdir = self.path(target.classes)          if self.junit_path is not None:            classes = "%s;%s" % (classes, self.junit_path)          sourcepath = self.path(source.sourcepath)          cbuild = "javac -g -target 1.2 -source 1.3 -classpath %s -d %s " \                   "-sourcepath %s $(InputPath)" \                   % tuple(map(self.quote, (classes, targetdir, sourcepath)))          ctarget = self.path(object.filename)        rsrc = self.path(str(source))        if quote_path and '-' in rsrc:          rsrc = '"%s"' % rsrc        sources.append(ProjectItem(path=rsrc, reldir=reldir, user_deps=[],                                   custom_build=cbuild, custom_target=ctarget))    if isinstance(target, gen_base.TargetJavaClasses) and target.jar:      classdir = self.path(target.classes)      jarfile = msvc_path_join(classdir, target.jar)      cbuild = "jar cf %s -C %s %s" \               % (jarfile, classdir, string.join(target.packages))      deps = map(lambda x: x.custom_target, sources)      sources.append(ProjectItem(path='makejar', reldir='', user_deps=deps,                                 custom_build=cbuild, custom_target=jarfile))    if isinstance(target, gen_base.TargetSWIG):      swig_options = string.split(self.swig.opts[target.lang])      swig_options.append('-DWIN32')      swig_deps = []      for include_dir in self.get_win_includes(target):        swig_options.append("-I%s" % self.quote(include_dir))      for obj in self.graph.get_sources(gen_base.DT_LINK, target.name):        if isinstance(obj, gen_base.SWIGObject):

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -