Fix PEP8 style issues in bootstrap code
This commit is contained in:
parent
650b1b1f3a
commit
a263a78b28
2 changed files with 32 additions and 17 deletions
|
@ -302,6 +302,7 @@ def default_build_triple():
|
||||||
|
|
||||||
return "{}-{}".format(cputype, ostype)
|
return "{}-{}".format(cputype, ostype)
|
||||||
|
|
||||||
|
|
||||||
class RustBuild(object):
|
class RustBuild(object):
|
||||||
"""Provide all the methods required to build Rust"""
|
"""Provide all the methods required to build Rust"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -19,6 +19,7 @@ rust_dir = os.path.dirname(rust_dir)
|
||||||
sys.path.append(os.path.join(rust_dir, "src", "bootstrap"))
|
sys.path.append(os.path.join(rust_dir, "src", "bootstrap"))
|
||||||
import bootstrap
|
import bootstrap
|
||||||
|
|
||||||
|
|
||||||
class Option:
|
class Option:
|
||||||
def __init__(self, name, rustbuild, desc, value):
|
def __init__(self, name, rustbuild, desc, value):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
@ -26,14 +27,18 @@ class Option:
|
||||||
self.desc = desc
|
self.desc = desc
|
||||||
self.value = value
|
self.value = value
|
||||||
|
|
||||||
|
|
||||||
options = []
|
options = []
|
||||||
|
|
||||||
|
|
||||||
def o(*args):
|
def o(*args):
|
||||||
options.append(Option(*args, value=False))
|
options.append(Option(*args, value=False))
|
||||||
|
|
||||||
|
|
||||||
def v(*args):
|
def v(*args):
|
||||||
options.append(Option(*args, value=True))
|
options.append(Option(*args, value=True))
|
||||||
|
|
||||||
|
|
||||||
o("debug", "rust.debug", "debug mode; disables optimization unless `--enable-optimize` given")
|
o("debug", "rust.debug", "debug mode; disables optimization unless `--enable-optimize` given")
|
||||||
o("docs", "build.docs", "build standard library documentation")
|
o("docs", "build.docs", "build standard library documentation")
|
||||||
o("compiler-docs", "build.compiler-docs", "build compiler documentation")
|
o("compiler-docs", "build.compiler-docs", "build compiler documentation")
|
||||||
|
@ -136,13 +141,16 @@ v("target", None, "GNUs ./configure syntax LLVM target triples")
|
||||||
|
|
||||||
v("set", None, "set arbitrary key/value pairs in TOML configuration")
|
v("set", None, "set arbitrary key/value pairs in TOML configuration")
|
||||||
|
|
||||||
|
|
||||||
def p(msg):
|
def p(msg):
|
||||||
print("configure: " + msg)
|
print("configure: " + msg)
|
||||||
|
|
||||||
|
|
||||||
def err(msg):
|
def err(msg):
|
||||||
print("configure: error: " + msg)
|
print("configure: error: " + msg)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
if '--help' in sys.argv or '-h' in sys.argv:
|
if '--help' in sys.argv or '-h' in sys.argv:
|
||||||
print('Usage: ./configure [options]')
|
print('Usage: ./configure [options]')
|
||||||
print('')
|
print('')
|
||||||
|
@ -208,7 +216,7 @@ while i < len(sys.argv):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
found = True
|
found = True
|
||||||
if not option.name in known_args:
|
if option.name not in known_args:
|
||||||
known_args[option.name] = []
|
known_args[option.name] = []
|
||||||
known_args[option.name].append((option, value))
|
known_args[option.name].append((option, value))
|
||||||
break
|
break
|
||||||
|
@ -227,11 +235,13 @@ if 'option-checking' not in known_args or known_args['option-checking'][1]:
|
||||||
# TOML we're going to write out
|
# TOML we're going to write out
|
||||||
config = {}
|
config = {}
|
||||||
|
|
||||||
|
|
||||||
def build():
|
def build():
|
||||||
if 'build' in known_args:
|
if 'build' in known_args:
|
||||||
return known_args['build'][0][1]
|
return known_args['build'][0][1]
|
||||||
return bootstrap.default_build_triple()
|
return bootstrap.default_build_triple()
|
||||||
|
|
||||||
|
|
||||||
def set(key, value):
|
def set(key, value):
|
||||||
s = "{:20} := {}".format(key, value)
|
s = "{:20} := {}".format(key, value)
|
||||||
if len(s) < 70:
|
if len(s) < 70:
|
||||||
|
@ -245,10 +255,11 @@ def set(key, value):
|
||||||
if i == len(parts) - 1:
|
if i == len(parts) - 1:
|
||||||
arr[part] = value
|
arr[part] = value
|
||||||
else:
|
else:
|
||||||
if not part in arr:
|
if part not in arr:
|
||||||
arr[part] = {}
|
arr[part] = {}
|
||||||
arr = arr[part]
|
arr = arr[part]
|
||||||
|
|
||||||
|
|
||||||
for key in known_args:
|
for key in known_args:
|
||||||
# The `set` option is special and can be passed a bunch of times
|
# The `set` option is special and can be passed a bunch of times
|
||||||
if key == 'set':
|
if key == 'set':
|
||||||
|
@ -345,6 +356,7 @@ for target in configured_targets:
|
||||||
targets[target] = sections['target'][:]
|
targets[target] = sections['target'][:]
|
||||||
targets[target][0] = targets[target][0].replace("x86_64-unknown-linux-gnu", target)
|
targets[target][0] = targets[target][0].replace("x86_64-unknown-linux-gnu", target)
|
||||||
|
|
||||||
|
|
||||||
# Here we walk through the constructed configuration we have from the parsed
|
# Here we walk through the constructed configuration we have from the parsed
|
||||||
# command line arguemnts. We then apply each piece of configuration by
|
# command line arguemnts. We then apply each piece of configuration by
|
||||||
# basically just doing a `sed` to change the various configuration line to what
|
# basically just doing a `sed` to change the various configuration line to what
|
||||||
|
@ -362,6 +374,7 @@ def to_toml(value):
|
||||||
else:
|
else:
|
||||||
raise 'no toml'
|
raise 'no toml'
|
||||||
|
|
||||||
|
|
||||||
def configure_section(lines, config):
|
def configure_section(lines, config):
|
||||||
for key in config:
|
for key in config:
|
||||||
value = config[key]
|
value = config[key]
|
||||||
|
@ -375,9 +388,10 @@ def configure_section(lines, config):
|
||||||
if not found:
|
if not found:
|
||||||
raise RuntimeError("failed to find config line for {}".format(key))
|
raise RuntimeError("failed to find config line for {}".format(key))
|
||||||
|
|
||||||
|
|
||||||
for section_key in config:
|
for section_key in config:
|
||||||
section_config = config[section_key]
|
section_config = config[section_key]
|
||||||
if not section_key in sections:
|
if section_key not in sections:
|
||||||
raise RuntimeError("config key {} not in sections".format(key))
|
raise RuntimeError("config key {} not in sections".format(key))
|
||||||
|
|
||||||
if section_key == 'target':
|
if section_key == 'target':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue