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

📄 gen_win.py

📁 linux subdivision ying gai ke yi le ba
💻 PY
📖 第 1 页 / 共 3 页
字号:

    if cfg == 'Debug':
      fakedefines.extend(["_DEBUG","SVN_DEBUG"])
    elif cfg == 'Release':
      fakedefines.append("NDEBUG")

    # XXX: Check if db is present, and if so, let apr-util know
    # XXX: This is a hack until the apr build system is improved to
    # XXX: know these things for itself.
    if self.bdb_lib:
      fakedefines.append("APU_HAVE_DB=1")

    # check if they wanted nls
    if self.enable_nls:
      fakedefines.append("ENABLE_NLS")

    return fakedefines

  def get_win_includes(self, target):
    "Return the list of include directories for target"

    if isinstance(target, gen_base.TargetApacheMod):
      fakeincludes = [ self.path("subversion/include"),
                       self.apath(self.bdb_path, "include"),
                       self.path("subversion") ]
      fakeincludes.extend([
        self.apath(self.apr_path, "include"),
        self.apath(self.apr_util_path, "include"),
        self.apath(self.apr_util_path, "xml/expat/lib"),
        self.apath(self.httpd_path, "include")
        ])
    elif isinstance(target, gen_base.TargetSWIG):
      util_includes = "subversion/bindings/swig/%s/libsvn_swig_%s" \
                      % (target.lang,
                         gen_base.lang_utillib_suffix[target.lang])
      fakeincludes = [ self.path("subversion/bindings/swig"),
                       self.path("subversion/include"),
                       self.path(util_includes),
                       self.apath(self.apr_path, "include"),
                       self.apath(self.apr_util_path, "include") ]
    else:
      fakeincludes = [ self.path("subversion/include"),
                       self.apath(self.apr_path, "include"),
                       self.apath(self.apr_util_path, "include"),
                       self.apath(self.apr_util_path, "xml/expat/lib"),
                       self.path("neon/src"),
                       self.apath(self.bdb_path, "include"),
                       self.path("subversion") ]

    if self.swig_libdir \
       and (isinstance(target, gen_base.TargetSWIG)
            or isinstance(target, gen_base.TargetSWIGLib)):
      fakeincludes.append(self.swig_libdir)

    return fakeincludes

  def get_win_lib_dirs(self, target, cfg):
    "Return the list of library directories for target"

    libcfg = string.replace(string.replace(cfg, "Debug", "LibD"),
                            "Release", "LibR")

    fakelibdirs = [ self.apath(self.bdb_path, "lib") ]
    if isinstance(target, gen_base.TargetApacheMod):
      fakelibdirs.append(self.apath(self.httpd_path, cfg))
      if target.name == 'mod_dav_svn':
        fakelibdirs.append(self.apath(self.httpd_path, "modules/dav/main", 
                                      cfg))

    return fakelibdirs

  def get_win_libs(self, target, cfg):
    "Return the list of external libraries needed for target"

    dblib = self.bdb_lib+(cfg == 'Debug' and 'd.lib' or '.lib')

    if not isinstance(target, gen_base.TargetLinked):
      return []

    if isinstance(target, gen_base.TargetLib) and target.msvc_static:
      return []

    nondeplibs = target.msvc_libs[:]
    if self.enable_nls:
      nondeplibs.extend(['intl.lib'])

    if isinstance(target, gen_base.TargetExe):
      nondeplibs.append('setargv.obj')

    if ((isinstance(target, gen_base.TargetSWIG) 
         or isinstance(target, gen_base.TargetSWIGLib))
        and target.lang == 'perl'):
      nondeplibs.append(self.perl_lib)

    for dep in self.get_win_depends(target, FILTER_LIBS):
      nondeplibs.extend(dep.msvc_libs)

      if dep.external_lib == '$(SVN_DB_LIBS)':
        nondeplibs.append(dblib)

    return gen_base.unique(nondeplibs)

  def get_win_sources(self, target, reldir_prefix=''):
    "Return the list of source files that need to be compliled for target"

    sources = { }

    for obj in self.graph.get_sources(gen_base.DT_LINK, target.name):
      if isinstance(obj, gen_base.Target):
        continue

      for src in self.graph.get_sources(gen_base.DT_OBJECT, obj):
        if isinstance(src, gen_base.SourceFile):
          if reldir_prefix:
            if src.reldir:
              reldir = reldir_prefix + '\\' + src.reldir
            else:
              reldir = reldir_prefix
          else:
            reldir = src.reldir
        else:
          reldir = ''
        sources[src] = src, obj, reldir

    return sources.values()

  def write_file_if_changed(self, fname, new_contents):
    """Rewrite the file if new_contents are different than its current content.

    If you have your windows projects open and generate the projects
    it's not a small thing for windows to re-read all projects so
    only update those that have changed.
    """

    try:
      old_contents = open(fname, 'rb').read()
    except IOError:
      old_contents = None
    if old_contents != new_contents:
      open(fname, 'wb').write(new_contents)
      print "Wrote:", fname

  def write_with_template(self, fname, tname, data):
    fout = StringIO()

    template = ezt.Template(compress_whitespace = 0)
    template.parse_file(os.path.join('build', 'generator', tname))
    template.generate(fout, data)

    self.write_file_if_changed(fname, fout.getvalue())

  def write(self):
    "Override me when creating a new project type"

    raise NotImplementedError

  def _find_bdb(self):
    "Find the Berkley DB library and version"
    for lib in ("libdb42", "libdb41", "libdb40"):
      path = os.path.join(self.bdb_path, "lib")
      if os.path.exists(os.path.join(path, lib + ".lib")):
        sys.stderr.write("Found %s.lib in %s\n" % (lib, path))
        self.bdb_lib = lib
        break
    else:
      sys.stderr.write("DB not found; assuming db-4.2.x in db4-win32 "
                       "by default\n")
      self.bdb_lib = "libdb42"

  def _find_perl(self):
    "Find the right perl library name to link swig bindings with"
    fp = os.popen('perl -MConfig -e ' + escape_shell_arg(
                  'print "$Config{PERL_REVISION}$Config{PERL_VERSION}"'), 'r')
    try:
      num = fp.readline()
      if num:
        msg = 'Found installed perl version number.'
        self.perl_lib = 'perl' + string.rstrip(num) + '.lib'
      else:
        msg = 'Could not detect perl version.'
        self.perl_lib = 'perl56.lib'
      sys.stderr.write('%s\n  Perl bindings will be linked with %s\n'
                       % (msg, self.perl_lib))
    finally:
      fp.close()

  def _find_swig(self):
    # Require (and assume) version 1.3.19
    base_version = '1.3.19'
    vernum = base_vernum = 103019
    libdir = ''

    infp, outfp = os.popen4('swig -version')
    infp.close()
    try:
      txt = outfp.read()
      if (txt):
        vermatch = re.compile(r'^SWIG\ Version\ (\d+)\.(\d+)\.(\d+)$', re.M) \
                   .search(txt)
      else:
        vermatch = None

      if (vermatch):
        version = (int(vermatch.group(1)),
                   int(vermatch.group(2)),
                   int(vermatch.group(3)))
        # build/ac-macros/swig.m4 explains the next incantation
        vernum = int('%d%02d%03d' % version)
        sys.stderr.write('Found installed SWIG version %d.%d.%d\n' % version)
        if vernum < base_vernum:
          sys.stderr.write('WARNING: Subversion requires version %s\n'
                           % base_version)

        libdir = self._find_swig_libdir()
      else:
        sys.stderr.write('Could not find installed SWIG,'
                         ' assuming version %s\n' % base_version)
        self.swig_libdir = ''
    finally:
      outfp.close()

    self.swig_defines = 'SVN_SWIG_VERSION=%d' % vernum
    self.swig_vernum = vernum
    self.swig_libdir = libdir

  def _find_swig_libdir(self):
    fp = os.popen('swig -swiglib', 'r')
    try:
      libdir = string.rstrip(fp.readline())
      if libdir:
        sys.stderr.write('Using SWIG library directory %s\n' % libdir)
        return libdir
      else:
        sys.stderr.write('WARNING: could not find SWIG library directory\n')
    finally:
      fp.close()
    return ''

  def _configure_apr_util(self):
    if not self.configure_apr_util:
      return
    script_path = os.path.join(self.apr_util_path, "build", "w32locatedb.pl")
    inc_path = os.path.join(self.bdb_path, "include")
    lib_path = os.path.join(self.bdb_path, "lib")
    cmdline = "perl %s dll %s %s" % (escape_shell_arg(script_path),
                                     escape_shell_arg(inc_path),
                                     escape_shell_arg(lib_path))
    sys.stderr.write('Configuring apr-util library...\n%s\n' % cmdline)
    if os.system(cmdline):
      sys.stderr.write('WARNING: apr-util library was not configured'
                       ' successfully\n')

class ProjectItem:
  "A generic item class for holding sources info, config info, etc for a project"
  def __init__(self, **kw):
    vars(self).update(kw)

if sys.platform == "win32":
  def escape_shell_arg(str):
    return '"' + string.replace(str, '"', '"^""') + '"'
else:
  def escape_shell_arg(str):
    return "'" + string.replace(str, "'", "'\\''") + "'"

FILTER_LIBS = 1
FILTER_PROJECTS = 2

class POFile:
  "Item class for holding po file info"
  def __init__(self, base):
    self.po = base + '.po'
    self.spo = base + '.spo'
    self.mo = base + '.mo'

# MSVC paths always use backslashes regardless of current platform
def msvc_path(path):
  """Convert a build path to an msvc path"""
  return string.replace(path, '/', '\\')

def msvc_path_join(*path_parts):
  """Join path components into an msvc path"""
  return string.join(path_parts, '\\')

⌨️ 快捷键说明

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