Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (not overwrite) and (name in target.vars):
return
name = '__%s_%s' % (target.id.replace('-','_').replace('.','_').replace('/','_'),
basename)
mk.setVar(e.props['var'], '$(%s)' % name,
eval=0, target=target,
add_dict=add_dict, hints=hints)
if cond == None:
raise ReaderError(e, "malformed condition: '%s': must be constant expression, equality test or conjunction of them" % condstr)
if name in mk.cond_vars:
if not overwrite:
return
var = mk.cond_vars[name]
else:
var = mk.CondVar(name, target)
mk.addCondVar(var, hints)
if doEval:
value = mk.evalExpr(e_if.value,target=target,add_dict=add_dict)
else:
value = e_if.value
var.add(cond, value)
finally:
errors.popCtx()
if noValueSet:
isCond = 0
value = ''
if isCond:
return
# Non-conditional variables:
for v in cond.values:
cond2 = mk.mergeConditions(cnd, v.cond)
if '$' in v.value:
var.add(v.cond,
substitute2(v.value, callback, desc, cond2, hints))
else:
if len(v.value) == 0 or v.value.isspace():
var.add(v.cond, v.value)
else:
var.add(v.cond, callback(cond2, v.value))
return '$(%s)' % var.name
if expr in mk.options and mk.options[expr].values != None:
opt = mk.options[expr]
var = mk.CondVar(makeUniqueCondVarName('%s_%s' % (opt.name, desc)))
mk.addCondVar(var, hints)
for v in opt.values:
cond = mk.makeCondition("%s=='%s'" % (opt.name, v))
cond2 = mk.mergeConditions(cnd, cond)
if '$' in v:
var.add(cond, substitute2(v, callback, desc, cond2, hints))
else:
if len(v) == 0 or v.isspace(): var.add(cond, v)
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 +
return fmt % value
if value.startswith('$(') and value[-1] == ')':
# FIXME: this is too limited, it should be done inside __doEvalExpr
# callbacks instead.
condname = value[2:-1]
if condname in mk.options:
if mk.options[condname].isNeverEmpty():
return fmt % value
else:
raise errors.Error("formatIfNotEmpty failed: option '%s' may be empty" % condname)
if condname in mk.cond_vars:
cond = mk.cond_vars[condname]
var = mk.CondVar(makeUniqueCondVarName('%s_p' % cond.name))
mk.addCondVar(var)
for v in cond.values:
var.add(v.cond, formatIfNotEmpty(fmt, v.value))
return '$(%s)' % var.name
if condname in mk.make_vars:
form = formatIfNotEmpty(fmt, mk.make_vars[condname])
if form == '': return ''
return fmt % value
if condname in mk.vars:
form = formatIfNotEmpty(fmt, mk.vars[condname])
if form == '': return ''
return fmt % value
raise errors.Error("formatIfNotEmpty failed: '%s' too complicated" % value)
counter = 0
newname = common
while newname in mk.vars or newname in mk.__vars_opt:
newname = '%s_%i' % (common,counter)
counter += 1
del mk.__vars_opt[c1.name]
del mk.__vars_opt[c2.name]
del mk.cond_vars[c1.name]
del mk.cond_vars[c2.name]
if c1.name != newname:
mk.vars[c1.name] = '$(%s)' % newname
if c2.name != newname:
mk.vars[c2.name] = '$(%s)' % newname
hints = mk.getHints(c1.name)
c1.name = c2.name = newname
mk.addCondVar(c1, hints=hints)
if config.verbose:
sys.stdout.write(': %i -> %i\n' % (before, len(mk.cond_vars)))
return len(duplicates) > 0