How to use the mk.__doEvalExpr function in mk

To help you get started, we’ve selected a few mk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vslavik / bakefile / src / utils.py View on Github external
if expr in mk.options and mk.options[expr].values != None:
            opt = mk.options[expr]
            for v in opt.values:
                if '$' in v.value:
                    ret += getPossibleValues(v)
                else:
                    ret.append(v)
            return ' '.join(ret)

        # don't know what else to try, return as-is
        return expr

    def callbackTxt(nothing, expr):
        return expr

    return mk.__doEvalExpr(expr, callbackVar, callbackTxt,
                           None, 1, None, None).split()
github vslavik / bakefile / src / utils.py View on Github external
else: var.add(cond, callback(cond2, v))
            return '$(%s)' % var.name

        if expr in __substituteCallbacks:
            for func in __substituteCallbacks[expr]:
                rval = func(expr, callback, caller)
                if rval != None:
                    return rval
        raise errors.Error("'%s' can't be used in this context, "%expr +
                 "not a conditional variable or option with listed values")

    def callbackTxt(cond, expr):
        if len(expr) == 0 or expr.isspace(): return expr
        return callback(cond, expr)
    
    return mk.__doEvalExpr(str, callbackVar, callbackTxt,
                           cond, # moreArgs
                           1,    # use_options
                           None, # target
                           None) # add_dict
github vslavik / bakefile / src / utils.py View on Github external
if not helper.ok: # don't waste time otherwise
            if expr in mk.options:
                if mk.options[expr].isNeverEmpty():
                    helper.ok = True
            # FIXME: it would be nice to be able to do this for condvars too,
            #        but they default to empty value if the set of its
            #        conditions is not exhaustive and so checking all items
            #        of its 'values' members is not enough, we'd have to verify
        return ''

    def textCb(helper, txt):
        if len(txt) > 0:
            helper.ok = True
        return ''

    mk.__doEvalExpr(value, varCb, textCb,
                    helper, # extra argument passed to callbacks
                    1,    # use_options
                    None, # target
                    None) # add_dict
    return helper.ok