Skip to content

Commit a752b9b

Browse files
committed
Merge `pep8-update'
2 parents bd502ab + bb16e98 commit a752b9b

File tree

2 files changed

+49
-22
lines changed

2 files changed

+49
-22
lines changed

.pep8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[flake8]
22
filename = *.py,bootstrap
3-
ignore = E101,E111,E128,E265,E302,E402,E501,W191
3+
max-line-length = 80

Utilities/bootstrap

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,18 @@ import subprocess
4343
import sys
4444
import tempfile
4545

46-
###
4746

4847
def note(message):
4948
print("%s: note: %s" % (os.path.basename(sys.argv[0]), message))
5049
sys.stdout.flush()
5150

51+
5252
def error(message):
5353
print("%s: error: %s" % (os.path.basename(sys.argv[0]), message))
5454
sys.stdout.flush()
5555
raise SystemExit(1)
5656

57+
5758
def mkdir_p(path):
5859
"""
5960
mkdir_p(path)
@@ -68,6 +69,7 @@ def mkdir_p(path):
6869
if e.errno != errno.EEXIST:
6970
raise
7071

72+
7173
# FIXME: Consider eliminating this once the build task format supports node
7274
# hashing.
7375
def write_file_if_changed(path, data):
@@ -95,9 +97,12 @@ g_num_cpus = os.sysconf("SC_NPROCESSORS_ONLN")
9597
g_default_sysroot = None
9698
if platform.system() == 'Darwin':
9799
g_platform_path = subprocess.check_output(
98-
["xcrun", "--sdk", "macosx", "--show-sdk-platform-path"], universal_newlines=True).strip()
100+
["xcrun", "--sdk", "macosx", "--show-sdk-platform-path"],
101+
universal_newlines=True).strip()
99102
g_default_sysroot = subprocess.check_output(
100-
["xcrun", "--sdk", "macosx", "--show-sdk-path"], universal_newlines=True).strip()
103+
["xcrun", "--sdk", "macosx", "--show-sdk-path"],
104+
universal_newlines=True).strip()
105+
101106

102107
class Target(object):
103108
@property
@@ -169,23 +174,28 @@ class Target(object):
169174
print(" outputs: %s" % json.dumps(
170175
[compile_swift_node, module_path] + swift_objects), file=output)
171176
print(" module-name: %s" % json.dumps(module_name), file=output)
172-
print(" module-output-path: %s" % json.dumps(module_path), file=output)
173-
print(" sources: %s" % json.dumps(
174-
self.swift_sources), file=output)
177+
print(" module-output-path: %s" % json.dumps(module_path),
178+
file=output)
179+
print(" sources: %s" % json.dumps(self.swift_sources), file=output)
175180
print(" objects: %s" % json.dumps(swift_objects), file=output)
176181
print(" import-paths: %s" % json.dumps(
177182
[module_dir]), file=output)
178-
print(" other-args: %s" % json.dumps(' '.join(other_args)), file=output)
183+
print(" other-args: %s" % json.dumps(' '.join(other_args)),
184+
file=output)
179185
print(" temps-path: %s" % json.dumps(target_build_dir), file=output)
180186
print(" is-library: %s" % json.dumps(
181187
str(bool(self.is_library)).lower()), file=output)
182188
print(file=output)
183189

190+
184191
# currently only returns the targets parsed from the manifest
185192
def parse_manifest():
186-
# we have a *very* strict format for our manifest to make parsing more robust
187-
pattern = re.compile(r'Target\(.*?name: "(.*?)",\n *dependencies: (\[.*?\])\)', re.DOTALL|re.MULTILINE)
188-
manifest_data = codecs.open(os.path.join(g_project_root, "Package.swift"), encoding='utf-8', errors='strict').read()
193+
# we have a *very* strict format for our manifest to make parsing more
194+
# robust
195+
pattern = re.compile(
196+
r'Target\(.*?name: "(.*?)",\n *dependencies: (\[.*?\])\)',
197+
re.DOTALL | re.MULTILINE)
198+
manifest_data = open(os.path.join(g_project_root, "Package.swift"), encoding='utf-8', errors='strict').read()
189199

190200
def convert(match):
191201
name = match.group(1)
@@ -199,7 +209,8 @@ def parse_manifest():
199209
try:
200210
return next(a for a in targets if a.name == targetName)
201211
except StopIteration:
202-
# this target is not explicit in the manifest: it is an implicit target
212+
# this target is not explicit in the manifest: it is an
213+
# implicit target
203214
b = Target(targetName)
204215
targets.append(b)
205216
return b
@@ -208,6 +219,7 @@ def parse_manifest():
208219
# fill dependency graph and set dependencies back to strings
209220
def convert(target):
210221
myset = set()
222+
211223
def recurse(root):
212224
deps = []
213225
for dep in root.dependencies:
@@ -225,6 +237,7 @@ g_source_root = os.path.join(g_project_root, "Sources")
225237
targets = parse_manifest()
226238
target_map = dict((t.name, t) for t in targets)
227239

240+
228241
def create_bootstrap_files(sandbox_path, args):
229242
# Write out the build file.
230243
output = StringIO()
@@ -285,7 +298,8 @@ def create_bootstrap_files(sandbox_path, args):
285298
print(" %s:" % json.dumps(predecessor_node), file=output)
286299
print(" tool: phony", file=output)
287300
print(" inputs: %s" % json.dumps(
288-
[target_map[name].virtual_node for name in target.dependencies]), file=output)
301+
[target_map[name].virtual_node for name in target.dependencies]),
302+
file=output)
289303
print(" outputs: %s" % json.dumps([predecessor_node]), file=output)
290304
print(file=output)
291305

@@ -308,7 +322,8 @@ def create_bootstrap_files(sandbox_path, args):
308322
else:
309323
link_output_path = os.path.join(bin_dir, target.name)
310324

311-
link_command = [args.swiftc_path, '-o', pipes.quote(link_output_path)]
325+
link_command = [args.swiftc_path,
326+
'-o', pipes.quote(link_output_path)]
312327
if args.sysroot:
313328
link_command.extend(["-sdk", args.sysroot])
314329
if platform.system() == 'Darwin':
@@ -326,7 +341,10 @@ def create_bootstrap_files(sandbox_path, args):
326341
# Write out the link command.
327342
print(" %s:" % json.dumps(target.linked_virtual_node), file=output)
328343
print(" tool: shell", file=output)
329-
print(" description: Link %s" % (target.name if target.is_library else link_output_path,), file=output)
344+
if target.is_library:
345+
print(" description: Link %s" % target.name, file=output)
346+
else:
347+
print(" description: Link %s" % link_output_path, file=output)
330348
print(" inputs: %s" % json.dumps(
331349
link_input_nodes + objects + linked_libraries), file=output)
332350
print(" outputs: %s" % json.dumps(
@@ -339,13 +357,15 @@ def create_bootstrap_files(sandbox_path, args):
339357
print(" tool: phony", file=output)
340358
print(" inputs: %s" % json.dumps(
341359
[target.linked_virtual_node]), file=output)
342-
print(" outputs: %s" % json.dumps([target.virtual_node]), file=output)
360+
print(" outputs: %s" % json.dumps([target.virtual_node]),
361+
file=output)
343362
print(file=output)
344363

345364
# Write the output file.
346365
write_file_if_changed(os.path.join(sandbox_path, "build.swift-build"),
347366
output.getvalue())
348367

368+
349369
def process_runtime_libraries(build_path, args, bootstrap=False):
350370
if bootstrap:
351371
module_input_path = os.path.join(
@@ -392,7 +412,8 @@ def process_runtime_libraries(build_path, args, bootstrap=False):
392412
# error.
393413
tf = tempfile.NamedTemporaryFile(suffix=".swift")
394414
cmds = subprocess.check_output(
395-
cmd + [tf.name, "-###"], universal_newlines=True).strip().split("\n")
415+
cmd + [tf.name, "-###"],
416+
universal_newlines=True).strip().split("\n")
396417

397418
# Get the link command 'swiftc' used.
398419
link_cmd = shlex.split(cmds[-1])
@@ -409,10 +430,12 @@ def process_runtime_libraries(build_path, args, bootstrap=False):
409430
raise SystemExit("unable to understand 'swiftc' driver commands")
410431
del link_cmd[idx - 1]
411432
cmd = [arg for arg in link_cmd
412-
if arg.endswith("swift_begin.o") or arg.endswith("swift_end.o") or (not arg.endswith(".o") and not arg.endswith(".autolink"))]
433+
if arg.endswith(("swift_begin.o", "swift_end.o")) or
434+
(not arg.endswith((".o", ".autolink")))]
413435
subprocess.check_call(cmd)
414436
return (runtime_module_path, runtime_lib_path)
415437

438+
416439
def get_swift_build_tool_path():
417440
# Search for a 'swift-build-tool' to use.
418441

@@ -429,7 +452,8 @@ def get_swift_build_tool_path():
429452

430453
# Next, search for it in PATH.
431454
try:
432-
return subprocess.check_output(["which", "swift-build-tool"], universal_newlines=True).strip()
455+
return subprocess.check_output(["which", "swift-build-tool"],
456+
universal_newlines=True).strip()
433457
except:
434458
pass
435459

@@ -447,6 +471,7 @@ def get_swift_build_tool_path():
447471
# If all else failed, report an error.
448472
error("unable to find 'swift-build-tool' tool for bootstrap build")
449473

474+
450475
def main():
451476
parser = argparse.ArgumentParser(
452477
usage="%(prog)s [options] [clean|all|test|install]",
@@ -518,9 +543,11 @@ def main():
518543
args.sbt_path = os.path.abspath(
519544
args.sbt_path or get_swift_build_tool_path())
520545

521-
# Due to bug in Xcode where SWIFT_EXEC is not set correctly by downloadable toolchain
546+
# Due to bug in Xcode where SWIFT_EXEC is not set correctly by downloadable
547+
# toolchain
522548
if os.getenv("XCODE_DEFAULT_TOOLCHAIN_OVERRIDE"):
523-
args.swiftc = os.path.join(os.getenv("XCODE_DEFAULT_TOOLCHAIN_OVERRIDE"), "usr/bin/swiftc")
549+
args.swiftc = os.path.join(
550+
os.getenv("XCODE_DEFAULT_TOOLCHAIN_OVERRIDE"), "usr/bin/swiftc")
524551

525552
# Create or update the bootstrap files.
526553
create_bootstrap_files(sandbox_path, args)
@@ -562,7 +589,7 @@ def main():
562589
if args.sysroot:
563590
env_cmd.append("SYSROOT=" + args.sysroot)
564591

565-
# We need to embed an RPATH so swift-{build,test} can find the core
592+
# We need to embed an RPATH so swift-{build,test} can find the core
566593
# libraries.
567594
if platform.system() == 'Linux':
568595
embed_rpath = "$ORIGIN/../lib/swift/linux"

0 commit comments

Comments
 (0)