📄 gen_win.py
字号:
swig_options.append("-noruntime")
else:
swig_options.append("-c")
if target.lang == "java":
swig_options.append("-package org.tigris.subversion.swig")
swig_options.append("-outdir " + self.path("subversion/bindings/swig"
"/java/org/tigris"
"/subversion/swig"))
elif target.lang == "perl":
if self.swig_vernum >= 103020:
swig_options.append("-noproxy")
swig_options.append("-nopm")
objects = (("svn_delta_editor_t", "svn_delta.h", "delta_editor.hi"),
("svn_ra_plugin_t", "svn_ra.h", "ra_plugin.hi"),
("svn_ra_reporter_t", "svn_ra.h", "ra_reporter.hi"))
pfile = self.path("subversion/bindings/swig/perl/native/h2i.pl")
for objname, header, output in objects:
ifile = self.path("subversion/include", header)
ofile = self.path("subversion/bindings/swig", output)
obuild = "perl %s %s %s > %s" % (pfile, ifile, objname,
ofile)
sources.append(ProjectItem(path=ifile, reldir=None,
custom_build=obuild,
custom_target=ofile,
user_deps=()))
swig_deps.append(ofile)
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):
for cobj in self.graph.get_sources(gen_base.DT_OBJECT, obj):
if isinstance(cobj, gen_base.SWIGObject):
csrc = self.path(cobj.filename)
if self.swig_vernum < 103020 and target.lang == "python":
# workaround for a bug in the python module of old swigs.
# output path passed to swig has to use forward slashes,
# otherwise the generated python files (for shadow
# classes) will be saved to the wrong directory
cout = string.replace(csrc, '\\', '/')
else:
cout = csrc
# included header files that the generated c file depends on
user_deps = swig_deps[:]
for iobj in self.graph.get_sources(gen_base.DT_SWIG_C, cobj):
isrc = self.path(str(iobj))
if not isinstance(iobj, gen_base.SWIGSource):
user_deps.append(isrc)
continue
cbuild = "swig %s -o %s $(InputPath)" \
% (string.join(swig_options), cout)
sources.append(ProjectItem(path=isrc, reldir=None,
custom_build=cbuild,
custom_target=csrc,
user_deps=user_deps))
def_file = self.get_def_file(target)
if def_file is not None:
gsrc = self.path("build/generator/extractor.py")
deps = []
for header in target.msvc_export:
deps.append(self.path(target.path, header))
cbuild = "python $(InputPath) %s > %s" \
% (string.join(deps), def_file)
sources.append(ProjectItem(path=gsrc, reldir=None, custom_build=cbuild,
user_deps=deps, custom_target=def_file))
sources.append(ProjectItem(path=def_file, reldir=None,
custom_build=None, user_deps=[]))
sources.sort(lambda x, y: cmp(x.path, y.path))
return sources
def get_output_name(self, target):
if isinstance(target, gen_base.TargetExe):
return target.name + '.exe'
elif isinstance(target, gen_base.TargetJava):
return None
elif isinstance(target, gen_base.TargetApacheMod):
return target.name + '.so'
elif isinstance(target, gen_base.TargetLib):
if target.msvc_static:
return '%s-%d.lib' % (target.name, self.cfg.version)
else:
return os.path.basename(target.filename)
elif isinstance(target, gen_base.TargetProject):
### Since this target type doesn't produce any output, we shouldn't
### need to specify an output filename. But to keep the VC.NET template
### happy for now we have to return something
return target.name + '.exe'
elif isinstance(target, gen_base.TargetI18N):
return target.name
def get_output_dir(self, target):
if isinstance(target, gen_base.TargetJavaHeaders):
return msvc_path("../" + target.headers)
elif isinstance(target, gen_base.TargetJavaClasses):
return msvc_path("../" + target.classes)
else:
return msvc_path(target.path)
def get_intermediate_dir(self, target):
if isinstance(target, gen_base.TargetSWIG):
return msvc_path_join(msvc_path(target.path), target.name)
else:
return self.get_output_dir(target)
def get_def_file(self, target):
if isinstance(target, gen_base.TargetLib) and target.msvc_export:
return self.path(target.path, target.name + ".def")
return None
def gen_proj_names(self, install_targets):
"Generate project file names for the targets"
# Generate project file names for the targets: replace dashes with
# underscores and replace *-test with test_* (so that the test
# programs are visually separare from the rest of the projects)
for target in install_targets:
if target.msvc_name:
target.proj_name = target.msvc_name
continue
name = target.name
pos = string.find(name, '-test')
if pos >= 0:
proj_name = 'test_' + string.replace(name[:pos], '-', '_')
elif isinstance(target, gen_base.TargetSWIG):
proj_name = 'swig_' + string.replace(name, '-', '_')
else:
proj_name = string.replace(name, '-', '_')
target.proj_name = proj_name
def get_external_project(self, target, proj_ext):
if not ((isinstance(target, gen_base.TargetLinked)
or isinstance(target, gen_base.TargetI18N))
and target.external_project):
return None
if target.external_project[:10] == 'apr-iconv/':
path = self.apr_iconv_path + target.external_project[9:]
elif target.external_project[:9] == 'apr-util/':
path = self.apr_util_path + target.external_project[8:]
elif target.external_project[:4] == 'apr/':
path = self.apr_path + target.external_project[3:]
else:
path = target.external_project
return "%s.%s" % (gen_base.native_path(path), proj_ext)
def adjust_win_depends(self, target, name):
"Handle special dependencies if needed"
if name == '__CONFIG__':
depends = []
else:
depends = self.sections['__CONFIG__'].get_dep_targets(target)
depends.extend(self.get_win_depends(target, FILTER_PROJECTS))
return depends
def get_win_depends(self, target, mode):
"""Return the list of dependencies for target"""
dep_dict = {}
if isinstance(target, gen_base.TargetLib) and target.msvc_static:
self.get_static_win_depends(target, dep_dict)
else:
self.get_linked_win_depends(target, dep_dict)
deps = []
if mode == FILTER_PROJECTS:
for dep, (is_proj, is_lib, is_static) in dep_dict.items():
if is_proj:
deps.append(dep)
elif mode == FILTER_LIBS:
for dep, (is_proj, is_lib, is_static) in dep_dict.items():
if is_static or (is_lib and not is_proj):
deps.append(dep)
else:
raise NotImplementedError
deps.sort(lambda d1, d2: cmp(d1.name, d2.name))
return deps
def get_direct_depends(self, target):
"""Read target dependencies from graph
return value is list of (dependency, (is_project, is_lib, is_static)) tuples
"""
deps = []
for dep in self.graph.get_sources(gen_base.DT_LINK, target.name):
if not isinstance(dep, gen_base.Target):
continue
is_project = hasattr(dep, 'proj_name')
is_lib = isinstance(dep, gen_base.TargetLib)
is_static = is_lib and dep.msvc_static
deps.append((dep, (is_project, is_lib, is_static)))
for dep in self.graph.get_sources(gen_base.DT_NONLIB, target.name):
is_project = hasattr(dep, 'proj_name')
is_lib = isinstance(dep, gen_base.TargetLib)
is_static = is_lib and dep.msvc_static
deps.append((dep, (is_project, is_lib, is_static)))
return deps
def get_static_win_depends(self, target, deps):
"""Find project dependencies for a static library project"""
for dep, dep_kind in self.get_direct_depends(target):
is_proj, is_lib, is_static = dep_kind
# recurse for projectless targets
if not is_proj:
self.get_static_win_depends(dep, deps)
# Only add project dependencies on non-library projects. If we added
# project dependencies on libraries, MSVC would copy those libraries
# into the static archive. This would waste space and lead to linker
# warnings about multiply defined symbols. Instead, the library
# dependencies get added to any DLLs or EXEs that depend on this static
# library (see get_linked_win_depends() implementation).
if not is_lib:
deps[dep] = dep_kind
# a static library can depend on another library through a fake project
elif dep.msvc_fake:
deps[dep.msvc_fake] = dep_kind
def get_linked_win_depends(self, target, deps, static_recurse=0):
"""Find project dependencies for a DLL or EXE project"""
for dep, dep_kind in self.get_direct_depends(target):
is_proj, is_lib, is_static = dep_kind
# recurse for projectless dependencies
if not is_proj:
self.get_linked_win_depends(dep, deps, 0)
# also recurse into static library dependencies
elif is_static:
self.get_linked_win_depends(dep, deps, 1)
# add all top level dependencies and any libraries that
# static library dependencies depend on.
if not static_recurse or is_lib:
deps[dep] = dep_kind
def get_win_defines(self, target, cfg):
"Return the list of defines for target"
fakedefines = ["WIN32","_WINDOWS","alloca=_alloca",
"snprintf=_snprintf"]
if isinstance(target, gen_base.TargetApacheMod):
if target.name == 'mod_dav_svn':
fakedefines.extend(["AP_DECLARE_EXPORT"])
if isinstance(target, gen_base.TargetSWIG):
fakedefines.append("SWIG_GLOBAL")
fakedefines.append(self.swig_defines)
if target.lang == 'java':
fakedefines.append('SWIGJAVA')
if isinstance(target, gen_base.TargetSWIGLib):
fakedefines.append(self.swig_defines)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -