diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2006-03-21 21:40:36 +0000 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2006-03-21 21:40:36 +0000 |
commit | 1564778d579eddaa9deae78ed68153a0122f4391 (patch) | |
tree | 58439a7c7d75f0e8d0e066671b74580167a60405 | |
parent | 92e0454966f2ed91e79c03f8abf1e81280ccbc75 (diff) | |
download | bitbake-1564778d579eddaa9deae78ed68153a0122f4391.tar.gz |
parse/parse_c/BBHandler:
Implement some bits of the C parser. We will
do the easy things in python and then initialize
the lexer/parser.
-rw-r--r-- | lib/bb/parse/parse_c/BBHandler.py | 52 |
1 files changed, 47 insertions, 5 deletions
diff --git a/lib/bb/parse/parse_c/BBHandler.py b/lib/bb/parse/parse_c/BBHandler.py index 300871d9e..771a7a0d8 100644 --- a/lib/bb/parse/parse_c/BBHandler.py +++ b/lib/bb/parse/parse_c/BBHandler.py @@ -22,8 +22,10 @@ # THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -from bb import data +# The Module we will use here +from bb import data, parse from bb.parse import ParseError +import bb # # This is the Python Part of the Native Parser Implementation. @@ -39,7 +41,12 @@ from bb.parse import ParseError # # internal # - +def _init(fn, d): + """ + Initialize the data implementation with values of + the environment and data from the file. + """ + pass # # public @@ -48,15 +55,50 @@ def supports(fn, data): return fn[-3:] == ".bb" or fn[-8:] == ".bbclass" or fn[-4:] == ".inc" def init(fn, data): - print "Init" + if not bb.data.getVar('TOPDIR', data): + bb.error('TOPDIR is not set') + if not bb.data.getVar('BBPATH', data): + bb.error('BBPATH is not set') + -def handle(fn, data, include): +def handle(fn, d, include): print "" print "fn: %s" % fn print "data: %s" % data print "include: %s" % include - pass + # check if we include or are the beginning + if include: + oldfile = data.getVar('FILE', d) + else: + data.inheritFromOS(d) + oldfile = None + + # find the file + if not os.path.isabs(fn): + bb.error("No Absolute FILE name") + abs_fn = bb.which(data.getVar('BBPATH',d), fn) + else: + abs_fn = fn + + # check if the file exists + if not os.path.exists(abs_fn): + raise IOError("file '%(fn)' not found" % locals() ) + + fn = file(abs_fn, 'r') + + # now we know the file is around mark it as dep + if include: + parse.mark_dependency(d, abs_fn) + + # now parse this file - by defering it to C++ + + + # restore the original FILE + if oldfile: + data.setVar('FILE', oldfile, data) + + return data # Inform bitbake that we are a parser # We need to define all three |