summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/parse/parse_c/BBHandler.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/parse/parse_c/BBHandler.py')
-rw-r--r--bitbake/lib/bb/parse/parse_c/BBHandler.py116
1 files changed, 82 insertions, 34 deletions
diff --git a/bitbake/lib/bb/parse/parse_c/BBHandler.py b/bitbake/lib/bb/parse/parse_c/BBHandler.py
index 300871d9e3..d9f48db17b 100644
--- a/bitbake/lib/bb/parse/parse_c/BBHandler.py
+++ b/bitbake/lib/bb/parse/parse_c/BBHandler.py
@@ -1,29 +1,42 @@
1# ex:ts=4:sw=4:sts=4:et 1# ex:ts=4:sw=4:sts=4:et
2# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- 2# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
3# 3"""class for handling .bb files (using a C++ parser)
4# Copyright (C) 2006 Holger Hans Peter Freyther 4
5# 5 Reads a .bb file and obtains its metadata (using a C++ parser)
6# Permission is hereby granted, free of charge, to any person obtaining a copy 6
7# of this software and associated documentation files (the "Software"), to deal 7 Copyright (C) 2006 Tim Robert Ansell
8# in the Software without restriction, including without limitation the rights 8 Copyright (C) 2006 Holger Hans Peter Freyther
9# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9
10# copies of the Software, and to permit persons to whom the Software is 10 This program is free software; you can redistribute it and/or modify it under
11# furnished to do so, subject to the following conditions: 11 the terms of the GNU General Public License as published by the Free Software
12# 12 Foundation; either version 2 of the License, or (at your option) any later
13# The above copyright notice and this permission notice shall be included in all 13 version.
14# copies or substantial portions of the Software.
15#
16# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
19# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
22# THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23#
24 14
25from bb import data 15 Permission is hereby granted, free of charge, to any person obtaining a copy
26from bb.parse import ParseError 16 of this software and associated documentation files (the "Software"), to deal
17 in the Software without restriction, including without limitation the rights
18 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19 copies of the Software, and to permit persons to whom the Software is
20 furnished to do so, subject to the following conditions:
21
22 The above copyright notice and this permission notice shall be included in all
23 copies or substantial portions of the Software.
24
25 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
28 SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
29 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
30 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
31 THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32"""
33
34import os
35
36# The Module we will use here
37import bb
38
39from bitbakec import parsefile
27 40
28# 41#
29# This is the Python Part of the Native Parser Implementation. 42# This is the Python Part of the Native Parser Implementation.
@@ -34,29 +47,64 @@ from bb.parse import ParseError
34# 47#
35# The rest of the methods are internal implementation details. 48# The rest of the methods are internal implementation details.
36 49
37 50def _init(fn, d):
38 51 """
39# 52 Initialize the data implementation with values of
40# internal 53 the environment and data from the file.
41# 54 """
42 55 pass
43 56
44# 57#
45# public 58# public
46# 59#
47def supports(fn, data): 60def supports(fn, data):
48 return fn[-3:] == ".bb" or fn[-8:] == ".bbclass" or fn[-4:] == ".inc" 61 return fn[-3:] == ".bb" or fn[-8:] == ".bbclass" or fn[-4:] == ".inc" or fn[-5:] == ".conf"
49 62
50def init(fn, data): 63def init(fn, data):
51 print "Init" 64 if not data.getVar('TOPDIR'):
65 bb.error('TOPDIR is not set')
66 if not data.getVar('BBPATH'):
67 bb.error('BBPATH is not set')
68
52 69
53def handle(fn, data, include): 70def handle(fn, d, include):
54 print "" 71 print ""
55 print "fn: %s" % fn 72 print "fn: %s" % fn
56 print "data: %s" % data 73 print "data: %s" % d
74 print dir(d)
75 print d.getVar.__doc__
57 print "include: %s" % include 76 print "include: %s" % include
58 77
59 pass 78 # check if we include or are the beginning
79 if include:
80 oldfile = d.getVar('FILE')
81 else:
82 #d.inheritFromOS()
83 oldfile = None
84
85 # find the file
86 if not os.path.isabs(fn):
87 bb.error("No Absolute FILE name")
88 abs_fn = bb.which(d.getVar('BBPATH'), fn)
89 else:
90 abs_fn = fn
91
92 # check if the file exists
93 if not os.path.exists(abs_fn):
94 raise IOError("file '%(fn)' not found" % locals() )
95
96 # now we know the file is around mark it as dep
97 if include:
98 parse.mark_dependency(d, abs_fn)
99
100 # now parse this file - by defering it to C++
101 parsefile(fn, d)
102
103 # restore the original FILE
104 if oldfile:
105 d.setVar('FILE', oldfile)
106
107 return d
60 108
61# Inform bitbake that we are a parser 109# Inform bitbake that we are a parser
62# We need to define all three 110# We need to define all three