Skip to content

[APIDiff] Improve API digester integration & polish of experimental-api-diff #3485

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 22 commits into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
fd3e92d
[APIDiff] Parse serialized diagnostics from API digester to different…
owenv May 8, 2021
8d6b0f6
[APIDiff] Refactoring and documentation to make the diffing process e…
owenv May 8, 2021
80b8864
[APIDiff] Diff and print results from one module at a time
owenv May 8, 2021
1f5a34b
[APIDiff] Improve test coverage
owenv May 8, 2021
125818f
[APIDiff] Use per-module baselines
owenv May 8, 2021
ba89eaa
[APIDiff] Only diagnose API breakage in modules vended by library pro…
owenv May 8, 2021
3a421a4
[APIDiff] Add a test case involving a C-family target
owenv May 8, 2021
5c1e2db
[APIDiff] Print a message if a module has no breaking changes
owenv May 8, 2021
fbeb00a
[APIDiff] Skip comparison of modules which aren't present in the base…
owenv May 8, 2021
1407c66
[APIDiff] Refactor API digester tool to accept a BuildPlan instead of…
owenv May 8, 2021
7bbf999
[APIDiff] Remove an option-parsing hack that's no longer needed
owenv May 8, 2021
3557105
[APIDiff] Improve failure diagnostics
owenv May 8, 2021
5415614
[APIDiff] Remove an obsolete test
owenv May 8, 2021
2738aa0
[APIDiff] Adapt to a TSC API change
owenv May 9, 2021
2457b7d
[APIDiff] Rename SwiftAPIDigester.ComparisonResult.isSuccessful -> Sw…
owenv May 16, 2021
81b4d2d
[APIDiff] Allow restricting the diff to specific products and/or targets
owenv May 22, 2021
59f13f9
[APIDiff] Improve subcommand help
owenv May 22, 2021
cd88df0
[APIDiff] Parallelize diff operation
owenv May 22, 2021
3f07326
[APIDiff] Parallelize baseline generation
owenv May 22, 2021
e45725d
[APIDiff] Clarify filtering options
owenv May 26, 2021
9167479
[APIDiff] Control paralellism of api-digester invocations with -j
owenv May 26, 2021
cc0bdf4
Update help text
owenv May 26, 2021
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
14 changes: 14 additions & 0 deletions Fixtures/Miscellaneous/APIDiff/Bar/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// swift-tools-version:4.2
import PackageDescription

let package = Package(
name: "Bar",
products: [
.library(name: "Baz", targets: ["Baz"]),
.library(name: "Qux", targets: ["Qux"]),
],
targets: [
.target(name: "Baz"),
.target(name: "Qux")
]
)
3 changes: 3 additions & 0 deletions Fixtures/Miscellaneous/APIDiff/Bar/Sources/Baz/Baz.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public func bar() -> Int {
42
}
1 change: 1 addition & 0 deletions Fixtures/Miscellaneous/APIDiff/Bar/Sources/Qux/Qux.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public class Qux<T> { public let x = 1 }
13 changes: 13 additions & 0 deletions Fixtures/Miscellaneous/APIDiff/CTargetDep/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// swift-tools-version:4.2
import PackageDescription

let package = Package(
name: "CLibrarySources",
products: [
.library(name: "Lib", targets: ["Bar"])
],
targets: [
.target(name: "Foo"),
.target(name: "Bar", dependencies: ["Foo"])
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Foo

public func bar() -> Int {
foo()
return 42
}
8 changes: 8 additions & 0 deletions Fixtures/Miscellaneous/APIDiff/CTargetDep/Sources/Foo/Foo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "Foo.h"

int foo() {
int a = 5;
int b = a;
a = b;
return a;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int foo();
3 changes: 3 additions & 0 deletions Fixtures/Miscellaneous/APIDiff/Foo/Foo.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public func foo() {
{}()
}
12 changes: 12 additions & 0 deletions Fixtures/Miscellaneous/APIDiff/Foo/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// swift-tools-version:4.2
import PackageDescription

let package = Package(
name: "Foo",
products: [
.library(name: "Foo", targets: ["Foo"]),
],
targets: [
.target(name: "Foo", path: "./"),
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// swift-tools-version:4.2
import PackageDescription

let package = Package(
name: "NonAPILibraryTargets",
products: [
.library(name: "One", targets: ["Foo"]),
.library(name: "Two", targets: ["Bar", "Baz"]),
.executable(name: "Exec", targets: ["Exec", "Qux"])
],
targets: [
.target(name: "Foo"),
.target(name: "Bar", dependencies: ["Baz"]),
.target(name: "Baz"),
.target(name: "Qux"),
.target(name: "Exec", dependencies: ["Qux"])
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Baz

public func bar() -> Int {
42
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public enum Baz {
case a, c
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Qux

print("Hello, world!")
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public struct Foo {
func doThing() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public class Qux<T> { public let x = 1 }
9 changes: 1 addition & 8 deletions Sources/Build/BuildPlan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1919,14 +1919,7 @@ public class BuildPlan {
// Add search paths from the system library targets.
for target in graph.reachableTargets {
if let systemLib = target.underlyingTarget as? SystemLibraryTarget {
for flag in self.pkgConfig(for: systemLib).cFlags {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these changes unnecessary now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, as of swiftlang/swift#37206 this is unnecessary because the API digester and compiler are using the same option definitions

// The api-digester tool doesn't like `-I<Foo>` style for some reason.
if flag.hasPrefix("-I") && flag.count > 2 {
arguments += ["-I", String(flag.dropFirst(2))]
} else {
arguments.append(flag)
}
}
arguments.append(contentsOf: self.pkgConfig(for: systemLib).cFlags)
// Add the path to the module map.
arguments += ["-I", systemLib.moduleMapPath.parentDirectory.pathString]
}
Expand Down
Loading