Lines Matching refs:self

198     def __init__(self, name, conf={}):  argument
239 self.name = name
240 self.debug = conf.get('debug', 0)
241 self.debug_out = conf.get('debug_out', sys.stderr)
243 self.machine = conf.get('MACHINE', '')
244 self.machine_arch = conf.get('MACHINE_ARCH', '')
245 self.target_spec = conf.get('TARGET_SPEC', self.machine)
246 self.exts = target_spec_exts(self.target_spec)
247 self.curdir = conf.get('CURDIR')
248 self.reldir = conf.get('RELDIR')
249 self.dpdeps = conf.get('DPDEPS')
250 self.pids = {}
251 self.line = 0
253 if not self.conf:
255 self.conf = conf
256 self.host_target = conf.get('HOST_TARGET')
260 if not srctop in self.srctops:
261 self.srctops.append(srctop)
265 if not _srctop in self.srctops:
266 self.srctops.append(_srctop)
268 trim_list = add_trims(self.machine)
269 if self.machine == 'host':
270 trim_list += add_trims(self.host_target)
271 if self.target_spec != self.machine:
272 trim_list += add_trims(self.target_spec)
282 if not objroot in self.objroots:
283 self.objroots.append(objroot)
287 if not _objroot in self.objroots:
288 self.objroots.append(_objroot)
291 self.srctops.sort(reverse=True)
292 self.objroots.sort(reverse=True)
294 self.excludes = conf.get('EXCLUDES', [])
296 if self.debug:
297 print("host_target=", self.host_target, file=self.debug_out)
298 print("srctops=", self.srctops, file=self.debug_out)
299 print("objroots=", self.objroots, file=self.debug_out)
300 print("excludes=", self.excludes, file=self.debug_out)
301 print("ext_list=", self.exts, file=self.debug_out)
303 self.dirdep_re = re.compile(r'([^/]+)/(.+)')
305 if self.dpdeps and not self.reldir:
306 if self.debug:
307 print("need reldir:", end=' ', file=self.debug_out)
308 if self.curdir:
309 srctop = self.find_top(self.curdir, self.srctops)
311 self.reldir = self.curdir.replace(srctop,'')
312 if self.debug:
313 print(self.reldir, file=self.debug_out)
314 if not self.reldir:
315 self.dpdeps = None # we cannot do it?
317 self.cwd = os.getcwd() # make sure this is initialized
318 self.last_dir = self.cwd
321 self.try_parse()
323 def reset(self): argument
325 self.seen = {}
326 self.obj_deps = []
327 self.src_deps = []
328 self.file_deps = []
330 def dirdeps(self, sep='\n'): argument
332 return sep.strip() + sep.join(self.obj_deps)
334 def src_dirdeps(self, sep='\n'): argument
336 return sep.strip() + sep.join(self.src_deps)
338 def file_depends(self, out=None): argument
341 if not self.reldir:
343 for f in sort_unique(self.file_deps):
344 print('DPDEPS_%s += %s' % (f, self.reldir), file=out)
346 for f in self.obj_deps:
347 print('DEPDIRS_%s += %s' % (f, self.reldir), file=out)
349 def seenit(self, dir): argument
351 self.seen[dir] = 1
353 def add(self, list, data, clue=''): argument
357 if self.debug:
358 print("%s: %sAdd: %s" % (self.name, clue, data), file=self.debug_out)
360 def find_top(self, path, list): argument
364 if self.debug > 2:
365 print("found in", top, file=self.debug_out)
369 def find_obj(self, objroot, dir, path, input): argument
375 if self.debug > 1:
376 print("found %s: %s\n" % (ddepf, ddep), file=self.debug_out)
377 for e in self.exts:
384 self.seenit(input)
385 self.seenit(dir)
386 if self.machine == 'none':
390 m = self.dirdep_re.match(dir.replace(objroot,''))
394 if dmachine != self.machine:
395 if not (self.machine == 'host' and
396 dmachine == self.host_target):
397 if self.debug > 2:
398 print("adding .%s to %s" % (dmachine, ddep), file=self.debug_out)
403 def try_parse(self, name=None, file=None): argument
406 self.parse(name, file)
409 print('{}:{}: '.format(self.name, self.line), end=' ', file=sys.stderr)
412 def parse(self, name=None, file=None): argument
441 self.name = name;
444 cwd = self.last_dir = self.cwd
446 f = open(self.name, 'r')
452 self.line = 0
453 if self.curdir:
454 self.seenit(self.curdir) # we ignore this
458 self.line += 1
462 if self.debug > 2:
463 print("input:", line, end=' ', file=self.debug_out)
477 self.cwd = cwd = self.last_dir = w[1]
478 self.seenit(cwd) # ignore this
479 if self.debug:
480 print("%s: CWD=%s" % (self.name, cwd), file=self.debug_out)
486 pid_last_dir[last_pid] = self.last_dir
487 cwd = pid_cwd.get(pid, self.cwd)
488 self.last_dir = pid_last_dir.get(pid, self.cwd)
499 cwd = abspath(w[2], cwd, None, self.debug, self.debug_out)
502 if self.debug > 1:
503 print("missing cwd=", cwd, file=self.debug_out)
506 self.last_dir = pid_last_dir[pid] = cwd
508 if self.debug > 1:
509 print("cwd=", cwd, file=self.debug_out)
514 del self.pids[pid]
519 if w[2] in self.seen:
520 if self.debug > 2:
521 print("seen:", w[2], file=self.debug_out)
527 self.parse_path(w[2].strip("'"), cwd, 'R', w)
528 self.parse_path(w[3].strip("'"), cwd, 'W', w)
533 self.pids[pid] = path
536 self.parse_path(path, cwd, w[0], w)
541 for pid,path in self.pids.items():
554 del self.pids[pid]
555 assert(len(self.pids) == 0)
559 def is_src(self, base, dir, rdir): argument
565 srctop = self.find_top(path, self.srctops)
567 if self.dpdeps:
568 self.add(self.file_deps, path.replace(srctop,''), 'file')
569 self.add(self.src_deps, dir.replace(srctop,''), 'src')
570 self.seenit(dir)
574 def parse_path(self, path, cwd, op=None, w=[]): argument
583 for p in self.excludes:
585 if self.debug > 2:
586 print("exclude:", p, path, file=self.debug_out)
590 path = resolve(path, cwd, self.last_dir, self.debug, self.debug_out)
594 if dir in self.seen:
595 if self.debug > 2:
596 print("seen:", dir, file=self.debug_out)
601 dir = abspath(dir, cwd, self.last_dir, self.debug, self.debug_out)
610 if self.debug > 1:
611 print("raw=%s rdir=%s dir=%s path=%s" % (w[2], rdir, dir, path), file=self.debug_out)
613 if path in [self.last_dir, cwd, self.cwd, self.curdir]:
614 if self.debug > 1:
615 print("skipping:", path, file=self.debug_out)
619 self.last_dir = path;
620 if self.debug > 1:
621 print("ldir=", self.last_dir, file=self.debug_out)
626 if dir == self.cwd or dir == self.curdir:
628 if self.is_src(base, dir, rdir):
629 self.seenit(w[2])
637 objroot = self.find_top(dir, self.objroots)
641 ddep = self.find_obj(objroot, dir, path, w[2])
643 self.add(self.obj_deps, ddep, 'obj')
644 if self.dpdeps and objroot.endswith('/stage/'):
646 self.add(self.file_deps, sp, 'file')
649 self.seenit(w[2])
650 self.seenit(dir)