Alien-SVN
view release on metacpan or search on metacpan
src/subversion/build/generator/gen_base.py view on Meta::CPAN
def compute_hdr_deps(self):
"""Compute the dependencies of each header file"""
include_deps = IncludeDependencyInfo(self.compute_hdrs(),
list(map(native_path, self.private_built_includes)))
for objectfile, sources in self.graph.get_deps(DT_OBJECT):
assert len(sources) == 1
source = sources[0]
# Generated .c files must depend on all headers their parent .i file
# includes
if isinstance(objectfile, SWIGObject):
swigsources = self.graph.get_sources(DT_SWIG_C, source)
assert len(swigsources) == 1
ifile = swigsources[0]
assert isinstance(ifile, SWIGSource)
c_includes, swig_includes = \
include_deps.query_swig(native_path(ifile.filename))
for include_file in c_includes:
self.graph.add(DT_OBJECT, objectfile, build_path(include_file))
for include_file in swig_includes:
self.graph.add(DT_SWIG_C, source, build_path(include_file))
# Any non-swig C/C++ object must depend on the headers its parent
# .c or .cpp includes. Note that 'object' includes gettext .mo files,
# Java .class files, and .h files generated from Java classes, so
# we must filter here.
elif isinstance(source, SourceFile) and \
os.path.splitext(source.filename)[1] in ('.c', '.cpp'):
for include_file in include_deps.query(native_path(source.filename)):
self.graph.add(DT_OBJECT, objectfile, build_path(include_file))
def write_sqlite_headers(self):
"Transform sql files into header files"
import transform_sql
for hdrfile, sqlfile in self.graph.get_deps(DT_SQLHDR):
new_hdrfile = hdrfile + ".new"
new_file = open(new_hdrfile, 'w')
transform_sql.main(sqlfile[0], new_file)
new_file.close()
def identical(file1, file2):
try:
if filecmp.cmp(new_hdrfile, hdrfile):
return True
else:
return False
except:
return False
if identical(new_hdrfile, hdrfile):
os.remove(new_hdrfile)
else:
try:
os.remove(hdrfile)
except: pass
os.rename(new_hdrfile, hdrfile)
class DependencyGraph:
"""Record dependencies between build items.
See the DT_* values for the different dependency types. For each type,
the target and source objects recorded will be different. They could
be file names, Target objects, install types, etc.
"""
def __init__(self):
self.deps = { } # type -> { target -> [ source ... ] }
for dt in dep_types:
self.deps[dt] = { }
def add(self, type, target, source):
if target in self.deps[type]:
self.deps[type][target].append(source)
else:
self.deps[type][target] = [ source ]
def bulk_add(self, type, target, sources):
if target in self.deps[type]:
self.deps[type][target].extend(sources)
else:
self.deps[type][target] = sources[:]
def get_sources(self, type, target, cls=None):
sources = self.deps[type].get(target, [ ])
if not cls:
return sources
filtered = [ ]
for src in sources:
if isinstance(src, cls):
filtered.append(src)
return filtered
def get_all_sources(self, type):
sources = [ ]
for group in self.deps[type].values():
sources.extend(group)
return sources
def get_deps(self, type):
return list(self.deps[type].items())
# dependency types
dep_types = [
'DT_INSTALL', # install areas. e.g. 'lib', 'base-lib'
'DT_OBJECT', # an object filename, depending upon .c filenames
'DT_SWIG_C', # a swig-generated .c file, depending upon .i filename(s)
'DT_LINK', # a libtool-linked filename, depending upon object fnames
'DT_NONLIB', # filename depends on object fnames, but isn't linked to them
'DT_SQLHDR', # header generated from a .sql file
]
# create some variables for these
for _dt in dep_types:
# e.g. DT_INSTALL = 'DT_INSTALL'
globals()[_dt] = _dt
( run in 3.925 seconds using v1.01-cache-2.11-cpan-d7f47b0818f )