summaryrefslogtreecommitdiffstats
path: root/lib/bb/parse/parse_c/bitbakec.pyx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bb/parse/parse_c/bitbakec.pyx')
-rw-r--r--lib/bb/parse/parse_c/bitbakec.pyx85
1 files changed, 67 insertions, 18 deletions
diff --git a/lib/bb/parse/parse_c/bitbakec.pyx b/lib/bb/parse/parse_c/bitbakec.pyx
index 1070e2731..c666e9b6b 100644
--- a/lib/bb/parse/parse_c/bitbakec.pyx
+++ b/lib/bb/parse/parse_c/bitbakec.pyx
@@ -15,14 +15,15 @@ cdef extern from "lexerc.h":
void* scanner
char* name
FILE* file
+ int config
void* data
int lineError
int errorParse
- cdef extern int parse(FILE*, char*, object)
+ cdef extern int parse(FILE*, char*, object, int)
-def parsefile(object file, object data):
+def parsefile(object file, object data, object config):
#print "parsefile: 1", file, data
# Open the file
@@ -34,7 +35,7 @@ def parsefile(object file, object data):
raise IOError("No such file %s." % file)
#print "parsefile: 3 parse"
- parse(f, file, data)
+ parse(f, file, data, config)
# Close the file
fclose(f)
@@ -104,7 +105,7 @@ cdef public void e_postcat(lex_t* c, char* key, char* what):
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):
+cdef public int e_addtask(lex_t* c, char* name, char* before, char* after) except -1:
#print "e_addtask", name
# func = m.group("func")
# before = m.group("before")
@@ -123,8 +124,13 @@ cdef public void e_addtask(lex_t* c, char* name, char* before, char* after):
# data.setVarFlag(var, "postdeps", before.split(), d)
# return
- do = "do_%s" % name
+ if c.config == 1:
+ from bb.parse import ParseError
+ raise ParseError("No tasks allowed in config files")
+ return -1
+
d = <object>c.data
+ do = "do_%s" % name
d.setVarFlag(do, "task", 1)
if before != NULL and strlen(before) > 0:
@@ -134,20 +140,38 @@ cdef public void e_addtask(lex_t* c, char* name, char* before, char* after):
#print "After", after
d.setVarFlag(do, "deps", ("%s" % after).split())
+ return 0
-cdef public void e_addhandler(lex_t* c, char* h):
+cdef public int e_addhandler(lex_t* c, char* h) except -1:
#print "e_addhandler", h
# data.setVarFlag(h, "handler", 1, d)
+ if c.config == 1:
+ from bb.parse import ParseError
+ raise ParseError("No handlers allowed in config files")
+ return -1
+
d = <object>c.data
d.setVarFlag(h, "handler", 1)
+ return 0
-cdef public void e_export_func(lex_t* c, char* function):
+cdef public int e_export_func(lex_t* c, char* function) except -1:
#print "e_export_func", function
- pass
+ if c.config == 1:
+ from bb.parse import ParseError
+ raise ParseError("No functions allowed in config files")
+ return -1
-cdef public void e_inherit(lex_t* c, char* file):
+ return 0
+
+cdef public int e_inherit(lex_t* c, char* file) except -1:
#print "e_inherit", file
- pass
+
+ if c.config == 1:
+ from bb.parse import ParseError
+ raise ParseError("No inherits allowed in config files")
+ return -1
+
+ return 0
cdef public void e_include(lex_t* c, char* file):
from bb.parse import handle
@@ -172,27 +196,52 @@ cdef public int e_require(lex_t* c, char* file) except -1:
raise ParseError("Could not include required file %s" % file)
return -1
-cdef public void e_proc(lex_t* c, char* key, char* what):
+ return 0
+
+cdef public int e_proc(lex_t* c, char* key, char* what) except -1:
#print "e_proc", key, what
- pass
+ if c.config == 1:
+ from bb.parse import ParseError
+ raise ParseError("No inherits allowed in config files")
+ return -1
-cdef public void e_proc_python(lex_t* c, char* key, char* what):
+ return 0
+
+cdef public int e_proc_python(lex_t* c, char* key, char* what) except -1:
#print "e_proc_python"
+ if c.config == 1:
+ from bb.parse import ParseError
+ raise ParseError("No pythin allowed in config files")
+ return -1
+
if key != NULL:
pass
#print "Key", key
if what != NULL:
pass
#print "What", what
- pass
-cdef public void e_proc_fakeroot(lex_t* c, char* key, char* what):
+ return 0
+
+cdef public int e_proc_fakeroot(lex_t* c, char* key, char* what) except -1:
#print "e_fakeroot", key, what
- pass
-cdef public void e_def(lex_t* c, char* a, char* b, char* d):
+ if c.config == 1:
+ from bb.parse import ParseError
+ raise ParseError("No fakeroot allowed in config files")
+ return -1
+
+ return 0
+
+cdef public int e_def(lex_t* c, char* a, char* b, char* d) except -1:
#print "e_def", a, b, d
- pass
+
+ if c.config == 1:
+ from bb.parse import ParseError
+ raise ParseError("No defs allowed in config files")
+ return -1
+
+ return 0
cdef public int e_parse_error(lex_t* c) except -1:
print "e_parse_error", c.name, "line:", lineError, "parse:", errorParse