Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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])
def __copyMkToVars():
dict = {}
# Copy variables:
for v in mk.vars:
if v == 'targets': continue
if type(mk.vars[v]) is StringType:
dict[v] = mk.vars[v].strip()
else:
dict[v] = mk.vars[v]
# Copy targets information:
targets = Container()
for tar in mk.targets.values():
t = Struct()
for v in tar.vars:
if v == 'configs':
t.configs = {}
for x in tar.vars[v]:
st = Struct()
t.configs[x] = st
for y in tar.vars[v][x]:
setattr(st, y, tar.vars[v][x][y].strip())
elif v == 'distinctConfigs':
t.distinctConfigs = tar.vars['distinctConfigs']
else:
if type(tar.vars[v]) is StringType:
setattr(t, v, tar.vars[v].strip())
else:
setattr(t, v, tar.vars[v])
def replaceEscapeSequences():
# Replace all occurences of $ with $:
def _repl(s):
return s.replace('$', '$')
if config.verbose:
print 'replacing escape sequences'
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)
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():
for v in interestingVars:
if v in t.vars and '$' in t.vars[v]:
list.append((t.vars,v,t))
else:
for t in mk.targets.values():
for v in t.vars:
if type(t.vars[v]) is StringType:
if '$' in t.vars[v]:
list.append((t.vars,v,t))
def iterateModifications(list):
while len(list) > 0:
newList = []
if config.verbose:
sys.stdout.write('[%i]' % len(list))
sys.stdout.flush()
for dict, obj, target in list:
if dict == None:
expr = obj.value
else:
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] = ''
for val in cv.values:
ok = 1
for e in val.cond.exprs:
if e.option.values == None and e.option.default != e.value:
ok = 0
break
if cfg[e.option.name] != e.value:
def purgeUnusedConditions():
"""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: