示例#1
0
    def testUpdateDataLastBug(self):
        from bb import data
        from bb import data_smart

        slugos = data_smart.DataSmart()
        data.setVar('PN', 'busybox', slugos)
        data.setVar('INITSCRIPT_PARAMS_${PN}_slugos', 'start 20 .', slugos)

        data.expandKeys(slugos)
        self.assertTrue('INITSCRIPT_PARAMS_busybox_slugos' in data.keys(slugos))

        data.setVar('OVERRIDES', 'slugos', slugos) 
        data.update_data(slugos)

        self.assertTrue('INITSCRIPT_PARAMS_busybox' in data.keys(slugos))
        data.setVar('OVERRIDES', 'busybox:slugos', slugos)
        data.update_data(slugos)
 
        self.assertTrue('INITSCRIPT_PARAMS' in data.keys(slugos))
        self.assertEquals('start 20 .', data.getVar('INITSCRIPT_PARAMS', slugos))
示例#2
0
def handle(fn, d, include = 0):
    global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __infunc__, __body__, __bbpath_found__, __residue__
    __body__ = []
    __bbpath_found__ = 0
    __infunc__ = ""
    __classname__ = ""
    __residue__ = []

    if include == 0:
        debug(2, "BB " + fn + ": handle(data)")
    else:
        debug(2, "BB " + fn + ": handle(data, include)")

    (root, ext) = os.path.splitext(os.path.basename(fn))
    init(d)

    if ext == ".bbclass":
        __classname__ = root
        classes.append(__classname__)

    if include != 0:
        oldfile = data.getVar('FILE', d)
    else:
        oldfile = None

    fn = obtain(fn, d)
    bbpath = (data.getVar('BBPATH', d, 1) or '').split(':')
    if not os.path.isabs(fn):
        f = None
        for p in bbpath:
            p = data.expand(p, d)
            j = os.path.join(p, fn)
            if os.access(j, os.R_OK):
                abs_fn = j
                f = open(j, 'r')
                break
        if f is None:
            raise IOError("file not found")
    else:
        f = open(fn,'r')
        abs_fn = fn

    if ext != ".bbclass":
        bbpath.insert(0, os.path.dirname(abs_fn))
        data.setVar('BBPATH', ":".join(bbpath), d)

    if include:
        bb.parse.mark_dependency(d, abs_fn)

    if ext != ".bbclass":
        data.setVar('FILE', fn, d)
        i = (data.getVar("INHERIT", d, 1) or "").split()
        if not "base" in i and __classname__ != "base":
            i[0:0] = ["base"]
        inherit(i, d)

    lineno = 0
    while 1:
        lineno = lineno + 1
        s = f.readline()
        if not s: break
        s = s.rstrip()
        feeder(lineno, s, fn, d)
    if __inpython__:
        # add a blank line to close out any python definition
        feeder(lineno + 1, "", fn, d)
    if ext == ".bbclass":
        classes.remove(__classname__)
    else:
        if include == 0:
            data.expandKeys(d)
            data.update_data(d)
            anonqueue = data.getVar("__anonqueue", d, 1) or []
            for anon in anonqueue:
                data.setVar("__anonfunc", anon["content"], d)
                data.setVarFlags("__anonfunc", anon["flags"], d)
                from bb import build
                try:
                    t = data.getVar('T', d)
                    data.setVar('T', '${TMPDIR}/', d)
                    build.exec_func("__anonfunc", d)
                    data.delVar('T', d)
                    if t:
                        data.setVar('T', t, d)
                except Exception, e:
                    bb.debug(1, "executing anonymous function: %s" % e)
                    raise
            data.delVar("__anonqueue", d)
            data.delVar("__anonfunc", d)
            set_additional_vars(fn, d, include)
            data.update_data(d)

            for var in data.keys(d):
                if data.getVarFlag(var, 'handler', d):
                    bb.event.register(data.getVar(var, d))
                    continue

                if not data.getVarFlag(var, 'task', d):
                    continue

                deps = data.getVarFlag(var, 'deps', d) or []
                postdeps = data.getVarFlag(var, 'postdeps', d) or []
                bb.build.add_task(var, deps, d)
                for p in postdeps:
                    pdeps = data.getVarFlag(p, 'deps', d) or []
                    pdeps.append(var)
                    data.setVarFlag(p, 'deps', pdeps, d)
                    bb.build.add_task(p, pdeps, d)
        bbpath.pop(0)