def main(): cache = nodecache.NodeCache(bitbakec.parsefile) # Read the Configuration my_init = bb.data.init() bb.data.inheritFromOS(my_init) my_init.setVar('TOPDIR', os.getcwd() ) conf = bitbakec.parsefile(bb.which(os.environ['BBPATH'], "conf/bitbake.conf"), True) conf.eval( my_init, cache ) # micro optimisation INHERIT the bases once... import ast root = ast.Root("none") inherits = (my_init.getVar('INHERIT', True) or "").split() inherits.insert(0, "base") for inherit in inherits: print "Inheriting %s" % inherit root.add_statement( ast.Inherit( inherit ) ) root.eval( my_init, cache ) cache.base_classes = root.classes cache.task_base = root.tasks cache.queue_base = root.anonqueue print cache.base_classes print root.handler add_handler( root, my_init ) #sys.exit(-1) # Initialize the fetcher stuff def set_additional_vars(the_data): """Deduce rest of variables, e.g. ${A} out of ${SRC_URI}""" src_uri = bb.data.getVar('SRC_URI', the_data) if not src_uri: return src_uri = bb.data.expand(src_uri, the_data) a = bb.data.getVar('A', the_data) if a: a = bb.data.expand(a, the_data).split() else: a = [] from bb import fetch try: fetch.init(src_uri.split(), the_data) except fetch.NoMethodError: pass except bb.MalformedUrl,e: raise bb.parse.ParseError("Unable to generate local paths for SRC_URI due to malformed uri: %s" % e) a += fetch.localpaths(the_data) del fetch bb.data.setVar('A', " ".join(a), the_data)
def handle(fn, d, include): print "" print "fn: %s" % fn print "data: %s" % d print dir(d) print d.getVar.__doc__ print "include: %s" % include # check if we include or are the beginning if include: oldfile = d.getVar('FILE') else: #d.inheritFromOS() oldfile = None # find the file if not os.path.isabs(fn): bb.error("No Absolute FILE name") abs_fn = bb.which(d.getVar('BBPATH'), fn) else: abs_fn = fn # check if the file exists if not os.path.exists(abs_fn): raise IOError("file '%(fn)' not found" % locals() ) # now we know the file is around mark it as dep if include: parse.mark_dependency(d, abs_fn) # now parse this file - by defering it to C++ parsefile(fn, d) # restore the original FILE if oldfile: d.setVar('FILE', oldfile) return d
#bb.msg.debug(1, bb.msg.domain.Parsing, "executing anonymous function: %s" % e) raise bb.data.delVar("__anonfunc", the_data) set_additional_vars(the_data) bb.data.update_data(the_data) # Parse all functions for root, dirs, files in os.walk('/space/hacking/embedded/oe/org.openembedded.dev/'): for file in files: (r2, ext) = os.path.splitext(file) if not ext in ['.bb' ]: continue path = os.path.join(root, file) #print "Parsing %s" % path ast = bitbakec.parsefile(path,False) if not ast: continue try: data = my_init.createCopy() #ast.base_classes = copy.copy(base_classes) #ast.task_base = copy.copy(task_base) #ast.queue_base = copy.copy(queue_base) ast.eval( data, cache ) #print ast.classes finish_up( ast, data, cache ) add_tasks( ast, data ) except Exception, e: print "Error eval", e except: pass
def handle(fn, d, include): from bb import data, parse (root, ext) = os.path.splitext(os.path.basename(fn)) base_name = "%s%s" % (root,ext) # initialize with some data init(fn,d) # check if we include or are the beginning oldfile = None if include: oldfile = d.getVar('FILE', False) is_conf = False elif ext == ".conf": is_conf = True data.inheritFromOS(d) # find the file if not os.path.isabs(fn): abs_fn = bb.which(d.getVar('BBPATH', True), fn) else: abs_fn = fn # check if the file exists if not os.path.exists(abs_fn): raise IOError("file '%(fn)s' not found" % locals() ) # now we know the file is around mark it as dep if include: parse.mark_dependency(d, abs_fn) # manipulate the bbpath if ext != ".bbclass" and ext != ".conf": old_bb_path = data.getVar('BBPATH', d) data.setVar('BBPATH', os.path.dirname(abs_fn) + (":%s" %old_bb_path) , d) # handle INHERITS and base inherit if ext != ".bbclass" and ext != ".conf": data.setVar('FILE', fn, d) handle_interit(d) # now parse this file - by defering it to C++ parsefile(abs_fn, d, is_conf) # Finish it up if include == 0: data.expandKeys(d) data.update_data(d) #### !!! XXX Finish it up by executing the anonfunc # restore the original FILE if oldfile: d.setVar('FILE', oldfile) # restore bbpath if ext != ".bbclass" and ext != ".conf": data.setVar('BBPATH', old_bb_path, d ) return d