mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This mode is similar to `swift-symbolgraph-extract`; it takes a subset of compiler flags to configure the invocation for module loading, as well as a module name whose contents should be extracted. It does not take any other input files. The output is a single text file specified by `-o` (or `stdout` if not specified). While the most common use case for this would be viewing the synthesized Swift interface for a Clang module, since the implementation simply calls `swift::ide::printModuleInterface` under the hood, it's usable for any module that Swift can import. Thus, it could also be used to view a synthesized textual representation of, say, a compiled `.swiftmodule`. One could imagine that in the future, we might add more flags to `swift-synthesize-interface` to modify various `PrintOptions` used when generating the output, if we think those would be useful.
24 lines
695 B
Swift
24 lines
695 B
Swift
// Emit the Swift module.
|
|
// RUN: %empty-directory(%t)
|
|
// RUN: %target-swift-frontend -emit-module -module-name MyModule -o %t/MyModule.swiftmodule %s
|
|
|
|
// Invoke the frontend with the module on the import path.
|
|
// RUN: %target-swift-synthesize-interface -module-name MyModule -I %t -o - | %FileCheck %s
|
|
|
|
public struct MyStruct {
|
|
// CHECK: public struct MyStruct {
|
|
public private(set) var value: Int
|
|
// CHECK-DAG: public private(set) var value: Int { get }
|
|
|
|
public init(value: Int = 0) {
|
|
// CHECK-DAG: public init(value: Int = 0)
|
|
self.value = value
|
|
}
|
|
|
|
public func printValue() {
|
|
// CHECK-DAG: public func printValue()
|
|
print(self.value)
|
|
}
|
|
}
|
|
// CHECK-DAG: }
|