Skip to content
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

[6.0][Package/ModuleGraph] Allow cyclic package dependencies if they don't introduce a cycle in a build graph #7541

Merged
merged 1 commit into from
May 30, 2024

Conversation

xedin
Copy link
Member

@xedin xedin commented May 8, 2024

  • Explanation:

    It should be possible for packages to depend on each other if such
    dependence doesn't introduce cycles in the build graph.

    • Introduced a new DFS method to walk over graphs that breaks cycles.
    • Replaces use of findCycle + topologicalSort with DFS while
      building manifest and package graphs. This allows cycles in dependencies
      to be modeled correctly.
    • Removes some of the redundant data transformations from modules graph.
    • Modifies ResolvedPackage to carry identities of its dependencies
      instead of resolved dependencies themselves. This helps to simplify
      logic in createResolvedPackages.
    • Adds detection of target cycles across packages.

    Makes it possible for package A to depend on package B and B to depend
    on A if their targets don't form a cycle.

  • Scope: Package graph

  • Main Branch PRs: [Package/ModuleGraph] Allow cyclic package dependencies if they don't introduce a cycle in a build graph #7530

  • Risk: Low

  • Reviewed By: @MaxDesiatov

  • Testing: Added new test-cases to the test suite

@xedin
Copy link
Member Author

xedin commented May 8, 2024

apple/sourcekit-lsp#1248
@swift-ci please test

… introduce a cycle in a build graph (apple#7530)

It should be possible for packages to depend on each other if such
dependence doesn't introduce cycles in the build graph.

- Introduced a new DFS method to walk over graphs that breaks cycles.
- Replaces use of `findCycle` + `topologicalSort` with `DFS` while
building manifest and package graphs. This allows cycles in dependencies
to be modeled correctly.
- Removes some of the redundant data transformations from modules graph.
- Modifies `ResolvedPackage` to carry identities of its dependencies
instead of resolved dependencies themselves. This helps to simplify
logic in `createResolvedPackages`.
- Adds detection of target cycles across packages.

Makes it possible for package A to depend on package B and B to depend
on A if their targets don't form a cycle.

(cherry picked from commit 8b12909)
@xedin xedin force-pushed the allow-dependency-cycles-6.0 branch from 6246c3a to 550650b Compare May 29, 2024 22:52
@xedin
Copy link
Member Author

xedin commented May 29, 2024

apple/sourcekit-lsp#1248
@swift-ci please test

@xedin xedin merged commit aaeecec into apple:release/6.0 May 30, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package graph swift 6.0 Related to Swift 6.0 release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants