diff options
Diffstat (limited to 'bitbake/lib/bb/parse/parse_py/ConfHandler.py')
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/ConfHandler.py | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py index f171c5c932..7826dee7d3 100644 --- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py +++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py | |||
@@ -20,8 +20,8 @@ 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 | \s* ( |
27 | (?P<colon>:=) | | 27 | (?P<colon>:=) | |
@@ -45,13 +45,11 @@ __include_regexp__ = re.compile( r"include\s+(.+)" ) | |||
45 | __require_regexp__ = re.compile( r"require\s+(.+)" ) | 45 | __require_regexp__ = re.compile( r"require\s+(.+)" ) |
46 | __export_regexp__ = re.compile( r"export\s+([a-zA-Z0-9\-_+.${}/~]+)$" ) | 46 | __export_regexp__ = re.compile( r"export\s+([a-zA-Z0-9\-_+.${}/~]+)$" ) |
47 | __unset_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/~]+)$" ) | 47 | __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\-_+.]+)\]$" ) | 48 | __unset_flag_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/~]+)\[([a-zA-Z0-9\-_+.][a-zA-Z0-9\-_+.@]+)\]$" ) |
49 | __addpylib_regexp__ = re.compile(r"addpylib\s+(.+)\s+(.+)" ) | ||
49 | 50 | ||
50 | def init(data): | 51 | def init(data): |
51 | topdir = data.getVar('TOPDIR', False) | 52 | return |
52 | if not topdir: | ||
53 | data.setVar('TOPDIR', os.getcwd()) | ||
54 | |||
55 | 53 | ||
56 | def supports(fn, d): | 54 | def supports(fn, d): |
57 | return fn[-5:] == ".conf" | 55 | return fn[-5:] == ".conf" |
@@ -105,12 +103,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 | 103 | # 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 | 104 | # 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, | 105 | # 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 | 106 | # 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 | 107 | # 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. | 108 | # parsing. This turns out to be a hard problem to solve any other way. |
111 | confFilters = [] | 109 | confFilters = [] |
112 | 110 | ||
113 | def handle(fn, data, include): | 111 | def handle(fn, data, include, baseconfig=False): |
114 | init(data) | 112 | init(data) |
115 | 113 | ||
116 | if include == 0: | 114 | if include == 0: |
@@ -128,21 +126,26 @@ def handle(fn, data, include): | |||
128 | s = f.readline() | 126 | s = f.readline() |
129 | if not s: | 127 | if not s: |
130 | break | 128 | break |
129 | origlineno = lineno | ||
130 | origline = s | ||
131 | w = s.strip() | 131 | w = s.strip() |
132 | # skip empty lines | 132 | # skip empty lines |
133 | if not w: | 133 | if not w: |
134 | continue | 134 | continue |
135 | s = s.rstrip() | 135 | s = s.rstrip() |
136 | while s[-1] == '\\': | 136 | while s[-1] == '\\': |
137 | s2 = f.readline().rstrip() | 137 | line = f.readline() |
138 | origline += line | ||
139 | s2 = line.rstrip() | ||
138 | lineno = lineno + 1 | 140 | lineno = lineno + 1 |
139 | if (not s2 or s2 and s2[0] != "#") and s[0] == "#" : | 141 | 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)) | 142 | 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)) |
143 | |||
141 | s = s[:-1] + s2 | 144 | s = s[:-1] + s2 |
142 | # skip comments | 145 | # skip comments |
143 | if s[0] == '#': | 146 | if s[0] == '#': |
144 | continue | 147 | continue |
145 | feeder(lineno, s, abs_fn, statements) | 148 | feeder(lineno, s, abs_fn, statements, baseconfig=baseconfig) |
146 | 149 | ||
147 | # DONE WITH PARSING... time to evaluate | 150 | # DONE WITH PARSING... time to evaluate |
148 | data.setVar('FILE', abs_fn) | 151 | data.setVar('FILE', abs_fn) |
@@ -150,14 +153,14 @@ def handle(fn, data, include): | |||
150 | if oldfile: | 153 | if oldfile: |
151 | data.setVar('FILE', oldfile) | 154 | data.setVar('FILE', oldfile) |
152 | 155 | ||
153 | f.close() | ||
154 | |||
155 | for f in confFilters: | 156 | for f in confFilters: |
156 | f(fn, data) | 157 | f(fn, data) |
157 | 158 | ||
158 | return data | 159 | return data |
159 | 160 | ||
160 | def feeder(lineno, s, fn, statements): | 161 | # baseconfig is set for the bblayers/layer.conf cookerdata config parsing |
162 | # The function is also used by BBHandler, conffile would be False | ||
163 | def feeder(lineno, s, fn, statements, baseconfig=False, conffile=True): | ||
161 | m = __config_regexp__.match(s) | 164 | m = __config_regexp__.match(s) |
162 | if m: | 165 | if m: |
163 | groupd = m.groupdict() | 166 | groupd = m.groupdict() |
@@ -189,6 +192,11 @@ def feeder(lineno, s, fn, statements): | |||
189 | ast.handleUnsetFlag(statements, fn, lineno, m) | 192 | ast.handleUnsetFlag(statements, fn, lineno, m) |
190 | return | 193 | return |
191 | 194 | ||
195 | m = __addpylib_regexp__.match(s) | ||
196 | if baseconfig and conffile and m: | ||
197 | ast.handlePyLib(statements, fn, lineno, m) | ||
198 | return | ||
199 | |||
192 | raise ParseError("unparsed line: '%s'" % s, fn, lineno); | 200 | raise ParseError("unparsed line: '%s'" % s, fn, lineno); |
193 | 201 | ||
194 | # Add us to the handlers list | 202 | # Add us to the handlers list |