mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Improve swift dependency scanner by validating and selecting dependency module into scanner. This provides benefits that: * Build system does not need to schedule interface compilation task if the candidate module is picked, it can just use the candidate module directly. * There is no need for forwarding module in the explicit module build. Since the build system is coordinating the build, there is no need for the forwarding module in the module cache to avoid duplicated work, * This also correctly supports all the module loading modes in the dependency scanner. This is achieved by only adding validate and up-to-date binary module as the candidate module for swift interface module dependency. This allows caching build to construct the correct dependency in the CAS. If there is a candidate module for the interface module, dependency scanner will return a binary module dependency in the dependency graph. The legacy behavior is mostly preserved with a hidden frontend flag `-no-scanner-module-validation`, while the scanner output is mostly interchangeable with new scanner behavior with `prefer-interface` module loading mode except the candidate module will not be returned. rdar://123711823
51 lines
2.3 KiB
Swift
51 lines
2.3 KiB
Swift
/// Test -scan-dependencies module aliasing.
|
|
///
|
|
/// Module 'Lib' imports module 'XLogging' via module aliasing and with various import attributes.
|
|
/// Module 'User' imports 'Lib'.
|
|
|
|
// RUN: %empty-directory(%t)
|
|
// RUN: %{python} %utils/split_file.py -o %t %s
|
|
|
|
/// Create AppleLogging.swiftmodule by aliasing XLogging
|
|
// RUN: %target-swift-frontend -module-name AppleLogging -module-alias XLogging=AppleLogging %t/FileLogging.swift -emit-module -emit-module-path %t/AppleLogging.swiftmodule
|
|
// RUN: test -f %t/AppleLogging.swiftmodule
|
|
|
|
/// Scanned dependencies should contain real name AppleLogging
|
|
// RUN: %target-swift-frontend -scan-dependencies -module-load-mode prefer-interface %t/FileLib.swift -module-alias XLogging=AppleLogging -I %t > %t/scandump.output
|
|
// RUN: %validate-json %t/scandump.output | %FileCheck %s -check-prefix=CHECK-REAL-NAME
|
|
// CHECK-REAL-NAME-NOT: "swiftPrebuiltExternal": "XLogging"
|
|
// CHECK-REAL-NAME-NOT: "compiledModulePath":{{.*}}XLogging.swiftmodule",
|
|
// CHECK-REAL-NAME: "swiftPrebuiltExternal": "AppleLogging"
|
|
// CHECK-REAL-NAME: "compiledModulePath":{{.*}}AppleLogging.swiftmodule",
|
|
|
|
/// Create AppleLoggingIF.swiftinterface by aliasing XLogging
|
|
///
|
|
// RUN: %target-swift-frontend -module-name AppleLoggingIF %t/FileLogging.swift -module-alias XLogging=AppleLoggingIF -I %t -emit-module -emit-module-interface-path %t/AppleLoggingIF.swiftinterface -swift-version 5 -enable-library-evolution -I %t
|
|
// RUN: test -f %t/AppleLoggingIF.swiftinterface
|
|
|
|
/// Scanned dependencies should contain real name AppleLoggingIF
|
|
// RUN: %target-swift-frontend -scan-dependencies -module-load-mode prefer-interface %t/FileLib.swift -module-alias XLogging=AppleLoggingIF -I %t > %t/scandumpIF.output
|
|
// RUN: %validate-json %t/scandumpIF.output | %FileCheck %s -check-prefix=CHECK-REAL-NAME-IF
|
|
// CHECK-REAL-NAME-IF-NOT: "swift": "XLogging"
|
|
// CHECK-REAL-NAME-IF-NOT: "moduleInterfacePath":{{.*}}XLogging.swiftinterface
|
|
// CHECK-REAL-NAME-IF: "swift": "AppleLoggingIF"
|
|
// CHECK-REAL-NAME-IF: "moduleInterfacePath":{{.*}}AppleLoggingIF.swiftinterface
|
|
|
|
// BEGIN FileLogging.swift
|
|
public struct Logger {
|
|
public init() {}
|
|
public func startLogging() {}
|
|
}
|
|
public func setup() -> XLogging.Logger? {
|
|
return Logger()
|
|
}
|
|
|
|
// BEGIN FileLib.swift
|
|
import XLogging
|
|
|
|
public func start() {
|
|
let it = Logger()
|
|
it.startLogging()
|
|
}
|
|
|