lib/bb/parse/parser_c: Handle includes, requires, cope with our syntax
[vuplus_bitbake] / lib / bb / parse / parse_c / bitbakec.pyx
index 6bdad36..b26ebce 100644 (file)
@@ -22,45 +22,45 @@ cdef extern from "lexerc.h":
     cdef extern void parse(FILE*, object)
 
 def parsefile(object file, object data):
-    print "parsefile: 1", file, data
+    #print "parsefile: 1", file, data
 
     # Open the file
     cdef FILE* f
 
     f = fopen(file, "r")
-    print "parsefile: 2 opening file"
+    #print "parsefile: 2 opening file"
     if (f == NULL):
         raise IOError("No such file %s." % file)
 
-    print "parsefile: 3 parse"
+    #print "parsefile: 3 parse"
     parse(f, data)
 
     # Close the file
-    print "parsefile: 4 closing"
+    #print "parsefile: 4 closing"
     fclose(f)
 
 
 cdef public void e_assign(lex_t* container, char* key, char* what):
-    print "e_assign", key, what
+    #print "e_assign", key, what
     d = <object>container.data
     d.setVar(key, what)
 
 cdef public void e_export(lex_t* c, char* what):
-    print "e_export", what
+    #print "e_export", what
     #exp:
     # bb.data.setVarFlag(key, "export", 1, data)
     d = <object>c.data
     d.setVarFlag(what, "export", 1)
 
 cdef public void e_immediate(lex_t* c, char* key, char* what):
-    print "e_immediate", key, what
+    #print "e_immediate", key, what
     #colon:
     # val = bb.data.expand(groupd["value"], data)
     d = <object>c.data
     d.setVar(key, d.expand(what,None))
 
 cdef public void e_cond(lex_t* c, char* key, char* what):
-    print "e_cond", key, what
+    #print "e_cond", key, what
     #ques:
     # val = bb.data.getVar(key, data)
     # if val == None:    
@@ -69,35 +69,35 @@ cdef public void e_cond(lex_t* c, char* key, char* what):
     d.setVar(key, (d.getVar(key,0) or what))
 
 cdef public void e_prepend(lex_t* c, char* key, char* what):
-    print "e_prepend", key, what
+    #print "e_prepend", key, what
     #prepend:
     # val = "%s %s" % (groupd["value"], (bb.data.getVar(key, data) or ""))
     d = <object>c.data
     d.setVar(key, what + " " + (d.getVar(key,0) or ""))
 
 cdef public void e_append(lex_t* c, char* key, char* what):
-    print "e_append", key, what
+    #print "e_append", key, what
     #append:
     # val = "%s %s" % ((bb.data.getVar(key, data) or ""), groupd["value"])
     d = <object>c.data
     d.setVar(key, (d.getVar(key,0) or "") + " " + what)
 
 cdef public void e_precat(lex_t* c, char* key, char* what):
-    print "e_precat", key, what
+    #print "e_precat", key, what
     #predot:
     # val = "%s%s" % (groupd["value"], (bb.data.getVar(key, data) or ""))
     d = <object>c.data
     d.setVar(key, what + (d.getVar(key,0) or ""))
 
 cdef public void e_postcat(lex_t* c, char* key, char* what):
-    print "e_postcat", key, what
+    #print "e_postcat", key, what
     #postdot:
     # val = "%s%s" % ((bb.data.getVar(key, data) or ""), groupd["value"])
     d = <object>c.data
     d.setVar(key, (d.getVar(key,0) or "") + what)
 
 cdef public void e_addtask(lex_t* c, char* name, char* before, char* after):
-    print "e_addtask", name
+    #print "e_addtask", name
     # func = m.group("func")
     # before = m.group("before")
     # after = m.group("after")
@@ -120,69 +120,75 @@ cdef public void e_addtask(lex_t* c, char* name, char* before, char* after):
     d.setVarFlag(do, "task", 1)
 
     if before != NULL and strlen(before) > 0:
-        print "Before", before
+        #print "Before", before
         d.setVarFlag(do, "postdeps", ("%s" % before).split())
     if after  != NULL and strlen(after) > 0:
-        print "After", after
+        #print "After", after
         d.setVarFlag(do, "deps", ("%s" % after).split())
 
 
 cdef public void e_addhandler(lex_t* c, char* h):
-    print "e_addhandler", h
+    #print "e_addhandler", h
     # data.setVarFlag(h, "handler", 1, d)
     d = <object>c.data
     d.setVarFlag(h, "handler", 1)
 
 cdef public void e_export_func(lex_t* c, char* function):
-    print "e_export_func", function
+    #print "e_export_func", function
     pass
 
 cdef public void e_inherit(lex_t* c, char* file):
-    print "e_inherit", file
+    #print "e_inherit", file
     pass
 
 cdef public void e_include(lex_t* c, char* file):
-    print "e_include", file
     from bb.parse import handle
     d = <object>c.data
 
     try:
-        handle(d.expand(file,None), d, True)
+        handle(d.expand(file,d), d, True)
     except IOError:
-        print "Could not include required file %s" % file
+        print "Could not include file", file
 
 
 cdef public void e_require(lex_t* c, char* file):
-    print "e_require", file
+    #print "e_require", file
+    from bb.parse import handle
     d = <object>c.data
-    d.expand(file)
 
     try:
-        parsefile(file, d)
+        handle(d.expand(file,d), d, True)
     except IOError:
-        raise CParseError("Could not include required file %s" % file)
+        print "ParseError", file
+        from bb.parse import ParseError
+        raise ParseError("Could not include required file %s" % file)
 
 cdef public void e_proc(lex_t* c, char* key, char* what):
-    print "e_proc", key, what
+    #print "e_proc", key, what
     pass
 
 cdef public void e_proc_python(lex_t* c, char* key, char* what):
-    print "e_proc_python"
+    #print "e_proc_python"
     if key != NULL:
-        print "Key", key
+        pass
+        #print "Key", key
     if what != NULL:
-        print "What", what
+        pass
+        #print "What", what
     pass
 
 cdef public void e_proc_fakeroot(lex_t* c, char* key, char* what):
-    print "e_fakeroot", key, what
+    #print "e_fakeroot", key, what
     pass
 
 cdef public void e_def(lex_t* c, char* a, char* b, char* d):
-    print "e_def", a, b, d
+    #print "e_def", a, b, d
     pass
 
 cdef public void e_parse_error(lex_t* c):
     print "e_parse_error", "line:", lineError, "parse:", errorParse
-    raise CParseError("There was an parse error, sorry unable to give more information at the current time.")
+
+
+    from bb.parse import ParseError
+    raise ParseError("There was an parse error, sorry unable to give more information at the current time.")