def make_ruleset(): ( targets, default_deps, default_commands ) = rules.match('DEFAULT') recurse_deps(default_deps) ( targets, top, commands ) = rules.match('TOP') recurse_deps(top) global missing if missing: raise SystemExit("Missing dependancies encountered, aborting.") targets = list(ruleset.keys()) ruleset['DEFAULT'] = Rule(('DEFAULT',), default_deps, default_commands) rruleset = dict([ (rule.targets,rule) for rule in list(ruleset.values()) ]) return ( rruleset, targets, srcfiles, autofiles )
def recurse_dep(dep): global autofiles global srcfiles global missing if dep in ruleset: return None if dep in srcfiles or dep in autofiles: return None debug("Looking for dependancy '%(dep)s'" % locals()) # Is the dependancy matched by a rule? rule = rules.match(dep) if rule: ( targets, deplist, commands ) = rule add_rule(targets, deplist, commands) debug("Found '%(dep)s' as rule %(targets)s => %(deplist)s" % locals()) return deplist # Is the dependancy an automatic file? if files.copy(dep): # If so, add it to the automatic files list. debug("Found '%(dep)s' as an automatic file" % locals()) autofiles.append(dep) return # Is the dependancy a source file? # If so, add it to the source files list. try: os.stat(dep) debug("Found '%(dep)s' as source" % locals()) srcfiles.append(dep) return except OSError: print("Missing dependancy: '%s'" % dep) missing.append(dep)
def scan_cpp(filename, already=None): if not already: already = {} if filename in already: return if files.copy(filename) or rules.match(filename): return [filename] already[filename] = None path = os.path.split(filename)[0] file = read(filename) if file is None: raise IOError deps = [filename] match = rx_include.search(file) build_incpaths = files.readlines("build-includes") or [] incpaths = ["", path] + build_incpaths while match: inctype, inc = match.groups() incs = [] if inctype == "<" else [inc] for incpath in incpaths: try: incs = scan_cpp(os.path.join(incpath, inc), already) except IOError: continue if incs is not None: break deps.extend(incs or []) match = rx_include.search(file, match.end()) return deps