Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Playing around with json in bitbake

View bitbake-json.patch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
diff --git i/lib/bb/parse/ast.py w/lib/bb/parse/ast.py
index eae840f..2fa5664 100644
--- i/lib/bb/parse/ast.py
+++ w/lib/bb/parse/ast.py
@@ -102,13 +102,23 @@ class DataNode(AstNode):
bb.data.update_data(e)
val = e.expand(groupd["value"], key + "[:=]")
elif "append" in groupd and groupd["append"] != None:
- val = "%s %s" % ((self.getFunc(key, data) or ""), groupd["value"])
+ val = self.getFunc(key, data) or ""
+ if isinstance(val, basestring):
+ val += " " + groupd["value"]
+ else:
+ val += groupd["value"]
elif "prepend" in groupd and groupd["prepend"] != None:
- val = "%s %s" % (groupd["value"], (self.getFunc(key, data) or ""))
+ val = self.getFunc(key, data) or ""
+ if isinstance(val, basestring):
+ val = groupd["value"] + " " + val
+ else:
+ val = groupd["value"] + val
elif "postdot" in groupd and groupd["postdot"] != None:
- val = "%s%s" % ((self.getFunc(key, data) or ""), groupd["value"])
+ val = self.getFunc(key, data) or ""
+ val += groupd["value"]
elif "predot" in groupd and groupd["predot"] != None:
- val = "%s%s" % (groupd["value"], (self.getFunc(key, data) or ""))
+ val = self.getFunc(key, data) or ""
+ val = groupd["value"] + val
else:
val = groupd["value"]
 
diff --git i/lib/bb/parse/parse_py/ConfHandler.py w/lib/bb/parse/parse_py/ConfHandler.py
index 1edf2ef..85aa90d 100644
--- i/lib/bb/parse/parse_py/ConfHandler.py
+++ w/lib/bb/parse/parse_py/ConfHandler.py
@@ -25,12 +25,12 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
import re, os
+import json
import logging
import bb.utils
from bb.parse import ParseError, resolve_file, ast, logger
 
-#__config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}]+)\s*(?P<colon>:)?(?P<ques>\?)?=\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$")
 
-__config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}/]+)(\[(?P<flag>[a-zA-Z0-9\-_+.]+)\])?\s*((?P<colon>:=)|(?P<lazyques>\?\?=)|(?P<ques>\?=)|(?P<append>\+=)|(?P<prepend>=\+)|(?P<predot>=\.)|(?P<postdot>\.=)|=)\s*(?P<apo>['\"]?)(?P<value>.*)(?P=apo)$")
+__config_regexp__ = re.compile( r"(?P<exp>export\s*)?(?P<var>[a-zA-Z0-9\-_+.${}/]+)(\[(?P<flag>[a-zA-Z0-9\-_+.]+)\])?\s*((?P<colon>:=)|(?P<lazyques>\?\?=)|(?P<ques>\?=)|(?P<append>\+=)|(?P<prepend>=\+)|(?P<predot>=\.)|(?P<postdot>\.=)|=)\s*(?P<value>(?P<apo>['\"]?).*(?P=apo))$")
__include_regexp__ = re.compile( r"include\s+(.+)" )
__require_regexp__ = re.compile( r"require\s+(.+)" )
__export_regexp__ = re.compile( r"export\s+([a-zA-Z0-9\-_+.${}/]+)$" )
@@ -125,6 +125,11 @@ def feeder(lineno, s, fn, statements):
m = __config_regexp__.match(s)
if m:
groupd = m.groupdict()
+ if groupd["apo"]:
+ value = groupd["value"][1:-1]
+ else:
+ value = json.loads(groupd["value"])
+ groupd["value"] = value
ast.handleData(statements, fn, lineno, groupd)
return
View bitbake-json.patch
1 2 3 4 5 6 7 8
FOO = true
BAR = [5,7,9]
BAR += [11,13]
BAZ = {"foo": "bar"}
ALPHA = 5
ALPHA_append = 3
BETA = ["foo", "bar"]
BETA =+ ["alpha", "beta"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.