diff options
author | Richard Purdie <richard@openedhand.com> | 2005-08-31 10:47:56 +0000 |
---|---|---|
committer | Richard Purdie <richard@openedhand.com> | 2005-08-31 10:47:56 +0000 |
commit | f54da734eb7b69e8e34de505bd89a13479e230e0 (patch) | |
tree | f796bea6f5683dfe3d591ca5390d12fd78e59c96 /bitbake/lib/bb/parse/__init__.py | |
parent | 4b46c1f6e891b1ddd5968536440b888661fade3e (diff) | |
download | poky-f54da734eb7b69e8e34de505bd89a13479e230e0.tar.gz |
Initial population
git-svn-id: https://svn.o-hand.com/repos/poky@2 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'bitbake/lib/bb/parse/__init__.py')
-rw-r--r-- | bitbake/lib/bb/parse/__init__.py | 70 |
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 | """ | ||
2 | BitBake Parsers | ||
3 | |||
4 | File parsers for the BitBake build tools. | ||
5 | |||
6 | Copyright (C) 2003, 2004 Chris Larson | ||
7 | Copyright (C) 2003, 2004 Phil Blundell | ||
8 | |||
9 | This program is free software; you can redistribute it and/or modify it under | ||
10 | the terms of the GNU General Public License as published by the Free Software | ||
11 | Foundation; either version 2 of the License, or (at your option) any later | ||
12 | version. | ||
13 | |||
14 | This program is distributed in the hope that it will be useful, but WITHOUT | ||
15 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
16 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
17 | |||
18 | You should have received a copy of the GNU General Public License along with | ||
19 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple | ||
20 | Place, Suite 330, Boston, MA 02111-1307 USA. | ||
21 | |||
22 | Based 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' ] | ||
27 | handlers = [] | ||
28 | |||
29 | class ParseError(Exception): | ||
30 | """Exception raised when parsing fails""" | ||
31 | |||
32 | class SkipPackage(Exception): | ||
33 | """Exception raised to skip this package""" | ||
34 | |||
35 | __mtime_cache = {} | ||
36 | def 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 | |||
42 | def 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 | |||
50 | def 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 | |||
57 | def 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 | |||
64 | def init(fn, data): | ||
65 | for h in handlers: | ||
66 | if h['supports'](fn): | ||
67 | return h['init'](data) | ||
68 | |||
69 | |||
70 | from parse_py import __version__, ConfHandler, BBHandler | ||