Skip to content

Commit ec3678c

Browse files
committed
swift-api-digester: teach the tool to compare two SDKs directly
With module stability from the compiler, we can now use an earlier version of the SDK as the baseline and compare the new SDK with it. This patch adds a new -bsdk flag to the tool to specify the baseline SDK path.
1 parent 7933a9c commit ec3678c

File tree

12 files changed

+133
-21
lines changed

12 files changed

+133
-21
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#if !defined(__FOOSUB_H__)
2+
#define __FOOSUB_H__ 1
3+
4+
int fooSubFunc1(int a);
5+
6+
enum FooSubEnum1 {
7+
FooSubEnum1X,
8+
FooSubEnum1Y
9+
};
10+
11+
enum {
12+
FooSubUnnamedEnumeratorA1
13+
};
14+
15+
#endif /* ! __FOOSUB_H__ */
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* Foo.h
2+
Copyright (c) 1815, Napoleon Bonaparte. All rights reserved.
3+
*/
4+
#if !defined(__FOO_H__)
5+
#define __FOO_H__ 1
6+
7+
#import <FooSub/FooSub.h>
8+
9+
void removedFunction(void);
10+
11+
#endif /* ! __FOO_H__ */
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
framework module Foo {
2+
umbrella header "Foo.h"
3+
export *
4+
framework module FooSub {
5+
umbrella header "FooSub.h"
6+
export *
7+
}
8+
}
9+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Foo
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#if !defined(__FOOSUB_H__)
2+
#define __FOOSUB_H__ 1
3+
4+
int fooSubFunc1(int a);
5+
6+
enum FooSubEnum1 {
7+
FooSubEnum1X,
8+
FooSubEnum1Y
9+
};
10+
11+
enum {
12+
FooSubUnnamedEnumeratorA1
13+
};
14+
15+
#endif /* ! __FOOSUB_H__ */
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* Foo.h
2+
Copyright (c) 1815, Napoleon Bonaparte. All rights reserved.
3+
*/
4+
#if !defined(__FOO_H__)
5+
#define __FOO_H__ 1
6+
7+
#import <FooSub/FooSub.h>
8+
9+
#endif /* ! __FOO_H__ */
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
framework module Foo {
2+
umbrella header "Foo.h"
3+
export *
4+
framework module FooSub {
5+
umbrella header "FooSub.h"
6+
export *
7+
}
8+
}
9+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Foo(Foo.h): Func removedFunction() has been removed

test/api-digester/compare-dump-abi-parsable-interface.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
// RUN: %target-swift-frontend -typecheck -emit-parseable-module-interface-path %t.mod1/cake.swiftinterface %S/Inputs/cake_baseline/cake.swift -I %S/Inputs/APINotesLeft %clang-importer-sdk-nosource -parse-as-library -enable-library-evolution -disable-objc-attr-requires-foundation-module -module-cache-path %t.module-cache
77
// RUN: %target-swift-frontend -typecheck -emit-parseable-module-interface-path %t.mod2/cake.swiftinterface %S/Inputs/cake_current/cake.swift -I %S/Inputs/APINotesRight %clang-importer-sdk-nosource -parse-as-library -enable-library-evolution -disable-objc-attr-requires-foundation-module -module-cache-path %t.module-cache
8-
// RUN: %api-digester -diagnose-sdk -print-module -module cake -BI %t.mod1 -BI %S/Inputs/APINotesLeft -I %t.mod2 -I %S/Inputs/APINotesRight %clang-importer-sdk-nosource -module-cache-path %t.module-cache -o %t.result -abi
8+
// RUN: %api-digester -diagnose-sdk -print-module -module cake -BI %t.mod1 -BI %S/Inputs/APINotesLeft -I %t.mod2 -I %S/Inputs/APINotesRight -sdk %clang-importer-sdk-path -bsdk %clang-importer-sdk-path -module-cache-path %t.module-cache -o %t.result -abi
99

1010
// RUN: %clang -E -P -x c %S/Outputs/Cake-abi.txt -o - | sed '/^\s*$/d' > %t.expected
1111
// RUN: %clang -E -P -x c %t.result -o - | sed '/^\s*$/d' > %t.result.tmp
12-
// RUN: diff -u %t.expected %t.result.tmp
12+
// RUN: diff -u %t.expected %t.result.tmp

test/api-digester/compare-dump-parsable-interface.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
// RUN: %target-swift-frontend -typecheck -emit-parseable-module-interface-path %t.mod1/cake.swiftinterface %S/Inputs/cake_baseline/cake.swift -I %S/Inputs/APINotesLeft %clang-importer-sdk-nosource -parse-as-library -enable-library-evolution -disable-objc-attr-requires-foundation-module -module-cache-path %t.module-cache
77
// RUN: %target-swift-frontend -typecheck -emit-parseable-module-interface-path %t.mod2/cake.swiftinterface %S/Inputs/cake_current/cake.swift -I %S/Inputs/APINotesRight %clang-importer-sdk-nosource -parse-as-library -enable-library-evolution -disable-objc-attr-requires-foundation-module -module-cache-path %t.module-cache
8-
// RUN: %api-digester -diagnose-sdk -print-module -module cake -BI %t.mod1 -BI %S/Inputs/APINotesLeft -I %t.mod2 -I %S/Inputs/APINotesRight %clang-importer-sdk-nosource -module-cache-path %t.module-cache -o %t.result
8+
// RUN: %api-digester -diagnose-sdk -print-module -module cake -BI %t.mod1 -BI %S/Inputs/APINotesLeft -I %t.mod2 -I %S/Inputs/APINotesRight -sdk %clang-importer-sdk-path -bsdk %clang-importer-sdk-path -module-cache-path %t.module-cache -o %t.result
99

1010
// RUN: %clang -E -P -x c %S/Outputs/Cake.txt -o - | sed '/^\s*$/d' > %t.expected
1111
// RUN: %clang -E -P -x c %t.result -o - | sed '/^\s*$/d' > %t.result.tmp
12-
// RUN: diff -u %t.expected %t.result.tmp
12+
// RUN: diff -u %t.expected %t.result.tmp

0 commit comments

Comments
 (0)