2 # ex:ts=4:sw=4:sts=4:et
3 # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
7 File parsers for the BitBake build tools.
9 Copyright (C) 2003, 2004 Chris Larson
10 Copyright (C) 2003, 2004 Phil Blundell
12 This program is free software; you can redistribute it and/or modify it under
13 the terms of the GNU General Public License as published by the Free Software
14 Foundation; either version 2 of the License, or (at your option) any later
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23 Place, Suite 330, Boston, MA 02111-1307 USA.
25 Based on functions from the base bb module, Copyright 2003 Holger Schurig
29 __all__ = [ 'handlers', 'supports', 'handle', 'init', 'ConfHandler', 'BBHandler', 'ParseError' ]
32 class ParseError(Exception):
33 """Exception raised when parsing fails"""
35 class SkipPackage(Exception):
36 """Exception raised to skip this package"""
39 ConfHandler.ParseError = ParseError
41 BBHandler.ParseError = ParseError
47 if not __mtime_cache.has_key(f):
48 __mtime_cache[f] = os.stat(f)[8]
49 return __mtime_cache[f]
51 def mark_dependency(d, f):
53 if f.startswith('./'):
54 f = "%s/%s" % (os.getcwd(), f[2:])
55 deps = (bb.data.getVar('__depends', d) or "").split()
56 deps.append("%s@%s" % (f, cached_mtime(f)))
57 bb.data.setVar('__depends', " ".join(deps), d)
59 def supports(fn, data):
60 """Returns true if we have a handler for this file, false otherwise"""
62 if h['supports'](fn, data):
66 def handle(fn, data, include = 0):
67 """Call the handler that is appropriate for this file"""
69 if h['supports'](fn, data):
70 return h['handle'](fn, data, include)
76 return h['init'](data)