Skip to content

[bootstrap] Update bootstrap utility to be Python 3 compatible #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Utilities/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ try:
except ImportError:
from io import StringIO
import argparse
import codecs
import errno
import json
import os
Expand Down Expand Up @@ -184,13 +185,13 @@ class Target(object):
def parse_manifest():
# we have a *very* strict format for our manifest to make parsing more robust
pattern = re.compile(r'Target\(.*?name: "(.*?)",\n *dependencies: (\[.*?\])\)', re.DOTALL|re.MULTILINE)
manifest_data = open(os.path.join(g_project_root, "Package.swift")).read()
manifest_data = codecs.open(os.path.join(g_project_root, "Package.swift"), encoding='utf-8', errors='strict').read()

def convert(match):
name = match.group(1)
deps = eval(match.group(2))
return Target(name, deps)
targets = map(convert, pattern.finditer(manifest_data))
targets = list(map(convert, pattern.finditer(manifest_data)))

# substitute strings for Target objects
for target in targets:
Expand All @@ -202,7 +203,7 @@ def parse_manifest():
b = Target(targetName)
targets.append(b)
return b
target.dependencies = map(convert, target.dependencies)
target.dependencies = list(map(convert, target.dependencies))

# fill dependency graph and set dependencies back to strings
def convert(target):
Expand All @@ -216,7 +217,7 @@ def parse_manifest():
return deps
# `reversed` because Linux link order must be reverse-topological
return Target(target.name, reversed(recurse(target)))
return map(convert, targets)
return list(map(convert, targets))

# Hard-coded target definition.
g_project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
Expand Down