Lines Matching +full:self +full:-
26 'W' files opened for write or read-write,
39 SPDX-License-Identifier: BSD-2-Clause
44 Copyright (c) 2011-2020, Simon J. Gerraty
45 Copyright (c) 2011-2017, Juniper Networks, Inc.
83 path = path[0:-2]
88 print("skipping non-existent:", path, file=debug_out)
103 p = '/'.join(dw[:-1])
188 n -= 1
205 def __init__(self, name, conf={}): argument
216 set to 'none' if we are not cross-building.
227 end in '/' or '-'.
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')
265 if srctop[-1] != '/':
267 if not srctop in self.srctops:
268 self.srctops.append(srctop)
270 if _srctop[-1] != '/':
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)
284 # this is not what we want - fix it
285 objroot = objroot[0:-len(e)]
287 if objroot[-1] != '/':
289 if not objroot in self.objroots:
290 self.objroots.append(objroot)
292 if objroot[-1] == '/':
294 if not _objroot in self.objroots:
295 self.objroots.append(_objroot)
297 self.sb = conf.get('SB', '')
299 self.srctops.sort(reverse=True)
300 self.objroots.sort(reverse=True)
302 self.excludes = conf.get('EXCLUDES', [])
304 if self.debug:
305 print("host_target=", self.host_target, file=self.debug_out)
306 print("srctops=", self.srctops, file=self.debug_out)
307 print("objroots=", self.objroots, file=self.debug_out)
308 print("excludes=", self.excludes, file=self.debug_out)
309 print("ext_list=", self.exts, file=self.debug_out)
311 self.dirdep_re = re.compile(r'([^/]+)/(.+)')
313 if self.dpdeps and not self.reldir:
314 if self.debug:
315 print("need reldir:", end=' ', file=self.debug_out)
316 if self.curdir:
317 srctop = self.find_top(self.curdir, self.srctops)
319 self.reldir = self.curdir.replace(srctop,'')
320 if self.debug:
321 print(self.reldir, file=self.debug_out)
322 if not self.reldir:
323 self.dpdeps = None # we cannot do it?
325 self.cwd = os.getcwd() # make sure this is initialized
326 self.last_dir = self.cwd
329 self.try_parse()
331 def reset(self): argument
333 self.seen = {}
334 self.obj_deps = []
335 self.src_deps = []
336 self.file_deps = []
338 def dirdeps(self, sep='\n'): argument
340 return sep.strip() + sep.join(self.obj_deps)
342 def src_dirdeps(self, sep='\n'): argument
344 return sep.strip() + sep.join(self.src_deps)
346 def file_depends(self, out=None): argument
349 if not self.reldir:
351 for f in sort_unique(self.file_deps):
352 print('DPDEPS_%s += %s' % (f, self.reldir), file=out)
354 for f in self.obj_deps:
355 print('DEPDIRS_%s += %s' % (f, self.reldir), file=out)
357 def seenit(self, dir): argument
359 self.seen[dir] = 1
361 def add(self, list, data, clue=''): argument
365 if self.debug:
366 print("%s: %sAdd: %s" % (self.name, clue, data), file=self.debug_out)
368 def find_top(self, path, list): argument
372 if self.debug > 2:
373 print("found in", top, file=self.debug_out)
377 def find_obj(self, objroot, dir, path, input): argument
383 if self.debug > 1:
384 print("found %s: %s\n" % (ddepf, ddep), file=self.debug_out)
385 for e in self.exts:
387 ddep = ddep[0:-len(e)]
392 self.seenit(input)
393 self.seenit(dir)
394 if self.machine == 'none':
398 m = self.dirdep_re.match(dir.replace(objroot,''))
402 if dmachine != self.machine:
403 if not (self.machine == 'host' and
404 dmachine == self.host_target):
405 if self.debug > 2:
406 print("adding .%s to %s" % (dmachine, ddep), file=self.debug_out)
411 def try_parse(self, name=None, file=None): argument
414 self.parse(name, file)
417 print('{}:{}: '.format(self.name, self.line), end=' ', file=sys.stderr)
420 def parse(self, name=None, file=None): argument
424 CMD "command-line"
427 -- command output --
428 -- filemon acquired metadata --
449 self.name = name;
452 cwd = self.last_dir = self.cwd
454 f = open(self.name, 'r')
461 self.line = 0
462 if self.curdir:
463 self.seenit(self.curdir) # we ignore this
465 if self.sb and self.name.startswith(self.sb):
466 error_name = self.name.replace(self.sb+'/','')
468 error_name = self.name
471 self.line += 1
475 if self.debug > 2:
476 print("input:", line, end=' ', file=self.debug_out)
490 self.cwd = cwd = self.last_dir = w[1]
491 self.seenit(cwd) # ignore this
492 if self.debug:
493 print("%s: CWD=%s" % (self.name, cwd), file=self.debug_out)
505 pid_last_dir[last_pid] = self.last_dir
506 cwd = pid_cwd.get(pid, self.cwd)
507 self.last_dir = pid_last_dir.get(pid, self.cwd)
518 cwd = abspath(w[2], cwd, None, self.debug, self.debug_out)
521 if self.debug > 1:
522 print("missing cwd=", cwd, file=self.debug_out)
524 cwd = cwd[0:-2]
525 self.last_dir = pid_last_dir[pid] = cwd
527 if self.debug > 1:
528 print("cwd=", cwd, file=self.debug_out)
533 del self.pids[pid]
538 if w[2] in self.seen:
539 if self.debug > 2:
540 print("seen:", w[2], file=self.debug_out)
546 self.parse_path(w[2].strip("'"), cwd, 'R', w)
547 self.parse_path(w[3].strip("'"), cwd, 'W', w)
552 self.pids[pid] = path
555 self.parse_path(path, cwd, w[0], w)
563 # self.pids should be empty!
564 for pid,path in self.pids.items():
577 del self.pids[pid]
578 if len(self.pids) > 0:
579 raise AssertionError('bad filemon data - missing eXits: {}'.format(error_name))
583 def is_src(self, base, dir, rdir): argument
589 srctop = self.find_top(path, self.srctops)
591 if self.dpdeps:
592 self.add(self.file_deps, path.replace(srctop,''), 'file')
593 self.add(self.src_deps, dir.replace(srctop,''), 'src')
594 self.seenit(dir)
598 def parse_path(self, path, cwd, op=None, w=[]): argument
607 for p in self.excludes:
609 if self.debug > 2:
610 print("exclude:", p, path, file=self.debug_out)
614 path = resolve(path, cwd, self.last_dir, self.debug, self.debug_out)
618 if dir in self.seen:
619 if self.debug > 2:
620 print("seen:", dir, file=self.debug_out)
625 dir = abspath(dir, cwd, self.last_dir, self.debug, self.debug_out)
634 if self.debug > 1:
635 print("raw=%s rdir=%s dir=%s path=%s" % (w[2], rdir, dir, path), file=self.debug_out)
637 if path in [self.last_dir, cwd, self.cwd, self.curdir]:
638 if self.debug > 1:
639 print("skipping:", path, file=self.debug_out)
643 self.last_dir = path;
644 if self.debug > 1:
645 print("ldir=", self.last_dir, file=self.debug_out)
650 if dir == self.cwd or dir == self.curdir:
652 if self.is_src(base, dir, rdir):
653 self.seenit(w[2])
661 objroot = self.find_top(dir, self.objroots)
665 ddep = self.find_obj(objroot, dir, path, w[2])
667 self.add(self.obj_deps, ddep, 'obj')
668 if self.dpdeps and objroot.endswith('/stage/'):
670 self.add(self.file_deps, sp, 'file')
673 self.seenit(w[2])
674 self.seenit(dir)
686 -S "SRCTOP"
689 -C "CURDIR"
691 -O "OBJROOT"
694 -m "MACHINE"
696 -a "MACHINE_ARCH"
698 -H "HOST_TARGET"
700 -D "DPDEPS"
702 -d bumps debug level
746 if o == '-a':
748 elif o == '-d':
750 elif o == '-q':
752 elif o == '-H':
754 elif o == '-S':
757 elif o == '-C':
759 elif o == '-O':
762 elif o == '-R':
764 elif o == '-D':
766 elif o == '-m':
768 elif o == '-T':
770 elif o == '-X':