diff options
Diffstat (limited to 'bitbake/lib/bb/parse/parse_py/ConfHandler.py')
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/ConfHandler.py | 58 |
1 files changed, 41 insertions, 17 deletions
diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py index f171c5c932..9ddbae123d 100644 --- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py +++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py | |||
@@ -20,10 +20,10 @@ from bb.parse import ParseError, resolve_file, ast, logger, handle | |||
20 | __config_regexp__ = re.compile( r""" | 20 | __config_regexp__ = re.compile( r""" |
21 | ^ | 21 | ^ |
22 | (?P<exp>export\s+)? | 22 | (?P<exp>export\s+)? |
23 | (?P<var>[a-zA-Z0-9\-_+.${}/~]+?) | 23 | (?P<var>[a-zA-Z0-9\-_+.${}/~:]*?) |
24 | (\[(?P<flag>[a-zA-Z0-9\-_+.]+)\])? | 24 | (\[(?P<flag>[a-zA-Z0-9\-_+.][a-zA-Z0-9\-_+.@/]*)\])? |
25 | 25 | ||
26 | \s* ( | 26 | (?P<whitespace>\s*) ( |
27 | (?P<colon>:=) | | 27 | (?P<colon>:=) | |
28 | (?P<lazyques>\?\?=) | | 28 | (?P<lazyques>\?\?=) | |
29 | (?P<ques>\?=) | | 29 | (?P<ques>\?=) | |
@@ -32,7 +32,7 @@ __config_regexp__ = re.compile( r""" | |||
32 | (?P<predot>=\.) | | 32 | (?P<predot>=\.) | |
33 | (?P<postdot>\.=) | | 33 | (?P<postdot>\.=) | |
34 | = | 34 | = |
35 | ) \s* | 35 | ) (?P<whitespace2>\s*) |
36 | 36 | ||
37 | (?!'[^']*'[^']*'$) | 37 | (?!'[^']*'[^']*'$) |
38 | (?!\"[^\"]*\"[^\"]*\"$) | 38 | (?!\"[^\"]*\"[^\"]*\"$) |
@@ -43,15 +43,15 @@ __config_regexp__ = re.compile( r""" | |||
43 | """, re.X) | 43 | """, re.X) |
44 | __include_regexp__ = re.compile( r"include\s+(.+)" ) | 44 | __include_regexp__ = re.compile( r"include\s+(.+)" ) |
45 | __require_regexp__ = re.compile( r"require\s+(.+)" ) | 45 | __require_regexp__ = re.compile( r"require\s+(.+)" ) |
46 | __includeall_regexp__ = re.compile( r"include_all\s+(.+)" ) | ||
46 | __export_regexp__ = re.compile( r"export\s+([a-zA-Z0-9\-_+.${}/~]+)$" ) | 47 | __export_regexp__ = re.compile( r"export\s+([a-zA-Z0-9\-_+.${}/~]+)$" ) |
47 | __unset_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/~]+)$" ) | 48 | __unset_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/~]+)$" ) |
48 | __unset_flag_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/~]+)\[([a-zA-Z0-9\-_+.]+)\]$" ) | 49 | __unset_flag_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/~]+)\[([a-zA-Z0-9\-_+.][a-zA-Z0-9\-_+.@]+)\]$" ) |
50 | __addpylib_regexp__ = re.compile(r"addpylib\s+(.+)\s+(.+)" ) | ||
51 | __addfragments_regexp__ = re.compile(r"addfragments\s+(.+)\s+(.+)\s+(.+)\s+(.+)" ) | ||
49 | 52 | ||
50 | def init(data): | 53 | def init(data): |
51 | topdir = data.getVar('TOPDIR', False) | 54 | return |
52 | if not topdir: | ||
53 | data.setVar('TOPDIR', os.getcwd()) | ||
54 | |||
55 | 55 | ||
56 | def supports(fn, d): | 56 | def supports(fn, d): |
57 | return fn[-5:] == ".conf" | 57 | return fn[-5:] == ".conf" |
@@ -105,12 +105,12 @@ def include_single_file(parentfn, fn, lineno, data, error_out): | |||
105 | # We have an issue where a UI might want to enforce particular settings such as | 105 | # We have an issue where a UI might want to enforce particular settings such as |
106 | # an empty DISTRO variable. If configuration files do something like assigning | 106 | # an empty DISTRO variable. If configuration files do something like assigning |
107 | # a weak default, it turns out to be very difficult to filter out these changes, | 107 | # a weak default, it turns out to be very difficult to filter out these changes, |
108 | # particularly when the weak default might appear half way though parsing a chain | 108 | # particularly when the weak default might appear half way though parsing a chain |
109 | # of configuration files. We therefore let the UIs hook into configuration file | 109 | # of configuration files. We therefore let the UIs hook into configuration file |
110 | # parsing. This turns out to be a hard problem to solve any other way. | 110 | # parsing. This turns out to be a hard problem to solve any other way. |
111 | confFilters = [] | 111 | confFilters = [] |
112 | 112 | ||
113 | def handle(fn, data, include): | 113 | def handle(fn, data, include, baseconfig=False): |
114 | init(data) | 114 | init(data) |
115 | 115 | ||
116 | if include == 0: | 116 | if include == 0: |
@@ -128,21 +128,26 @@ def handle(fn, data, include): | |||
128 | s = f.readline() | 128 | s = f.readline() |
129 | if not s: | 129 | if not s: |
130 | break | 130 | break |
131 | origlineno = lineno | ||
132 | origline = s | ||
131 | w = s.strip() | 133 | w = s.strip() |
132 | # skip empty lines | 134 | # skip empty lines |
133 | if not w: | 135 | if not w: |
134 | continue | 136 | continue |
135 | s = s.rstrip() | 137 | s = s.rstrip() |
136 | while s[-1] == '\\': | 138 | while s[-1] == '\\': |
137 | s2 = f.readline().rstrip() | 139 | line = f.readline() |
140 | origline += line | ||
141 | s2 = line.rstrip() | ||
138 | lineno = lineno + 1 | 142 | lineno = lineno + 1 |
139 | if (not s2 or s2 and s2[0] != "#") and s[0] == "#" : | 143 | if (not s2 or s2 and s2[0] != "#") and s[0] == "#" : |
140 | bb.fatal("There is a confusing multiline, partially commented expression on line %s of file %s (%s).\nPlease clarify whether this is all a comment or should be parsed." % (lineno, fn, s)) | 144 | bb.fatal("There is a confusing multiline, partially commented expression starting on line %s of file %s:\n%s\nPlease clarify whether this is all a comment or should be parsed." % (origlineno, fn, origline)) |
145 | |||
141 | s = s[:-1] + s2 | 146 | s = s[:-1] + s2 |
142 | # skip comments | 147 | # skip comments |
143 | if s[0] == '#': | 148 | if s[0] == '#': |
144 | continue | 149 | continue |
145 | feeder(lineno, s, abs_fn, statements) | 150 | feeder(lineno, s, abs_fn, statements, baseconfig=baseconfig) |
146 | 151 | ||
147 | # DONE WITH PARSING... time to evaluate | 152 | # DONE WITH PARSING... time to evaluate |
148 | data.setVar('FILE', abs_fn) | 153 | data.setVar('FILE', abs_fn) |
@@ -150,17 +155,21 @@ def handle(fn, data, include): | |||
150 | if oldfile: | 155 | if oldfile: |
151 | data.setVar('FILE', oldfile) | 156 | data.setVar('FILE', oldfile) |
152 | 157 | ||
153 | f.close() | ||
154 | |||
155 | for f in confFilters: | 158 | for f in confFilters: |
156 | f(fn, data) | 159 | f(fn, data) |
157 | 160 | ||
158 | return data | 161 | return data |
159 | 162 | ||
160 | def feeder(lineno, s, fn, statements): | 163 | # baseconfig is set for the bblayers/layer.conf cookerdata config parsing |
164 | # The function is also used by BBHandler, conffile would be False | ||
165 | def feeder(lineno, s, fn, statements, baseconfig=False, conffile=True): | ||
161 | m = __config_regexp__.match(s) | 166 | m = __config_regexp__.match(s) |
162 | if m: | 167 | if m: |
163 | groupd = m.groupdict() | 168 | groupd = m.groupdict() |
169 | if groupd['var'] == "": | ||
170 | raise ParseError("Empty variable name in assignment: '%s'" % s, fn, lineno); | ||
171 | if not groupd['whitespace'] or not groupd['whitespace2']: | ||
172 | logger.warning("%s:%s has a lack of whitespace around the assignment: '%s'" % (fn, lineno, s)) | ||
164 | ast.handleData(statements, fn, lineno, groupd) | 173 | ast.handleData(statements, fn, lineno, groupd) |
165 | return | 174 | return |
166 | 175 | ||
@@ -174,6 +183,11 @@ def feeder(lineno, s, fn, statements): | |||
174 | ast.handleInclude(statements, fn, lineno, m, True) | 183 | ast.handleInclude(statements, fn, lineno, m, True) |
175 | return | 184 | return |
176 | 185 | ||
186 | m = __includeall_regexp__.match(s) | ||
187 | if m: | ||
188 | ast.handleIncludeAll(statements, fn, lineno, m) | ||
189 | return | ||
190 | |||
177 | m = __export_regexp__.match(s) | 191 | m = __export_regexp__.match(s) |
178 | if m: | 192 | if m: |
179 | ast.handleExport(statements, fn, lineno, m) | 193 | ast.handleExport(statements, fn, lineno, m) |
@@ -189,6 +203,16 @@ def feeder(lineno, s, fn, statements): | |||
189 | ast.handleUnsetFlag(statements, fn, lineno, m) | 203 | ast.handleUnsetFlag(statements, fn, lineno, m) |
190 | return | 204 | return |
191 | 205 | ||
206 | m = __addpylib_regexp__.match(s) | ||
207 | if baseconfig and conffile and m: | ||
208 | ast.handlePyLib(statements, fn, lineno, m) | ||
209 | return | ||
210 | |||
211 | m = __addfragments_regexp__.match(s) | ||
212 | if m: | ||
213 | ast.handleAddFragments(statements, fn, lineno, m) | ||
214 | return | ||
215 | |||
192 | raise ParseError("unparsed line: '%s'" % s, fn, lineno); | 216 | raise ParseError("unparsed line: '%s'" % s, fn, lineno); |
193 | 217 | ||
194 | # Add us to the handlers list | 218 | # Add us to the handlers list |