Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if outputVarsOnly:
interestingVars = mk.vars['FORMAT_OUTPUT_VARIABLES'].strip()
if interestingVars != '':
interestingVars = interestingVars.split()
optimizeVars = len(interestingVars) > 0
else:
optimizeVars = 0
else:
optimizeVars = 0
for v in mk.make_vars:
if '$' in mk.make_vars[v]:
list.append((mk.make_vars,v,None))
for c in mk.cond_vars.values():
for v in c.values:
if '$' in v.value:
list.append((None,v,c.target))
if optimizeVars:
for v in interestingVars:
if v in mk.vars and '$' in mk.vars[v]:
list.append((mk.vars,v,None))
else:
for v in mk.vars:
if type(mk.vars[v]) is StringType:
if '$' in mk.vars[v]:
list.append((mk.vars,v,None))
if optimizeVars:
for t in mk.targets.values():
options.append(o.name, o)
dict['options'] = options
# Copy conditions:
conditions = Container()
for cond in mk.conditions.values():
c = Struct()
c.name = cond.name
c.exprs = cond.exprs
conditions.append(c.name, c)
setattr(conditions, c.name, c)
dict['conditions'] = conditions
# Copy conditional variables:
cond_vars = Container()
for cv in mk.cond_vars.values():
c = Struct()
c.name = cv.name
c.values = []
for v in cv.values:
vv = Struct()
vv.value = v.value
vv.cond = conditions[v.cond.name]
c.values.append(vv)
cond_vars.append(c.name, c)
setattr(cond_vars, c.name, c)
dict['cond_vars'] = cond_vars
# Copy "make variables":
make_vars = Container()
for mv in mk.make_vars:
mvv = Struct()
def dumpMakefile():
print '\nVariables:'
for v in mk.vars:
print ' %-30s = %s' % (v, mk.vars[v])
print '\nOptions:'
for o in mk.options.values():
print ' %-30s (default:%s,values:%s)' % (o.name, o.default, o.values)
print '\nConditions:'
for c in mk.conditions.values():
print ' %-30s (%s)' % (c.name,c.exprs)
print '\nConditional variables:'
for v in mk.cond_vars.values():
print ' %-30s' % v.name
for vv in v.values:
print ' if %-25s = %s' % (vv.cond.name, vv.value)
print '\nTargets:'
for t in mk.targets.values():
print ' %s %s' % (t.type, t.id)
for v in t.vars:
print ' %-28s = %s' % (v, t.vars[v])
for v in mk.vars:
if type(mk.vars[v]) is StringType:
mk.vars[v] = _repl(mk.vars[v])
for v in mk.make_vars:
mk.make_vars[v] = _repl(mk.make_vars[v])
for t in mk.targets.values():
for v in t.vars:
if type(t.vars[v]) is StringType:
t.vars[v] = _repl(t.vars[v])
for o in mk.options.values():
if o.default != None:
o.default = _repl(o.default)
if o.values != None:
o.values = [_repl(x) for x in o.values]
for c in mk.cond_vars.values():
for v in c.values:
v.value = _repl(v.value)
"""Removes unused conditions."""
if config.verbose:
sys.stdout.write('purging unused conditions')
sys.stdout.flush()
toDel = []
for c in mk.conditions:
cond = mk.conditions[c]
used = 0
for t in mk.targets.values():
if t.cond == cond:
used = 1
break
if used: continue
for cv in mk.cond_vars.values():
for v in cv.values:
if v.cond == cond:
used = 1
break
if used: break
if used: continue
toDel.append(c)
if config.verbose:
sys.stdout.write(': %i of %i\n' % (len(toDel), len(mk.cond_vars)))
for c in toDel:
del mk.conditions[c]
return len(toDel) > 0