📄 gen_base.py
字号:
if self.external_lib or self.external_project:
if self.external_project:
graph.add(DT_LIST, LT_PROJECT, self)
return
# the specified install area depends upon this target
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
graph.add(DT_OBJECT, ofile, SourceFile(src, reldir))
# target (a linked item) depends upon object
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?"
graph.add(DT_LIST, LT_TARGET_DIRS, self.path)
for pattern in string.split(self.sources):
dirname = build_path_dirname(pattern)
if dirname:
graph.add(DT_LIST, LT_TARGET_DIRS,
build_path_join(self.path, dirname))
class TargetExe(TargetLinked):
def __init__(self, name, options, cfg, extmap):
TargetLinked.__init__(self, name, options, cfg, extmap)
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, graph, cfg, extmap):
TargetLinked.add_dependencies(self, graph, cfg, extmap)
# collect test programs
if self.install == 'test':
graph.add(DT_LIST, LT_TEST_DEPS, self.filename)
if self.testing != 'skip':
graph.add(DT_LIST, LT_TEST_PROGS, self.filename)
elif self.install == 'bdb-test':
graph.add(DT_LIST, LT_BDB_TEST_DEPS, self.filename)
if self.testing != 'skip':
graph.add(DT_LIST, LT_BDB_TEST_PROGS, self.filename)
graph.bulk_add(DT_LIST, LT_MANPAGES, string.split(self.manpages))
class TargetScript(Target):
def add_dependencies(self, graph, cfg, extmap):
# 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.
graph.add(DT_INSTALL, self.install, self)
class TargetLib(TargetLinked):
def __init__(self, name, options, cfg, extmap):
TargetLinked.__init__(self, name, options, cfg, extmap)
self.objext = extmap['lib', 'object']
# the target file is the name, version, and appropriate extension
tfile = '%s-%s%s' % (name, cfg.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, cfg, extmap):
TargetLib.__init__(self, name, options, cfg, extmap)
tfile = name + extmap['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):
pass
class TargetFsModule(TargetLib):
pass
class TargetDoc(Target):
pass
class TargetI18N(Target):
"The target is a collection of .po files to be compiled by msgfmt."
def __init__(self, name, options, cfg, extmap):
Target.__init__(self, name, options, cfg, extmap)
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, graph, cfg, extmap):
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
graph.add(DT_OBJECT, ofile, SourceFile(src, reldir))
# target depends upon object
graph.add(DT_NONLIB, self.name, ofile)
# Add us to the list of target dirs, so we're created in mkdir-init.
graph.add(DT_LIST, LT_TARGET_DIRS, self.path)
class TargetSWIG(TargetLib):
def __init__(self, name, options, cfg, extmap, lang):
TargetLib.__init__(self, name, options, cfg, extmap)
self.lang = lang
self.desc = self.desc + ' for ' + lang_full_name[lang]
### hmm. this is Makefile-specific
self.link_cmd = '$(LINK_%s_WRAPPER)' % string.upper(lang_abbrev[lang])
def add_dependencies(self, graph, cfg, extmap):
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] + extmap['lib', 'object']
### we should really extract the %module line
libname = iname[:4] != 'svn_' and ('_' + iname[:-2]) or iname[3:-2]
libfile = libname + extmap['lib', 'target']
self.name = self.lang + libname
self.path = build_path_join(self.path, self.lang)
if self.lang == "perl":
self.filename = build_path_join(self.path, libfile[0]
+ string.capitalize(libfile[1:]))
else:
self.filename = build_path_join(self.path, libfile)
ifile = SWIGSource(ipath)
cfile = SWIGObject(build_path_join(self.path, cname), self.lang)
ofile = SWIGObject(build_path_join(self.path, oname), self.lang)
# the .c file depends upon the .i file
graph.add(DT_SWIG_C, cfile, ifile)
# the object depends upon the .c file
graph.add(DT_OBJECT, ofile, cfile)
# the library depends upon the object
graph.add(DT_LINK, self.name, ofile)
abbrev = lang_abbrev[self.lang]
# the specified install area depends upon the library
graph.add(DT_INSTALL, 'swig-' + abbrev, self)
class Section(TargetLib.Section):
def create_targets(self, graph, name, cfg, extmap):
self.targets = { }
for lang in cfg.swig_lang:
target = self.target_class(name, self.options, cfg, extmap, lang)
target.add_dependencies(graph, cfg, extmap)
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 TargetSWIGRuntime(TargetSWIG):
def add_dependencies(self, graph, cfg, extmap):
abbrev = lang_abbrev[self.lang]
name = 'swig' + abbrev
cname = name + '.c'
oname = name + extmap['lib', 'object']
libname = name + extmap['lib', 'target']
self.name = self.lang + '_runtime'
self.path = build_path_join(self.path, self.lang)
self.filename = build_path_join(self.path, libname)
self.external_lib = "$(LSWIG" + string.upper(abbrev) + ")"
cfile = SWIGObject(build_path_join(self.path, cname), self.lang)
ofile = SWIGObject(build_path_join(self.path, oname), self.lang)
graph.add(DT_OBJECT, ofile, cfile)
graph.add(DT_LINK, self.name, ofile)
graph.add(DT_INSTALL, 'swig_runtime-' + abbrev, self)
class Section(TargetSWIG.Section):
def create_targets(self, graph, name, cfg, extmap):
self.targets = { }
for lang in cfg.swig_lang:
if lang == 'java':
# java doesn't seem to have a separate runtime
continue
target = self.target_class(name, self.options, cfg, extmap, lang)
target.add_dependencies(graph, cfg, extmap)
self.targets[lang] = target
class TargetSWIGLib(TargetLib):
def __init__(self, name, options, cfg, extmap):
TargetLib.__init__(self, name, options, cfg, extmap)
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, cfg, extmap):
Target.__init__(self, name, options, cfg, extmap)
self.cmd = options.get('cmd')
self.release = options.get('release')
self.debug = options.get('debug')
self.filename = name
def add_dependencies(self, graph, cfg, extmap):
graph.add(DT_LIST, LT_PROJECT, self)
class TargetSWIGProject(TargetProject):
def __init__(self, name, options, cfg, extmap):
TargetProject.__init__(self, name, options, cfg, extmap)
self.lang = options.get('lang')
class TargetJava(TargetLib):
def __init__(self, name, options, cfg, extmap):
TargetLib.__init__(self, name, options, cfg, extmap)
self.link_cmd = options.get('link-cmd')
self.packages = string.split(options.get('package-roots', ''))
self.jar = options.get('jar')
self.deps = [ ]
del self.filename
class TargetJavaHeaders(TargetJava):
def __init__(self, name, options, cfg, extmap):
TargetJava.__init__(self, name, options, cfg, extmap)
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, graph, cfg, extmap):
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
graph.add(DT_OBJECT, hfile, class_file)
self.deps.append(hfile)
# target (a linked item) depends upon object
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?"
graph.add(DT_LIST, LT_TARGET_DIRS, self.path)
graph.add(DT_LIST, LT_TARGET_DIRS, self.classes)
graph.add(DT_LIST, LT_TARGET_DIRS, self.headers)
for pattern in string.split(self.sources):
dirname = build_path_dirname(pattern)
if dirname:
graph.add(DT_LIST, LT_TARGET_DIRS,
build_path_join(self.path, dirname))
graph.add(DT_INSTALL, self.name, self)
class TargetJavaClasses(TargetJava):
def __init__(self, name, options, cfg, extmap):
TargetJava.__init__(self, name, options, cfg, extmap)
self.objext = '.class'
self.lang = 'java'
self.classes = options.get('classes')
self.output_dir = self.classes
def add_dependencies(self, graph, cfg, extmap):
sources =_collect_paths(self.sources, self.path)
for src, reldir in sources:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -