How to use the mk.targets 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 / reader.py View on Github external
doAppend = 1
        else:
            doAppend = 0
        if 'prepend' in e.props and e.props['prepend'] == '1':
            doPrepend = 1
        else:
            doPrepend = 0
        store_in = None
        if 'scope' in e.props:
            sc = evalConstExpr(e, e.props['scope'], target=target)
            if sc == 'local':
                pass
            elif sc == 'global':
                store_in = mk.vars
            else:
                if sc in mk.targets:
                    store_in = mk.targets[sc].vars
                else:
                    raise ReaderError(e, "invalid scope '%s': must be 'global', 'local' or target name" % sc)

        if isMakeVar:
            if doAppend or store_in != None or not doEval:
                raise ReaderError(e, "make variable (%s) can't be appended or stored in nondefault scope or not evaluated" % name)
     
        mk.setVar(name, value, eval=doEval, target=target,
                  add_dict=add_dict, store_in=store_in,
                  append=doAppend, prepend=doPrepend, overwrite=overwrite,
                  makevar=isMakeVar, hints=hints)
    finally:
        errors.popCtx()
github vslavik / bakefile / src / flatten.py View on Github external
if len(cfgs) == 0:
        cfgs = [{}]

    if config.verbose:
        print '%i configurations' % len(cfgs)
        if config.debug:
            for c in cfgs: print '[dbg] %s' % c

    # remove options and conditional variables:
    mk.__vars_opt = {}
    for opt in mk.options.values():
        if opt.values == None:
            mk.vars[opt.name] = opt.default

    # add target.configs dictionary:
    for t in mk.targets.values():
        t.vars['configs'] = {}

    # expand or configurations:
    configs = {}
    configs_order = []
    for c in cfgs:
        name = __cfg2str(c)
        configDefs[name] = c
        configs[name] = flattenConfig(c)
        configs_order.append(name)
    mk.vars['configs'] = configs
    mk.vars['configs_order'] = configs_order

    # reduce number of configurations on targets:
    for t in mk.targets.values():
        findDistinctConfigs(t)
github vslavik / bakefile / src / flatten.py View on Github external
use = '1'
        else:
            use = mk.evalCondition(tar.cond.tostr())
        assert use != None
        if use == '0':
            toDel.append(t)
        else:
            orig_targets[t].vars['configs'][__cfg2str(cfg)] = tar.vars

    for t in toDel:
        del mk.targets[t]

    finalize.replaceEscapeSequences()

    myvars = mk.vars
    mytgt = mk.targets
    
    mk.vars = orig_vars
    mk.targets = orig_targets
    mk.cond_vars = orig_cond_vars
    mk.make_vars = orig_make_vars
    
    return (myvars, mytgt)
github vslavik / bakefile / src / flatten.py View on Github external
def flattenConfig(cfg):
    # make copy of mk.vars, we'll need to restore it later:
    orig_vars = mk.vars
    mk.vars = copy.deepcopy(mk.vars)
    orig_targets = mk.targets
    mk.targets = copy.deepcopy(mk.targets)
    orig_make_vars = mk.make_vars
    mk.make_vars = {}
    orig_cond_vars = mk.cond_vars
    mk.cond_vars = {}

    if 'configs' in mk.vars: del mk.vars['configs']
    for t in mk.targets.values():
        if 'configs' in t.vars: del t.vars['configs']
    
    # add option values in this configuration:
    for opt in cfg:
        mk.vars[opt] = cfg[opt]

    # add conditional variables:
    for cv in orig_cond_vars.values():
        mk.vars[cv.name] = ''
github vslavik / bakefile / src / flatten.py View on Github external
if e.option.values == None and e.option.default != e.value:
                    ok = 0
                    break
                if cfg[e.option.name] != e.value:
                    ok = 0
                    break
            if not ok: continue
            mk.vars[cv.name] = val.value
            break

    finalize.finalEvaluation()

    # Remove targets that are not part of this configuration:
    toDel = []
    for t in mk.targets:
        tar = mk.targets[t]
        if tar.cond == None:
            use = '1'
        else:
            use = mk.evalCondition(tar.cond.tostr())
        assert use != None
        if use == '0':
            toDel.append(t)
        else:
            orig_targets[t].vars['configs'][__cfg2str(cfg)] = tar.vars

    for t in toDel:
        del mk.targets[t]

    finalize.replaceEscapeSequences()

    myvars = mk.vars
github vslavik / bakefile / src / flatten.py View on Github external
def flattenConfig(cfg):
    # make copy of mk.vars, we'll need to restore it later:
    orig_vars = mk.vars
    mk.vars = copy.deepcopy(mk.vars)
    orig_targets = mk.targets
    mk.targets = copy.deepcopy(mk.targets)
    orig_make_vars = mk.make_vars
    mk.make_vars = {}
    orig_cond_vars = mk.cond_vars
    mk.cond_vars = {}

    if 'configs' in mk.vars: del mk.vars['configs']
    for t in mk.targets.values():
        if 'configs' in t.vars: del t.vars['configs']
    
    # add option values in this configuration:
    for opt in cfg:
        mk.vars[opt] = cfg[opt]

    # add conditional variables:
    for cv in orig_cond_vars.values():
github vslavik / bakefile / src / flatten.py View on Github external
for t in mk.targets.values():
        t.vars['configs'] = {}

    # expand or configurations:
    configs = {}
    configs_order = []
    for c in cfgs:
        name = __cfg2str(c)
        configDefs[name] = c
        configs[name] = flattenConfig(c)
        configs_order.append(name)
    mk.vars['configs'] = configs
    mk.vars['configs_order'] = configs_order

    # reduce number of configurations on targets:
    for t in mk.targets.values():
        findDistinctConfigs(t)