Alien-SVN
view release on metacpan or search on metacpan
src/subversion/build/generator/gen_base.py view on Meta::CPAN
lib_filename = '_' + module_name.capitalize() + lib_extension
else:
lib_extension = self.gen_obj._extension_map['pyd', 'target']
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(self.path, cname), self.lang,
self.gen_obj.release_mode)
ofile = SWIGObject(build_path_join(self.path, oname), self.lang,
self.gen_obj.release_mode)
# 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 list(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 = options.get('package-roots', '').split()
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,
self.package.replace(".", "_")
+ "_" + class_name + '.h')
class_pkg_list = self.package.split('.')
class_pkg = build_path_join(*class_pkg_list)
class_file = ObjectFile(build_path_join(self.classes, class_pkg,
class_name + self.objext),
self.when)
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
src/subversion/build/generator/gen_base.py view on Meta::CPAN
class IncludeDependencyInfo:
"""Finds all dependencies between a named set of headers, and computes
closure, so that individual C and SWIG source files can then be scanned, and
the stored dependency data used to return all directly and indirectly
referenced headers.
Note that where SWIG is concerned, there are two different kinds of include:
(1) those that include files in SWIG processing, and so matter to the
generation of .c files. (These are %include, %import).
(2) those that include references to C headers in the generated output,
and so are not required at .c generation, only at .o generation.
(These are %{ #include ... %}).
This class works exclusively in native-style paths."""
def __init__(self, filenames, fnames_nonexist):
"""Operation of an IncludeDependencyInfo instance is restricted to a
'domain' - a set of header files which are considered interesting when
following and reporting dependencies. This is done to avoid creating any
dependencies on system header files. The domain is defined by three
factors:
(1) FILENAMES is a list of headers which are in the domain, and should be
scanned to discover how they inter-relate.
(2) FNAMES_NONEXIST is a list of headers which are in the domain, but will
be created by the build process, and so are not available to be
scanned - they will be assumed not to depend on any other interesting
headers.
(3) Files in subversion/bindings/swig/proxy/, which are based
autogenerated based on files in subversion/include/, will be added to
the domain when a file in subversion/include/ is processed, and
dependencies will be deduced by special-case logic.
"""
# This defines the domain (i.e. set of files) in which dependencies are
# being located. Its structure is:
# { 'basename.h': [ 'path/to/something/named/basename.h',
# 'path/to/another/named/basename.h', ] }
self._domain = {}
for fname in filenames + fnames_nonexist:
bname = os.path.basename(fname)
self._domain.setdefault(bname, []).append(fname)
if _is_public_include(fname):
swig_fname = _swig_include_wrapper(fname)
swig_bname = os.path.basename(swig_fname)
self._domain.setdefault(swig_bname, []).append(swig_fname)
# This data structure is:
# { 'full/path/to/header.h': { 'full/path/to/dependency.h': TYPECODE, } }
# TYPECODE is '#', denoting a C include, or '%' denoting a SWIG include.
self._deps = {}
for fname in filenames:
self._deps[fname] = self._scan_for_includes(fname)
if _is_public_include(fname):
hdrs = { self._domain["proxy.swg"][0]: '%',
self._domain["apr.swg"][0]: '%',
fname: '%' }
for h in self._deps[fname].keys():
if (_is_public_include(h)
or h == os.path.join('subversion', 'include', 'private',
'svn_debug.h')):
hdrs[_swig_include_wrapper(h)] = '%'
else:
raise RuntimeError("Public include '%s' depends on '%s', " \
"which is not a public include! What's going on?" % (fname, h))
swig_fname = _swig_include_wrapper(fname)
swig_bname = os.path.basename(swig_fname)
self._deps[swig_fname] = hdrs
for fname in fnames_nonexist:
self._deps[fname] = {}
# Keep recomputing closures until we see no more changes
while True:
changes = 0
for fname in self._deps.keys():
changes = self._include_closure(self._deps[fname]) or changes
if not changes:
break
def query_swig(self, fname):
"""Scan the C or SWIG file FNAME, and return the full paths of each
include file that is a direct or indirect dependency, as a 2-tuple:
(C_INCLUDES, SWIG_INCLUDES)."""
if fname in self._deps:
hdrs = self._deps[fname]
else:
hdrs = self._scan_for_includes(fname)
self._include_closure(hdrs)
c_filenames = []
swig_filenames = []
for hdr, hdr_type in hdrs.items():
if hdr_type == '#':
c_filenames.append(hdr)
else: # hdr_type == '%'
swig_filenames.append(hdr)
# Be independent of hash ordering
c_filenames.sort()
swig_filenames.sort()
return (c_filenames, swig_filenames)
def query(self, fname):
"""Same as SELF.QUERY_SWIG(FNAME), but assert that there are no SWIG
includes, and return only C includes as a single list."""
c_includes, swig_includes = self.query_swig(fname)
assert len(swig_includes) == 0
return c_includes
def _include_closure(self, hdrs):
"""Mutate the passed dictionary HDRS, by performing a single pass
through the listed headers, adding the headers on which the first group
of headers depend, if not already present.
HDRS is of the form { 'path/to/header.h': TYPECODE, }
Return a boolean indicating whether any changes were made."""
items = list(hdrs.items())
for this_hdr, this_type in items:
for dependency_hdr, dependency_type in self._deps[this_hdr].items():
self._upd_dep_hash(hdrs, dependency_hdr, dependency_type)
return (len(items) != len(hdrs))
( run in 0.561 second using v1.01-cache-2.11-cpan-02777c243ea )