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

📄 gen_base.py

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 PY
📖 第 1 页 / 共 3 页
字号:
        self.gen_obj.projects.append(self)      return    # the specified install area depends upon this target    self.gen_obj.graph.add(DT_INSTALL, self.install, self)    sources = _collect_paths(self.sources or '*.c', self.path)    sources.sort()    for src, reldir in sources:      if src[-2:] == '.c':        objname = src[:-2] + self.objext      elif src[-4:] == '.cpp':        objname = src[:-4] + self.objext      else:        raise GenError('ERROR: unknown file extension on ' + src)      ofile = ObjectFile(objname, self.compile_cmd)      # object depends upon source      self.gen_obj.graph.add(DT_OBJECT, ofile, SourceFile(src, reldir))      # target (a linked item) depends upon object      self.gen_obj.graph.add(DT_LINK, self.name, ofile)    # collect all the paths where stuff might get built    ### we should collect this from the dependency nodes rather than    ### the sources. "what dir are you going to put yourself into?"    self.gen_obj.target_dirs.append(self.path)    for pattern in string.split(self.sources):      dirname = build_path_dirname(pattern)      if dirname:        self.gen_obj.target_dirs.append(build_path_join(self.path, dirname))class TargetExe(TargetLinked):  def __init__(self, name, options, gen_obj):    TargetLinked.__init__(self, name, options, gen_obj)    if not (self.external_lib or self.external_project):      extmap = self.gen_obj._extension_map      self.objext = extmap['exe', 'object']      self.filename = build_path_join(self.path, name + extmap['exe', 'target'])    self.manpages = options.get('manpages', '')    self.testing = options.get('testing')  def add_dependencies(self):    TargetLinked.add_dependencies(self)    # collect test programs    if self.install == 'test':      self.gen_obj.test_deps.append(self.filename)      if self.testing != 'skip':        self.gen_obj.test_progs.append(self.filename)    elif self.install == 'bdb-test':      self.gen_obj.bdb_test_deps.append(self.filename)      if self.testing != 'skip':        self.gen_obj.bdb_test_progs.append(self.filename)    self.gen_obj.manpages.extend(string.split(self.manpages))class TargetScript(Target):  def add_dependencies(self):    # we don't need to "compile" the sources, so there are no dependencies    # to add here, except to get the script installed in the proper area.    # note that the script might itself be generated, but that isn't a    # concern here.    self.gen_obj.graph.add(DT_INSTALL, self.install, self)class TargetLib(TargetLinked):  def __init__(self, name, options, gen_obj):    TargetLinked.__init__(self, name, options, gen_obj)    if not (self.external_lib or self.external_project):      extmap = gen_obj._extension_map      self.objext = extmap['lib', 'object']      # the target file is the name, version, and appropriate extension      tfile = '%s-%s%s' % (name, gen_obj.version, extmap['lib', 'target'])      self.filename = build_path_join(self.path, tfile)    # Is a library referencing symbols which are undefined at link time.    self.undefined_lib_symbols = options.get('undefined-lib-symbols') == 'yes'    self.msvc_static = options.get('msvc-static') == 'yes' # is a static lib    self.msvc_fake = options.get('msvc-fake') == 'yes' # has fake target    self.msvc_export = string.split(options.get('msvc-export', ''))class TargetApacheMod(TargetLib):  def __init__(self, name, options, gen_obj):    TargetLib.__init__(self, name, options, gen_obj)    tfile = name + self.gen_obj._extension_map['lib', 'target']    self.filename = build_path_join(self.path, tfile)    # we have a custom linking rule    ### hmm. this is Makefile-specific    self.compile_cmd = '$(COMPILE_APACHE_MOD)'    self.link_cmd = '$(LINK_APACHE_MOD)'class TargetRaModule(TargetLib):  passclass TargetFsModule(TargetLib):  passclass TargetDoc(Target):  passclass TargetI18N(Target):  "The target is a collection of .po files to be compiled by msgfmt."  def __init__(self, name, options, gen_obj):    Target.__init__(self, name, options, gen_obj)    self.install = options.get('install')    self.sources = options.get('sources')    # Let the Makefile determine this via .SUFFIXES    self.compile_cmd = None    self.objext = '.mo'    self.external_project = options.get('external-project')  def add_dependencies(self):    self.gen_obj.graph.add(DT_INSTALL, self.install, self)    sources = _collect_paths(self.sources or '*.po', self.path)    sources.sort()    for src, reldir in sources:      if src[-3:] == '.po':        objname = src[:-3] + self.objext      else:        raise GenError('ERROR: unknown file extension on ' + src)      ofile = ObjectFile(objname, self.compile_cmd)      # object depends upon source      self.gen_obj.graph.add(DT_OBJECT, ofile, SourceFile(src, reldir))      # target depends upon object      self.gen_obj.graph.add(DT_LINK, self.name, ofile)    # Add us to the list of target dirs, so we're created in mkdir-init.    self.gen_obj.target_dirs.append(self.path)class TargetSWIG(TargetLib):  def __init__(self, name, options, gen_obj, lang):    TargetLib.__init__(self, name, options, gen_obj)    self.lang = lang    self.desc = self.desc + ' for ' + lang_full_name[lang]    self.include_runtime = options.get('include-runtime') == 'yes'    ### hmm. this is Makefile-specific    self.link_cmd = '$(LINK_%s_WRAPPER)' % string.upper(lang_abbrev[lang])  def add_dependencies(self):    # Look in source directory for dependencies    self.gen_obj.target_dirs.append(self.path)    sources = _collect_paths(self.sources, self.path)    assert len(sources) == 1  ### simple assertions for now    # get path to SWIG .i file    ipath = sources[0][0]    iname = build_path_basename(ipath)    assert iname[-2:] == '.i'    cname = iname[:-2] + '.c'    oname = iname[:-2] + self.gen_obj._extension_map['lib', 'object']    # Extract SWIG module name from .i file name    module_name = iname[:4] != 'svn_' and iname[:-2] or iname[4:-2]    lib_extension = self.gen_obj._extension_map['lib', 'target']    if self.lang == "ruby":      lib_filename = module_name + lib_extension    elif self.lang == "perl":      lib_filename = '_' + string.capitalize(module_name) + lib_extension    else:      lib_filename = '_' + module_name + lib_extension    self.name = self.lang + '_' + module_name    self.path = build_path_join(self.path, self.lang)    if self.lang == "perl":      self.path = build_path_join(self.path, "native")    self.filename = build_path_join(self.path, lib_filename)    ifile = SWIGSource(ipath)    cfile = SWIGObject(build_path_join('$(top_srcdir)', self.path, cname),                       self.lang)    ofile = SWIGObject(build_path_join(self.path, oname), self.lang)    # the .c file depends upon the .i file    self.gen_obj.graph.add(DT_SWIG_C, cfile, ifile)    # the object depends upon the .c file    self.gen_obj.graph.add(DT_OBJECT, ofile, cfile)    # the library depends upon the object    self.gen_obj.graph.add(DT_LINK, self.name, ofile)    # the specified install area depends upon the library    self.gen_obj.graph.add(DT_INSTALL, 'swig-' + lang_abbrev[self.lang], self)  class Section(TargetLib.Section):    def create_targets(self):      self.targets = { }      for lang in self.gen_obj.swig_lang:        target = self.target_class(self.name, self.options, self.gen_obj, lang)        target.add_dependencies()        self.targets[lang] = target    def get_targets(self):      return self.targets.values()    def get_dep_targets(self, target):      target = self.targets.get(target.lang, None)      return target and [target] or [ ]class TargetSWIGLib(TargetLib):  def __init__(self, name, options, gen_obj):    TargetLib.__init__(self, name, options, gen_obj)    self.lang = options.get('lang')  class Section(TargetLib.Section):    def get_dep_targets(self, target):      if target.lang == self.target.lang:        return [ self.target ]      return [ ]class TargetProject(Target):  def __init__(self, name, options, gen_obj):    Target.__init__(self, name, options, gen_obj)    self.cmd = options.get('cmd')    self.release = options.get('release')    self.debug = options.get('debug')  def add_dependencies(self):    self.gen_obj.projects.append(self)class TargetSWIGProject(TargetProject):  def __init__(self, name, options, gen_obj):    TargetProject.__init__(self, name, options, gen_obj)    self.lang = options.get('lang')class TargetJava(TargetLinked):  def __init__(self, name, options, gen_obj):    TargetLinked.__init__(self, name, options, gen_obj)    self.link_cmd = options.get('link-cmd')    self.packages = string.split(options.get('package-roots', ''))    self.jar = options.get('jar')    self.deps = [ ]class TargetJavaHeaders(TargetJava):  def __init__(self, name, options, gen_obj):    TargetJava.__init__(self, name, options, gen_obj)    self.objext = '.class'    self.javah_objext = '.h'    self.headers = options.get('headers')    self.classes = options.get('classes')    self.package = options.get('package')    self.output_dir = self.headers  def add_dependencies(self):    sources = _collect_paths(self.sources, self.path)    for src, reldir in sources:      if src[-5:] != '.java':        raise GenError('ERROR: unknown file extension on ' + src)      class_name = build_path_basename(src[:-5])      class_header = build_path_join(self.headers, class_name + '.h')      class_header_win = build_path_join(self.headers,                                          string.replace(self.package,".", "_")                                         + "_" + class_name + '.h')      class_pkg_list = string.split(self.package, '.')      class_pkg = apply(build_path_join, class_pkg_list)      class_file = ObjectFile(build_path_join(self.classes, class_pkg,                                              class_name + self.objext))      class_file.source_generated = 1      class_file.class_name = class_name      hfile = HeaderFile(class_header, self.package + '.' + class_name,                         self.compile_cmd)      hfile.filename_win = class_header_win      hfile.source_generated = 1      self.gen_obj.graph.add(DT_OBJECT, hfile, class_file)      self.deps.append(hfile)      # target (a linked item) depends upon object      self.gen_obj.graph.add(DT_LINK, self.name, hfile)    # collect all the paths where stuff might get built    ### we should collect this from the dependency nodes rather than    ### the sources. "what dir are you going to put yourself into?"    self.gen_obj.target_dirs.append(self.path)    self.gen_obj.target_dirs.append(self.classes)    self.gen_obj.target_dirs.append(self.headers)    for pattern in string.split(self.sources):      dirname = build_path_dirname(pattern)      if dirname:        self.gen_obj.target_dirs.append(build_path_join(self.path, dirname))    self.gen_obj.graph.add(DT_INSTALL, self.name, self)class TargetJavaClasses(TargetJava):  def __init__(self, name, options, gen_obj):    TargetJava.__init__(self, name, options, gen_obj)    self.objext = '.class'    self.lang = 'java'    self.classes = options.get('classes')    self.output_dir = self.classes  def add_dependencies(self):    sources =_collect_paths(self.sources, self.path)    for src, reldir in sources:      if src[-5:] == '.java':        objname = src[:-5] + self.objext        # As .class files are likely not generated into the same        # directory as the source files, the object path may need        # adjustment.  To this effect, take "target_ob.classes" into        # account.        dirs = build_path_split(objname)        sourcedirs = dirs[:-1]  # Last element is the .class file name.        while sourcedirs:          if sourcedirs.pop() in self.packages:            sourcepath = apply(build_path_join, sourcedirs)            objname = apply(build_path_join,                             [self.classes] + dirs[len(sourcedirs):])            break        else:          raise GenError('Unable to find Java package root in path "%s"' % objname)      else:        raise GenError('ERROR: unknown file extension on "' + src + '"')      ofile = ObjectFile(objname, self.compile_cmd)      sfile = SourceFile(src, reldir)      sfile.sourcepath = sourcepath      # object depends upon source      self.gen_obj.graph.add(DT_OBJECT, ofile, sfile)      # target (a linked item) depends upon object      self.gen_obj.graph.add(DT_LINK, self.name, ofile)      # Add the class file to the dependency tree for this target      self.deps.append(ofile)    # collect all the paths where stuff might get built    ### we should collect this from the dependency nodes rather than    ### the sources. "what dir are you going to put yourself into?"    self.gen_obj.target_dirs.append(self.path)    self.gen_obj.target_dirs.append(self.classes)    for pattern in string.split(self.sources):      dirname = build_path_dirname(pattern)      if dirname:        self.gen_obj.target_dirs.append(build_path_join(self.path, dirname))    self.gen_obj.graph.add(DT_INSTALL, self.name, self)_build_types = {  'exe' : TargetExe,  'script' : TargetScript,

⌨️ 快捷键说明

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