From owner-svn-src-projects@FreeBSD.ORG Sun Oct 13 00:19:32 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 334D33E0; Sun, 13 Oct 2013 00:19:32 +0000 (UTC) (envelope-from sjg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 217352800; Sun, 13 Oct 2013 00:19:32 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9D0JWnx062514; Sun, 13 Oct 2013 00:19:32 GMT (envelope-from sjg@svn.freebsd.org) Received: (from sjg@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9D0JVVD062513; Sun, 13 Oct 2013 00:19:31 GMT (envelope-from sjg@svn.freebsd.org) Message-Id: <201310130019.r9D0JVVD062513@svn.freebsd.org> From: "Simon J. Gerraty" Date: Sun, 13 Oct 2013 00:19:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r256416 - projects/bmake/share/mk X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Oct 2013 00:19:32 -0000 Author: sjg Date: Sun Oct 13 00:19:31 2013 New Revision: 256416 URL: http://svnweb.freebsd.org/changeset/base/256416 Log: Latest version. Report better parse errors. Modified: projects/bmake/share/mk/meta2deps.py Modified: projects/bmake/share/mk/meta2deps.py ============================================================================== --- projects/bmake/share/mk/meta2deps.py Sun Oct 13 00:17:24 2013 (r256415) +++ projects/bmake/share/mk/meta2deps.py Sun Oct 13 00:19:31 2013 (r256416) @@ -35,7 +35,7 @@ We only pay attention to a subset of the """ RCSid: - $Id: meta2deps.py,v 1.12 2013/03/31 22:31:59 sjg Exp $ + $Id: meta2deps.py,v 1.15 2013/07/29 20:41:23 sjg Exp $ Copyright (c) 2011-2013, Juniper Networks, Inc. All rights reserved. @@ -77,7 +77,7 @@ def resolve(path, cwd, last_dir=None, de """ if path.endswith('/.'): path = path[0:-2] - if path[0] == '/': + if len(path) > 0 and path[0] == '/': return path if path == '.': return cwd @@ -107,10 +107,12 @@ def abspath(path, cwd, last_dir=None, de this gets called a lot, so we try to avoid calling realpath until we know we have something. """ - path = resolve(path, cwd, last_dir, debug, debug_out) - if path and (path.find('./') > 0 or - path.endswith('/..') or - os.path.islink(path)): + rpath = resolve(path, cwd, last_dir, debug, debug_out) + if rpath: + path = rpath + if (path.find('./') > 0 or + path.endswith('/..') or + os.path.islink(path)): return os.path.realpath(path) return path @@ -191,6 +193,7 @@ class MetaFile: self.curdir = getv(conf, 'CURDIR') self.reldir = getv(conf, 'RELDIR') self.dpdeps = getv(conf, 'DPDEPS') + self.line = 0 if not self.conf: # some of the steps below we want to do only once @@ -254,7 +257,7 @@ class MetaFile: self.cwd = os.getcwd() # make sure this is initialized if name: - self.parse() + self.try_parse() def reset(self): """reset state if we are being passed meta files from multiple directories.""" @@ -333,6 +336,15 @@ class MetaFile: return ddep + def try_parse(self, name=None, file=None): + """give file and line number causing exception""" + try: + self.parse(name, file) + except: + # give a useful clue + print >> sys.stderr, '{}:{}: '.format(self.name, self.line), + raise + def parse(self, name=None, file=None): """A meta file looks like: @@ -373,11 +385,13 @@ class MetaFile: pid_last_dir = {} last_pid = 0 + self.line = 0 if self.curdir: self.seenit(self.curdir) # we ignore this interesting = 'CEFLRV' for line in f: + self.line += 1 # ignore anything we don't care about if not line[0] in interesting: continue @@ -634,7 +648,13 @@ def main(argv, klass=MetaFile, xopts='', print >> debug_out, "%s=%s" % (k,v) for a in args: - m = klass(a, conf) + if a.endswith('.meta'): + m = klass(a, conf) + elif a.startswith('@'): + # there can actually multiple files per line + for line in open(a[1:]): + for f in line.strip().split(): + m = klass(f, conf) if output: print m.dirdeps()