Skip to content

Commit e1a732a

Browse files
authored
[APIDiff] Improve API digester integration & polish of experimental-api-diff (#3485)
* [APIDiff] Parse serialized diagnostics from API digester to differentiate breaking changes from other diags * [APIDiff] Refactoring and documentation to make the diffing process easier to understand * [APIDiff] Diff and print results from one module at a time * [APIDiff] Improve test coverage * [APIDiff] Use per-module baselines * [APIDiff] Only diagnose API breakage in modules vended by library products * [APIDiff] Add a test case involving a C-family target * [APIDiff] Print a message if a module has no breaking changes * [APIDiff] Skip comparison of modules which aren't present in the baseline * [APIDiff] Refactor API digester tool to accept a BuildPlan instead of opaque args * [APIDiff] Remove an option-parsing hack that's no longer needed * [APIDiff] Improve failure diagnostics * [APIDiff] Remove an obsolete test * [APIDiff] Adapt to a TSC API change * [APIDiff] Rename SwiftAPIDigester.ComparisonResult.isSuccessful -> SwiftAPIDigester.ComparisonResult.hasNoAPIBreakingChanges * [APIDiff] Allow restricting the diff to specific products and/or targets * [APIDiff] Improve subcommand help * [APIDiff] Parallelize diff operation * [APIDiff] Parallelize baseline generation * [APIDiff] Clarify filtering options * [APIDiff] Control paralellism of api-digester invocations with -j * Update help text
1 parent 19fb0e1 commit e1a732a

File tree

22 files changed

+700
-126
lines changed

22 files changed

+700
-126
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// swift-tools-version:4.2
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "Bar",
6+
products: [
7+
.library(name: "Baz", targets: ["Baz"]),
8+
.library(name: "Qux", targets: ["Qux"]),
9+
],
10+
targets: [
11+
.target(name: "Baz"),
12+
.target(name: "Qux")
13+
]
14+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public func bar() -> Int {
2+
42
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public class Qux<T> { public let x = 1 }
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// swift-tools-version:4.2
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "CLibrarySources",
6+
products: [
7+
.library(name: "Lib", targets: ["Bar"])
8+
],
9+
targets: [
10+
.target(name: "Foo"),
11+
.target(name: "Bar", dependencies: ["Foo"])
12+
]
13+
)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Foo
2+
3+
public func bar() -> Int {
4+
foo()
5+
return 42
6+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "Foo.h"
2+
3+
int foo() {
4+
int a = 5;
5+
int b = a;
6+
a = b;
7+
return a;
8+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int foo();
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public func foo() {
2+
{}()
3+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// swift-tools-version:4.2
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "Foo",
6+
products: [
7+
.library(name: "Foo", targets: ["Foo"]),
8+
],
9+
targets: [
10+
.target(name: "Foo", path: "./"),
11+
]
12+
)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// swift-tools-version:4.2
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "NonAPILibraryTargets",
6+
products: [
7+
.library(name: "One", targets: ["Foo"]),
8+
.library(name: "Two", targets: ["Bar", "Baz"]),
9+
.executable(name: "Exec", targets: ["Exec", "Qux"])
10+
],
11+
targets: [
12+
.target(name: "Foo"),
13+
.target(name: "Bar", dependencies: ["Baz"]),
14+
.target(name: "Baz"),
15+
.target(name: "Qux"),
16+
.target(name: "Exec", dependencies: ["Qux"])
17+
]
18+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Baz
2+
3+
public func bar() -> Int {
4+
42
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public enum Baz {
2+
case a, c
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Qux
2+
3+
print("Hello, world!")
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public struct Foo {
2+
func doThing() {}
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public class Qux<T> { public let x = 1 }

Sources/Build/BuildPlan.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1919,14 +1919,7 @@ public class BuildPlan {
19191919
// Add search paths from the system library targets.
19201920
for target in graph.reachableTargets {
19211921
if let systemLib = target.underlyingTarget as? SystemLibraryTarget {
1922-
for flag in self.pkgConfig(for: systemLib).cFlags {
1923-
// The api-digester tool doesn't like `-I<Foo>` style for some reason.
1924-
if flag.hasPrefix("-I") && flag.count > 2 {
1925-
arguments += ["-I", String(flag.dropFirst(2))]
1926-
} else {
1927-
arguments.append(flag)
1928-
}
1929-
}
1922+
arguments.append(contentsOf: self.pkgConfig(for: systemLib).cFlags)
19301923
// Add the path to the module map.
19311924
arguments += ["-I", systemLib.moduleMapPath.parentDirectory.pathString]
19321925
}

0 commit comments

Comments
 (0)