summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/parse/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/parse/__init__.py')
-rw-r--r--bitbake/lib/bb/parse/__init__.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/bitbake/lib/bb/parse/__init__.py b/bitbake/lib/bb/parse/__init__.py
new file mode 100644
index 0000000000..b8839c09fd
--- /dev/null
+++ b/bitbake/lib/bb/parse/__init__.py
@@ -0,0 +1,70 @@
1"""
2BitBake Parsers
3
4File parsers for the BitBake build tools.
5
6Copyright (C) 2003, 2004 Chris Larson
7Copyright (C) 2003, 2004 Phil Blundell
8
9This program is free software; you can redistribute it and/or modify it under
10the terms of the GNU General Public License as published by the Free Software
11Foundation; either version 2 of the License, or (at your option) any later
12version.
13
14This program is distributed in the hope that it will be useful, but WITHOUT
15ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License along with
19this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20Place, Suite 330, Boston, MA 02111-1307 USA.
21
22Based on functions from the base bb module, Copyright 2003 Holger Schurig
23"""
24
25__all__ = [ 'ParseError', 'SkipPackage', 'cached_mtime', 'mark_dependency',
26 'supports', 'handle', 'init' ]
27handlers = []
28
29class ParseError(Exception):
30 """Exception raised when parsing fails"""
31
32class SkipPackage(Exception):
33 """Exception raised to skip this package"""
34
35__mtime_cache = {}
36def cached_mtime(f):
37 import os
38 if not __mtime_cache.has_key(f):
39 __mtime_cache[f] = os.stat(f)[8]
40 return __mtime_cache[f]
41
42def mark_dependency(d, f):
43 import bb, os
44 if f.startswith('./'):
45 f = "%s/%s" % (os.getcwd(), f[2:])
46 deps = (bb.data.getVar('__depends', d) or "").split()
47 deps.append("%s@%s" % (f, cached_mtime(f)))
48 bb.data.setVar('__depends', " ".join(deps), d)
49
50def supports(fn, data):
51 """Returns true if we have a handler for this file, false otherwise"""
52 for h in handlers:
53 if h['supports'](fn, data):
54 return 1
55 return 0
56
57def handle(fn, data, include = 0):
58 """Call the handler that is appropriate for this file"""
59 for h in handlers:
60 if h['supports'](fn, data):
61 return h['handle'](fn, data, include)
62 raise ParseError("%s is not a BitBake file" % fn)
63
64def init(fn, data):
65 for h in handlers:
66 if h['supports'](fn):
67 return h['init'](data)
68
69
70from parse_py import __version__, ConfHandler, BBHandler