def __recordDeps(mod): import dependencies modfile = '/%s.py' % mod for path in sys.path: if os.path.isfile(path+modfile): dependencies.addDependency(vars['INPUT_FILE'], config.format, path+modfile) return
def __findWriter(writer): found = 0 for p in config.searchPath: template = os.path.join(p, writer) if os.path.isfile(template): found = 1 rulesdir = p if config.track_deps: dependencies.addDependency(mk.vars['INPUT_FILE'], config.format, os.path.abspath(template)) break if not found: raise errors.Error("can't find output writer '%s'" % writer) return (rulesdir, template)
def __findWriter(writer): found = 0 for p in config.searchPath: template = os.path.join(p, writer) if os.path.isfile(template): found = 1 rulesdir = p if config.track_deps: dependencies.addDependency( mk.vars['INPUT_FILE'], config.format, os.path.abspath(template)) break if not found: raise errors.Error("can't find output writer '%s'" % writer) return (rulesdir, template)
def handleFragment(e, target=None, add_dict=None): if e.props['format'] == config.format: if 'file' in e.props: filename = os.path.join(os.path.dirname(e.filename), e.props['file']) f = open(filename) content = f.read() f.close() if config.track_deps: dependencies.addDependency(mk.vars['INPUT_FILE'], config.format, os.path.abspath(filename)) else: content = e.value if 'location' in e.props: loc = evalConstExpr(e, e.props['location'], target, add_dict) else: loc = None mk.addFragment(mk.Fragment(content, loc))
def processFile(filename, onlyOnce=False): if not os.path.isfile(filename): raise ReaderError(None, "file '%s' doesn't exist" % filename) filename = os.path.abspath(filename) if onlyOnce and filename in includedFiles: if config.verbose: print "file %s already included, skipping..." % filename return includedFiles.append(filename) if config.verbose: print 'loading %s...' % filename if config.track_deps: dependencies.addDependency(mk.vars['INPUT_FILE'], config.format, filename) newdir = os.path.dirname(filename) if newdir not in sys.path: sys.path.append(newdir) __doProcess(file=filename)