mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +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
64 lines
2.9 KiB
Swift
64 lines
2.9 KiB
Swift
// REQUIRES: objc_interop, OS=macosx
|
|
// RUN: %empty-directory(%t)
|
|
// RUN: %empty-directory(%t/ModuleCache)
|
|
// RUN: %target-swift-frontend %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 %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
|
|
|
|
// Struct has no objc data.
|
|
@available(macOS 10.13, *)
|
|
public struct TestStruct {
|
|
public init() {}
|
|
|
|
@available(macOS 10.14, *)
|
|
public func testMethod() {}
|
|
}
|
|
|
|
// CHECK: {
|
|
// CHECK-NEXT: "target":
|
|
// CHECK-NEXT: "globals": [
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "name": "_$s8MyModule10TestStructV10testMethodyyF",
|
|
// CHECK-NEXT: "access": "public",
|
|
// CHECK-EXTRACT-NEXT: "file": "/@input/MyModule.swiftinterface",
|
|
// CHECK-EMIT-NEXT: "file": "SOURCE_DIR/test/APIJSON/struct.swift",
|
|
// CHECK-NEXT: "linkage": "exported",
|
|
// CHECK-NEXT: "introduced": "10.14"
|
|
// CHECK-NEXT: },
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "name": "_$s8MyModule10TestStructVACycfC",
|
|
// CHECK-NEXT: "access": "public",
|
|
// CHECK-EXTRACT-NEXT: "file": "/@input/MyModule.swiftinterface",
|
|
// CHECK-EMIT-NEXT: "file": "SOURCE_DIR/test/APIJSON/struct.swift",
|
|
// CHECK-NEXT: "linkage": "exported"
|
|
// CHECK-NEXT: },
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "name": "_$s8MyModule10TestStructVMa",
|
|
// CHECK-NEXT: "access": "public",
|
|
// CHECK-EXTRACT-NEXT: "file": "/@input/MyModule.swiftinterface",
|
|
// CHECK-EMIT-NEXT: "file": "SOURCE_DIR/test/APIJSON/struct.swift",
|
|
// CHECK-NEXT: "linkage": "exported",
|
|
// CHECK-NEXT: "introduced": "10.13"
|
|
// CHECK-NEXT: },
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "name": "_$s8MyModule10TestStructVMn",
|
|
// CHECK-NEXT: "access": "public",
|
|
// CHECK-EXTRACT-NEXT: "file": "/@input/MyModule.swiftinterface",
|
|
// CHECK-EMIT-NEXT: "file": "SOURCE_DIR/test/APIJSON/struct.swift",
|
|
// CHECK-NEXT: "linkage": "exported",
|
|
// CHECK-NEXT: "introduced": "10.13"
|
|
// CHECK-NEXT: },
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "name": "_$s8MyModule10TestStructVN",
|
|
// CHECK-NEXT: "access": "public",
|
|
// CHECK-EXTRACT-NEXT: "file": "/@input/MyModule.swiftinterface",
|
|
// CHECK-EMIT-NEXT: "file": "SOURCE_DIR/test/APIJSON/struct.swift",
|
|
// CHECK-NEXT: "linkage": "exported",
|
|
// CHECK-NEXT: "introduced": "10.13"
|
|
// CHECK-NEXT: }
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "interfaces": [],
|
|
// CHECK-NEXT: "categories": [],
|
|
// CHECK-NEXT: "version": "1.0"
|
|
// CHECK-NEXT: }
|