mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Make the changes to APIGenRecorder that are necessary to make it capable of emitting API descriptors during -emit-module jobs. The output in this mode differs from the output when run on an existing module in a couple of important ways: - The value for the `file` key in the descriptor JSON is now the path to the source file that defines the declaration responsible for the symbol. In `swift-api-extract` mode, the value for this key is the path to the module or swiftinterface which is unavailable during an -emit-module job since the module is usually not being emitted to its final installed location. - Some additional symbols may be included in the API descriptor JSON because more of the AST is available when emitting the module. Resolves rdar://110916764
107 lines
4.3 KiB
Swift
107 lines
4.3 KiB
Swift
// REQUIRES: objc_interop, OS=macosx
|
|
// RUN: %empty-directory(%t)
|
|
// RUN: %empty-directory(%t/ModuleCache)
|
|
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) %s -typecheck -parse-as-library -emit-module-interface-path %t/MyModule.swiftinterface -enable-library-evolution -module-name MyModule -swift-version 5
|
|
// RUN: %target-swift-api-extract -o - -pretty-print %t/MyModule.swiftinterface -module-name MyModule -module-cache-path %t/ModuleCache | %FileCheck %s -check-prefixes=CHECK,CHECK-EXTRACT
|
|
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource -I %t) %s -typecheck -parse-as-library -emit-module-interface-path %t/MyModule.swiftinterface -enable-library-evolution -module-name MyModule -swift-version 5 -emit-api-descriptor-path - | %FileCheck %s --check-prefixes=CHECK,CHECK-EMIT
|
|
|
|
import Foundation
|
|
|
|
// Need objc data for objc compatible methods.
|
|
public class NonObjC {
|
|
@objc public init() {}
|
|
@objc public func testMethod() {}
|
|
}
|
|
|
|
public class NonObjC1 {
|
|
@objc public func testMethod() {}
|
|
}
|
|
|
|
public class NonObjC2 {
|
|
@objc public func testMethod() {}
|
|
public init() {}
|
|
}
|
|
|
|
public class NonObjC3 {
|
|
@objc public init() {}
|
|
public init(fromInt: Int) {}
|
|
}
|
|
|
|
// CHECK: "interfaces": [
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "name": "_TtC8MyModule7NonObjC",
|
|
// CHECK-NEXT: "access": "public",
|
|
// CHECK-EXTRACT-NEXT: "file": "/@input/MyModule.swiftinterface",
|
|
// CHECK-EMIT-NEXT: "file": "SOURCE_DIR/test/APIJSON/non-objc-class.swift",
|
|
// CHECK-NEXT: "linkage": "internal",
|
|
// CHECK-NEXT: "super": "",
|
|
// CHECK-NEXT: "instanceMethods": [
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "name": "init",
|
|
// CHECK-NEXT: "access": "public",
|
|
// CHECK-EXTRACT-NEXT: "file": "/@input/MyModule.swiftinterface"
|
|
// CHECK-EMIT-NEXT: "file": "SOURCE_DIR/test/APIJSON/non-objc-class.swift"
|
|
// CHECK-NEXT: },
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "name": "testMethod",
|
|
// CHECK-NEXT: "access": "public",
|
|
// CHECK-EXTRACT-NEXT: "file": "/@input/MyModule.swiftinterface"
|
|
// CHECK-EMIT-NEXT: "file": "SOURCE_DIR/test/APIJSON/non-objc-class.swift"
|
|
// CHECK-NEXT: }
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "classMethods": []
|
|
// CHECK-NEXT: },
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "name": "_TtC8MyModule8NonObjC1",
|
|
// CHECK-NEXT: "access": "public",
|
|
// CHECK-EXTRACT-NEXT: "file": "/@input/MyModule.swiftinterface",
|
|
// CHECK-EMIT-NEXT: "file": "SOURCE_DIR/test/APIJSON/non-objc-class.swift",
|
|
// CHECK-NEXT: "linkage": "internal",
|
|
// CHECK-NEXT: "super": "",
|
|
// CHECK-NEXT: "instanceMethods": [
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "name": "testMethod",
|
|
// CHECK-NEXT: "access": "public",
|
|
// CHECK-EXTRACT-NEXT: "file": "/@input/MyModule.swiftinterface"
|
|
// CHECK-EMIT-NEXT: "file": "SOURCE_DIR/test/APIJSON/non-objc-class.swift"
|
|
// CHECK-NEXT: }
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "classMethods": []
|
|
// CHECK-NEXT: },
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "name": "_TtC8MyModule8NonObjC2",
|
|
// CHECK-NEXT: "access": "public",
|
|
// CHECK-EXTRACT-NEXT: "file": "/@input/MyModule.swiftinterface",
|
|
// CHECK-EMIT-NEXT: "file": "SOURCE_DIR/test/APIJSON/non-objc-class.swift",
|
|
// CHECK-NEXT: "linkage": "internal",
|
|
// CHECK-NEXT: "super": "",
|
|
// CHECK-NEXT: "instanceMethods": [
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "name": "testMethod",
|
|
// CHECK-NEXT: "access": "public",
|
|
// CHECK-EXTRACT-NEXT: "file": "/@input/MyModule.swiftinterface"
|
|
// CHECK-EMIT-NEXT: "file": "SOURCE_DIR/test/APIJSON/non-objc-class.swift"
|
|
// CHECK-NEXT: }
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "classMethods": []
|
|
// CHECK-NEXT: },
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "name": "_TtC8MyModule8NonObjC3",
|
|
// CHECK-NEXT: "access": "public",
|
|
// CHECK-EXTRACT-NEXT: "file": "/@input/MyModule.swiftinterface",
|
|
// CHECK-EMIT-NEXT: "file": "SOURCE_DIR/test/APIJSON/non-objc-class.swift",
|
|
// CHECK-NEXT: "linkage": "internal",
|
|
// CHECK-NEXT: "super": "",
|
|
// CHECK-NEXT: "instanceMethods": [
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "name": "init",
|
|
// CHECK-NEXT: "access": "public",
|
|
// CHECK-EXTRACT-NEXT: "file": "/@input/MyModule.swiftinterface"
|
|
// CHECK-EMIT-NEXT: "file": "SOURCE_DIR/test/APIJSON/non-objc-class.swift"
|
|
// CHECK-NEXT: }
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "classMethods": []
|
|
// CHECK-NEXT: }
|
|
// CHECK-NEXT: ]
|
|
|