THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
-import os
+import os, sys
# The Module we will use here
import bb
return fn[-3:] == ".bb" or fn[-8:] == ".bbclass" or fn[-4:] == ".inc" or fn[-5:] == ".conf"
def init(fn, data):
- if not data.getVar('TOPDIR', False):
- bb.error('TOPDIR is not set')
- if not data.getVar('BBPATH', False):
- bb.error('BBPATH is not set')
+ if not bb.data.getVar('TOPDIR', data):
+ bb.data.setVar('TOPDIR', os.getcwd(), data)
+ if not bb.data.getVar('BBPATH', data):
+ bb.data.setVar('BBPATH', os.path.join(sys.prefix, 'share', 'bitbake'), data)
def handle(fn, d, include):
#print "data: %s" % d
#print dir(d)
#print d.getVar.__doc__
- print "include: %s" % fn
+ #print "include: %s" % fn
+
+ # initialize with some data
+ init(fn,d)
# check if we include or are the beginning
if include:
return d
+
+# Needed for BitBake files...
+__pkgsplit_cache__={}
+def vars_from_file(mypkg, d):
+ if not mypkg:
+ return (None, None, None)
+ if mypkg in __pkgsplit_cache__:
+ return __pkgsplit_cache__[mypkg]
+
+ myfile = os.path.splitext(os.path.basename(mypkg))
+ parts = myfile[0].split('_')
+ __pkgsplit_cache__[mypkg] = parts
+ exp = 3 - len(parts)
+ tmplist = []
+ while exp != 0:
+ exp -= 1
+ tmplist.append(None)
+ parts.extend(tmplist)
+ return parts
+
+
+
+
# Inform bitbake that we are a parser
# We need to define all three
from bb.parse import handlers
ctypedef struct lex_t:
void* parser
void* scanner
+ char* name
FILE* file
void* data
int lineError
int errorParse
- cdef extern void parse(FILE*, object)
+ cdef extern int parse(FILE*, char*, object)
def parsefile(object file, object data):
#print "parsefile: 1", file, data
raise IOError("No such file %s." % file)
#print "parsefile: 3 parse"
- parse(f, data)
+ parse(f, file, data)
# Close the file
- #print "parsefile: 4 closing"
fclose(f)
cdef public void e_assign(lex_t* container, char* key, char* what):
#print "e_assign", key, what
+ if what == NULL:
+ print "FUTURE Warning empty string: use \"\""
+ what = ""
+
d = <object>container.data
d.setVar(key, what)
#colon:
# val = bb.data.expand(groupd["value"], data)
d = <object>c.data
- d.setVar(key, d.expand(what,None))
+ d.setVar(key, d.expand(what,d))
cdef public void e_cond(lex_t* c, char* key, char* what):
#print "e_cond", key, what
# val = bb.data.getVar(key, data)
# if val == None:
# val = groupd["value"]
+ if what == NULL:
+ print "FUTURE warning: Use \"\" for", key
+ what = ""
+
d = <object>c.data
- d.setVar(key, (d.getVar(key,0) or what))
+ d.setVar(key, (d.getVar(key,False) or what))
cdef public void e_prepend(lex_t* c, char* key, char* what):
#print "e_prepend", key, what
print "Could not include file", file
-cdef public void e_require(lex_t* c, char* file):
+cdef public int e_require(lex_t* c, char* file) except -1:
#print "e_require", file
from bb.parse import handle
d = <object>c.data
print "ParseError", file
from bb.parse import ParseError
raise ParseError("Could not include required file %s" % file)
+ return -1
cdef public void e_proc(lex_t* c, char* key, char* what):
#print "e_proc", key, what
#print "e_def", a, b, d
pass
-cdef public void e_parse_error(lex_t* c):
- print "e_parse_error", "line:", lineError, "parse:", errorParse
+cdef public int e_parse_error(lex_t* c) except -1:
+ print "e_parse_error", c.name, "line:", lineError, "parse:", errorParse
from bb.parse import ParseError
- raise ParseError("There was an parse error, sorry unable to give more information at the current time.")
+ raise ParseError("There was an parse error, sorry unable to give more information at the current time. File: %s Line: %d" % (c.name,lineError) )
+ return -1