diff options
| author | Holger Freyther <ich@tamarin.(none)> | 2009-05-17 15:56:40 +0200 |
|---|---|---|
| committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-02-10 16:37:43 +0000 |
| commit | fb918a758215c7669b4850946280bd58c6e063c4 (patch) | |
| tree | 9037c2e69c67448933a4a281b488bb60cd6ef99c /bitbake/lib/bb/parse/parse_py | |
| parent | b045ab32227baaec940698dad79aac0e41c5ee8a (diff) | |
| download | poky-fb918a758215c7669b4850946280bd58c6e063c4.tar.gz | |
bitbake: [parser] Move more stuff out the feeder
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/parse/parse_py')
| -rw-r--r-- | bitbake/lib/bb/parse/parse_py/ConfHandler.py | 86 |
1 files changed, 48 insertions, 38 deletions
diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py index ce746106a4..b22bbc8af5 100644 --- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py +++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py | |||
| @@ -33,6 +33,50 @@ __include_regexp__ = re.compile( r"include\s+(.+)" ) | |||
| 33 | __require_regexp__ = re.compile( r"require\s+(.+)" ) | 33 | __require_regexp__ = re.compile( r"require\s+(.+)" ) |
| 34 | __export_regexp__ = re.compile( r"export\s+(.+)" ) | 34 | __export_regexp__ = re.compile( r"export\s+(.+)" ) |
| 35 | 35 | ||
| 36 | # routines for the parser, to be turned into an AST | ||
| 37 | def handleInclude(m, fn, lineno, data, force): | ||
| 38 | s = bb.data.expand(m.group(1), data) | ||
| 39 | bb.msg.debug(3, bb.msg.domain.Parsing, "CONF %s:%d: including %s" % (fn, lineno, s)) | ||
| 40 | include(fn, s, data, False) | ||
| 41 | |||
| 42 | def handleExport(m, data): | ||
| 43 | bb.data.setVarFlag(m.group(1), "export", 1, data) | ||
| 44 | |||
| 45 | def handleData(groupd, data): | ||
| 46 | key = groupd["var"] | ||
| 47 | if "exp" in groupd and groupd["exp"] != None: | ||
| 48 | bb.data.setVarFlag(key, "export", 1, data) | ||
| 49 | if "ques" in groupd and groupd["ques"] != None: | ||
| 50 | val = getFunc(groupd, key, data) | ||
| 51 | if val == None: | ||
| 52 | val = groupd["value"] | ||
| 53 | elif "colon" in groupd and groupd["colon"] != None: | ||
| 54 | e = data.createCopy() | ||
| 55 | bb.data.update_data(e) | ||
| 56 | val = bb.data.expand(groupd["value"], e) | ||
| 57 | elif "append" in groupd and groupd["append"] != None: | ||
| 58 | val = "%s %s" % ((getFunc(groupd, key, data) or ""), groupd["value"]) | ||
| 59 | elif "prepend" in groupd and groupd["prepend"] != None: | ||
| 60 | val = "%s %s" % (groupd["value"], (getFunc(groupd, key, data) or "")) | ||
| 61 | elif "postdot" in groupd and groupd["postdot"] != None: | ||
| 62 | val = "%s%s" % ((getFunc(groupd, key, data) or ""), groupd["value"]) | ||
| 63 | elif "predot" in groupd and groupd["predot"] != None: | ||
| 64 | val = "%s%s" % (groupd["value"], (getFunc(groupd, key, data) or "")) | ||
| 65 | else: | ||
| 66 | val = groupd["value"] | ||
| 67 | if 'flag' in groupd and groupd['flag'] != None: | ||
| 68 | bb.msg.debug(3, bb.msg.domain.Parsing, "setVarFlag(%s, %s, %s, data)" % (key, groupd['flag'], val)) | ||
| 69 | bb.data.setVarFlag(key, groupd['flag'], val, data) | ||
| 70 | else: | ||
| 71 | bb.data.setVar(key, val, data) | ||
| 72 | |||
| 73 | def getFunc(groupd, key, data): | ||
| 74 | if 'flag' in groupd and groupd['flag'] != None: | ||
| 75 | return bb.data.getVarFlag(key, groupd['flag'], data) | ||
| 76 | else: | ||
| 77 | return bb.data.getVar(key, data) | ||
| 78 | |||
| 79 | |||
| 36 | def init(data): | 80 | def init(data): |
| 37 | topdir = bb.data.getVar('TOPDIR', data) | 81 | topdir = bb.data.getVar('TOPDIR', data) |
| 38 | if not topdir: | 82 | if not topdir: |
| @@ -110,59 +154,25 @@ def handle(fn, data, include = 0): | |||
| 110 | return data | 154 | return data |
| 111 | 155 | ||
| 112 | def feeder(lineno, s, fn, data): | 156 | def feeder(lineno, s, fn, data): |
| 113 | def getFunc(groupd, key, data): | ||
| 114 | if 'flag' in groupd and groupd['flag'] != None: | ||
| 115 | return bb.data.getVarFlag(key, groupd['flag'], data) | ||
| 116 | else: | ||
| 117 | return bb.data.getVar(key, data) | ||
| 118 | |||
| 119 | m = __config_regexp__.match(s) | 157 | m = __config_regexp__.match(s) |
| 120 | if m: | 158 | if m: |
| 121 | groupd = m.groupdict() | 159 | groupd = m.groupdict() |
| 122 | key = groupd["var"] | 160 | handleData(groupd, data) |
| 123 | if "exp" in groupd and groupd["exp"] != None: | ||
| 124 | bb.data.setVarFlag(key, "export", 1, data) | ||
| 125 | if "ques" in groupd and groupd["ques"] != None: | ||
| 126 | val = getFunc(groupd, key, data) | ||
| 127 | if val == None: | ||
| 128 | val = groupd["value"] | ||
| 129 | elif "colon" in groupd and groupd["colon"] != None: | ||
| 130 | e = data.createCopy() | ||
| 131 | bb.data.update_data(e) | ||
| 132 | val = bb.data.expand(groupd["value"], e) | ||
| 133 | elif "append" in groupd and groupd["append"] != None: | ||
| 134 | val = "%s %s" % ((getFunc(groupd, key, data) or ""), groupd["value"]) | ||
| 135 | elif "prepend" in groupd and groupd["prepend"] != None: | ||
| 136 | val = "%s %s" % (groupd["value"], (getFunc(groupd, key, data) or "")) | ||
| 137 | elif "postdot" in groupd and groupd["postdot"] != None: | ||
| 138 | val = "%s%s" % ((getFunc(groupd, key, data) or ""), groupd["value"]) | ||
| 139 | elif "predot" in groupd and groupd["predot"] != None: | ||
| 140 | val = "%s%s" % (groupd["value"], (getFunc(groupd, key, data) or "")) | ||
| 141 | else: | ||
| 142 | val = groupd["value"] | ||
| 143 | if 'flag' in groupd and groupd['flag'] != None: | ||
| 144 | bb.msg.debug(3, bb.msg.domain.Parsing, "setVarFlag(%s, %s, %s, data)" % (key, groupd['flag'], val)) | ||
| 145 | bb.data.setVarFlag(key, groupd['flag'], val, data) | ||
| 146 | else: | ||
| 147 | bb.data.setVar(key, val, data) | ||
| 148 | return | 161 | return |
| 149 | 162 | ||
| 150 | m = __include_regexp__.match(s) | 163 | m = __include_regexp__.match(s) |
| 151 | if m: | 164 | if m: |
| 152 | s = bb.data.expand(m.group(1), data) | 165 | handleInclude(m, fn, lineno, data, False) |
| 153 | bb.msg.debug(3, bb.msg.domain.Parsing, "CONF %s:%d: including %s" % (fn, lineno, s)) | ||
| 154 | include(fn, s, data, False) | ||
| 155 | return | 166 | return |
| 156 | 167 | ||
| 157 | m = __require_regexp__.match(s) | 168 | m = __require_regexp__.match(s) |
| 158 | if m: | 169 | if m: |
| 159 | s = bb.data.expand(m.group(1), data) | 170 | handleInclude(m, fn, lineno, data, True) |
| 160 | include(fn, s, data, "include required") | ||
| 161 | return | 171 | return |
| 162 | 172 | ||
| 163 | m = __export_regexp__.match(s) | 173 | m = __export_regexp__.match(s) |
| 164 | if m: | 174 | if m: |
| 165 | bb.data.setVarFlag(m.group(1), "export", 1, data) | 175 | handleExport(m, data) |
| 166 | return | 176 | return |
| 167 | 177 | ||
| 168 | raise ParseError("%s:%d: unparsed line: '%s'" % (fn, lineno, s)); | 178 | raise ParseError("%s:%d: unparsed line: '%s'" % (fn, lineno, s)); |
