[bootstrap] Extract dependency graph from manifest #187

Merged
merged 1 commit into from Mar 11, 2016

Conversation

Projects
None yet
3 participants
@mxcl
Contributor

mxcl commented Mar 10, 2016

Python is not my forte, so please improve.

/cc @ddunbar

@aciidb0mb3r

This comment has been minimized.

Show comment
Hide comment
@aciidb0mb3r

aciidb0mb3r Mar 10, 2016

Member

swiftpm is becoming the coolest kid in town

Member

aciidb0mb3r commented Mar 10, 2016

swiftpm is becoming the coolest kid in town

Utilities/bootstrap
@@ -179,24 +180,65 @@ class Target(object):
str(bool(self.is_library)).lower()), file=output)
print(file=output)
+def parse_manifest():

This comment has been minimized.

@ddunbar

ddunbar Mar 10, 2016

Member

A comment here that this is actually reading Swift might be nice.

I think a corresponding comment in our Package.swift that we do this here would be good.

@ddunbar

ddunbar Mar 10, 2016

Member

A comment here that this is actually reading Swift might be nice.

I think a corresponding comment in our Package.swift that we do this here would be good.

Utilities/bootstrap
+ if re.match(r'\s*\]\)', line): #TODO this is why we should do proper tokenization
+ break
+
+ if re.match(r'\s*Target\(', line):

This comment has been minimized.

@ddunbar

ddunbar Mar 10, 2016

Member

If we are going to do this, I would propose normalizing the Package.swift we have to be super-regular, so that the parsing logic can be very very strict. So for example if we required

/* BEGIN-TARGETS */
...
  Target(
     /* Comment */
     name: NAME,
     dependencies: [DEPS (even if empty)]
...
/* END-TARGETS */

then the parsing logic can become something like (no error handling):

data = open("Package.swift").read()

# Split on the begin/end target markets.
targetData, = re.match(r'/*BEGIN-TARGETS*/(.*)/*END-TARGETS*/', re.DOTALL|re.MULTILINE).groups()

# Iterate over each target -- we expect a very strict structure.
#
# FIXME: My re is no doubt wrong.
for (targetName, targetDeps) in re.finditer(targetData, r"Target\(\s*(/*.*?*/)?name: (.*?),\s*dependencies: (\[.*?\])\)", re.DOTALL|re.MULTILINE):
  # Cheat to get the deps list, because Python == Swift on the supported subset.
  targetDeps = eval(targetDeps)
  ... process this target and its deps ...

@ddunbar

ddunbar Mar 10, 2016

Member

If we are going to do this, I would propose normalizing the Package.swift we have to be super-regular, so that the parsing logic can be very very strict. So for example if we required

/* BEGIN-TARGETS */
...
  Target(
     /* Comment */
     name: NAME,
     dependencies: [DEPS (even if empty)]
...
/* END-TARGETS */

then the parsing logic can become something like (no error handling):

data = open("Package.swift").read()

# Split on the begin/end target markets.
targetData, = re.match(r'/*BEGIN-TARGETS*/(.*)/*END-TARGETS*/', re.DOTALL|re.MULTILINE).groups()

# Iterate over each target -- we expect a very strict structure.
#
# FIXME: My re is no doubt wrong.
for (targetName, targetDeps) in re.finditer(targetData, r"Target\(\s*(/*.*?*/)?name: (.*?),\s*dependencies: (\[.*?\])\)", re.DOTALL|re.MULTILINE):
  # Cheat to get the deps list, because Python == Swift on the supported subset.
  targetDeps = eval(targetDeps)
  ... process this target and its deps ...

This comment has been minimized.

@mxcl

mxcl Mar 10, 2016

Contributor

Good plan.

@mxcl

mxcl Mar 10, 2016

Contributor

Good plan.

This comment has been minimized.

@mxcl

mxcl Mar 10, 2016

Contributor

Also, nice trick with the eval. Didn't occur to me.

@mxcl

mxcl Mar 10, 2016

Contributor

Also, nice trick with the eval. Didn't occur to me.

@mxcl

This comment has been minimized.

Show comment
Hide comment
@mxcl

mxcl Mar 11, 2016

Contributor

@swift-ci Please test

Contributor

mxcl commented Mar 11, 2016

@swift-ci Please test

mxcl added a commit that referenced this pull request Mar 11, 2016

Merge pull request #187 from mxcl/parse_deps_in_bootstrap
[bootstrap] Extract dependency graph from manifest

@mxcl mxcl merged commit 1fe7638 into apple:master Mar 11, 2016

2 checks passed

Swift Test Linux Platform Build finished. 7995 tests run, 0 skipped, 0 failed.
Details
Swift Test OS X Platform Build finished. 32144 tests run, 0 skipped, 0 failed.
Details

@mxcl mxcl deleted the mxcl:parse_deps_in_bootstrap branch Mar 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment