Lines Matching full:self

205     def __init__(self, name, conf={}):
246 self.name = name
247 self.debug = conf.get('debug', 0)
248 self.debug_out = conf.get('debug_out', sys.stderr)
250 self.machine = conf.get('MACHINE', '')
251 self.machine_arch = conf.get('MACHINE_ARCH', '')
252 self.target_spec = conf.get('TARGET_SPEC', self.machine)
253 self.exts = target_spec_exts(self.target_spec)
254 self.curdir = conf.get('CURDIR')
255 self.reldir = conf.get('RELDIR')
256 self.dpdeps = conf.get('DPDEPS')
257 self.pids = {}
258 self.line = 0
260 if not self.conf:
262 self.conf = conf
263 self.host_target = conf.get('HOST_TARGET')
267 if not srctop in self.srctops:
268 self.srctops.append(srctop)
272 if not _srctop in self.srctops:
273 self.srctops.append(_srctop)
275 trim_list = add_trims(self.machine)
276 if self.machine == 'host':
277 trim_list += add_trims(self.host_target)
278 if self.target_spec != self.machine:
279 trim_list += add_trims(self.target_spec)
289 if not objroot in self.objroots:
290 self.objroots.append(objroot)
294 if not _objroot in self.objroots:
295 self.objroots.append(_objroot)
298 self.srctops.sort(reverse=True)
299 self.objroots.sort(reverse=True)
301 self.excludes = conf.get('EXCLUDES', [])
303 if self.debug:
304 print("host_target=", self.host_target, file=self.debug_out)
305 print("srctops=", self.srctops, file=self.debug_out)
306 print("objroots=", self.objroots, file=self.debug_out)
307 print("excludes=", self.excludes, file=self.debug_out)
308 print("ext_list=", self.exts, file=self.debug_out)
310 self.dirdep_re = re.compile(r'([^/]+)/(.+)')
312 if self.dpdeps and not self.reldir:
313 if self.debug:
314 print("need reldir:", end=' ', file=self.debug_out)
315 if self.curdir:
316 srctop = self.find_top(self.curdir, self.srctops)
318 self.reldir = self.curdir.replace(srctop,'')
319 if self.debug:
320 print(self.reldir, file=self.debug_out)
321 if not self.reldir:
322 self.dpdeps = None # we cannot do it?
324 self.cwd = os.getcwd() # make sure this is initialized
325 self.last_dir = self.cwd
328 self.try_parse()
330 def reset(self):
332 self.seen = {}
333 self.obj_deps = []
334 self.src_deps = []
335 self.file_deps = []
337 def dirdeps(self, sep='\n'):
339 return sep.strip() + sep.join(self.obj_deps)
341 def src_dirdeps(self, sep='\n'):
343 return sep.strip() + sep.join(self.src_deps)
345 def file_depends(self, out=None):
348 if not self.reldir:
350 for f in sort_unique(self.file_deps):
351 print('DPDEPS_%s += %s' % (f, self.reldir), file=out)
353 for f in self.obj_deps:
354 print('DEPDIRS_%s += %s' % (f, self.reldir), file=out)
356 def seenit(self, dir):
358 self.seen[dir] = 1
360 def add(self, list, data, clue=''):
364 if self.debug:
365 print("%s: %sAdd: %s" % (self.name, clue, data), file=self.debug_out)
367 def find_top(self, path, list):
371 if self.debug > 2:
372 print("found in", top, file=self.debug_out)
376 def find_obj(self, objroot, dir, path, input):
382 if self.debug > 1:
383 print("found %s: %s\n" % (ddepf, ddep), file=self.debug_out)
384 for e in self.exts:
391 self.seenit(input)
392 self.seenit(dir)
393 if self.machine == 'none':
397 m = self.dirdep_re.match(dir.replace(objroot,''))
401 if dmachine != self.machine:
402 if not (self.machine == 'host' and
403 dmachine == self.host_target):
404 if self.debug > 2:
405 print("adding .%s to %s" % (dmachine, ddep), file=self.debug_out)
410 def try_parse(self, name=None, file=None):
413 self.parse(name, file)
416 print('{}:{}: '.format(self.name, self.line), end=' ', file=sys.stderr)
419 def parse(self, name=None, file=None):
448 self.name = name;
451 cwd = self.last_dir = self.cwd
453 f = open(self.name, 'r')
460 self.line = 0
461 if self.curdir:
462 self.seenit(self.curdir) # we ignore this
466 self.line += 1
470 if self.debug > 2:
471 print("input:", line, end=' ', file=self.debug_out)
485 self.cwd = cwd = self.last_dir = w[1]
486 self.seenit(cwd) # ignore this
487 if self.debug:
488 print("%s: CWD=%s" % (self.name, cwd), file=self.debug_out)
500 pid_last_dir[last_pid] = self.last_dir
501 cwd = pid_cwd.get(pid, self.cwd)
502 self.last_dir = pid_last_dir.get(pid, self.cwd)
513 cwd = abspath(w[2], cwd, None, self.debug, self.debug_out)
516 if self.debug > 1:
517 print("missing cwd=", cwd, file=self.debug_out)
520 self.last_dir = pid_last_dir[pid] = cwd
522 if self.debug > 1:
523 print("cwd=", cwd, file=self.debug_out)
528 del self.pids[pid]
533 if w[2] in self.seen:
534 if self.debug > 2:
535 print("seen:", w[2], file=self.debug_out)
541 self.parse_path(w[2].strip("'"), cwd, 'R', w)
542 self.parse_path(w[3].strip("'"), cwd, 'W', w)
547 self.pids[pid] = path
550 self.parse_path(path, cwd, w[0], w)
558 # self.pids should be empty!
559 for pid,path in self.pids.items():
572 del self.pids[pid]
573 assert(len(self.pids) == 0)
577 def is_src(self, base, dir, rdir):
583 srctop = self.find_top(path, self.srctops)
585 if self.dpdeps:
586 self.add(self.file_deps, path.replace(srctop,''), 'file')
587 self.add(self.src_deps, dir.replace(srctop,''), 'src')
588 self.seenit(dir)
592 def parse_path(self, path, cwd, op=None, w=[]):
601 for p in self.excludes:
603 if self.debug > 2:
604 print("exclude:", p, path, file=self.debug_out)
608 path = resolve(path, cwd, self.last_dir, self.debug, self.debug_out)
612 if dir in self.seen:
613 if self.debug > 2:
614 print("seen:", dir, file=self.debug_out)
619 dir = abspath(dir, cwd, self.last_dir, self.debug, self.debug_out)
628 if self.debug > 1:
629 print("raw=%s rdir=%s dir=%s path=%s" % (w[2], rdir, dir, path), file=self.debug_out)
631 if path in [self.last_dir, cwd, self.cwd, self.curdir]:
632 if self.debug > 1:
633 print("skipping:", path, file=self.debug_out)
637 self.last_dir = path;
638 if self.debug > 1:
639 print("ldir=", self.last_dir, file=self.debug_out)
644 if dir == self.cwd or dir == self.curdir:
646 if self.is_src(base, dir, rdir):
647 self.seenit(w[2])
655 objroot = self.find_top(dir, self.objroots)
659 ddep = self.find_obj(objroot, dir, path, w[2])
661 self.add(self.obj_deps, ddep, 'obj')
662 if self.dpdeps and objroot.endswith('/stage/'):
664 self.add(self.file_deps, sp, 'file')
667 self.seenit(w[2])
668 self.seenit(dir)