|
| 1 | +// Check "isImportedDirectly" in trace for complex dependency graphs. |
| 2 | +// See also: rdar://64993153. |
| 3 | + |
| 4 | +// Dependency graph: |
| 5 | + |
| 6 | +// * CoreShip - ObjC module with overlay |
| 7 | +// * CoreFuel - ObjC module with overlay |
| 8 | +// * CoreMission - Swift module |
| 9 | +// * LaunchKit - ObjC module with overlay, has #import <CoreFuel.h> but not import CoreFuel |
| 10 | +// * FlightKit - Swift module, has import CoreShip and @_exported import CoreMission |
| 11 | +// * ShipUI - Swift module, has import FlightKit and import LaunchKit |
| 12 | + |
| 13 | +// RUN: %empty-directory(%t) |
| 14 | + |
| 15 | +// 1. Create CoreShip module |
| 16 | +// RUN: %target-swift-frontend %s -DCoreShip -module-name CoreShip -emit-module -o %t/CoreShip.swiftmodule -I %S/Inputs/imported_modules/ComplexModuleGraph |
| 17 | + |
| 18 | +#if CoreShip |
| 19 | +@_exported import CoreShip |
| 20 | +#endif |
| 21 | + |
| 22 | + |
| 23 | +// 2. Create CoreFuel module |
| 24 | +// RUN: %target-swift-frontend %s -DCoreFuel -module-name CoreFuel -emit-module -o %t/CoreFuel.swiftmodule -I %S/Inputs/imported_modules/ComplexModuleGraph |
| 25 | + |
| 26 | +#if CoreFuel |
| 27 | +@_exported import CoreFuel |
| 28 | +public func totalEnergyInMJ(hydrogenInKg: Float, methaneInKg: Float) -> Float { |
| 29 | + return hydrogenInKg * hydrogenEnergyDensityInMJPerKg |
| 30 | + + methaneInKg * methaneEnergyDensityInMJPerKg |
| 31 | +} |
| 32 | +#endif |
| 33 | + |
| 34 | + |
| 35 | +// 3. Create CoreMission module |
| 36 | +// RUN: %target-swift-frontend %s -DCoreMission -module-name CoreMission -emit-module -o %t/CoreMission.swiftmodule |
| 37 | + |
| 38 | +#if CoreMission |
| 39 | +public typealias Planet = String |
| 40 | +public typealias Mission = (origin: Planet, destination: Planet) |
| 41 | +#endif |
| 42 | + |
| 43 | + |
| 44 | +// 4. Compile LaunchKit and check that its trace has: |
| 45 | +// - direct dependency on CoreFuel |
| 46 | +// |
| 47 | +// RUN: %target-swift-frontend %s -DLaunchKit -module-name LaunchKit -emit-module -o %t/LaunchKit.swiftmodule -I %S/Inputs/imported_modules/ComplexModuleGraph -I %t -emit-loaded-module-trace |
| 48 | +// RUN: %FileCheck %s --check-prefix=LAUNCHKIT < %t/LaunchKit.trace.json |
| 49 | + |
| 50 | +#if LaunchKit |
| 51 | +// CoreFuel is not imported explicitly, but it is automatically @_exported via ObjC #import |
| 52 | +@_exported import LaunchKit |
| 53 | + |
| 54 | +// Both ObjC and Swift parts of CoreFuel are directly accessible! |
| 55 | +let _ = CoreFuel.hydrogenEnergyDensityInMJPerKg |
| 56 | +let _ = CoreFuel.totalEnergyInMJ |
| 57 | + |
| 58 | +// FIXME: rdar://64993153 |
| 59 | +// LAUNCHKIT: {"name":"CoreFuel","path":"{{[^"]*}}CoreFuel.swiftmodule","isImportedDirectly":false, |
| 60 | +#endif |
| 61 | + |
| 62 | + |
| 63 | +// 5. Compile FlightKit and check that trace has: |
| 64 | +// - direct dependency on CoreShip |
| 65 | +// |
| 66 | +// RUN: %target-swift-frontend %s -DFlightKit -module-name FlightKit -emit-module -o %t/FlightKit.swiftmodule -I %S/Inputs/imported_modules/ComplexModuleGraph -I %t -emit-loaded-module-trace |
| 67 | +// RUN: %FileCheck %s --check-prefix=FLIGHTKIT < %t/FlightKit.trace.json |
| 68 | + |
| 69 | +#if FlightKit |
| 70 | +import CoreShip |
| 71 | +@_exported import CoreMission |
| 72 | + |
| 73 | +// FLIGHTKIT: "swiftmodulesDetailedInfo":[ |
| 74 | +// FLIGHTKIT-DAG: {"name":"CoreShip","path":"{{[^"]*}}CoreShip.swiftmodule","isImportedDirectly":true, |
| 75 | +// FLIGHTKIT-DAG: {"name":"CoreMission","path":"{{[^"]*}}CoreMission.swiftmodule","isImportedDirectly":true, |
| 76 | +// FLIGHTKIT: ] |
| 77 | +#endif |
| 78 | + |
| 79 | +// 6. Compile ShipUI and check that trace has: |
| 80 | +// - direct dependency on FlightKit and LaunchKit (due to imports) |
| 81 | +// - direct dependency on CoreFuel (via LaunchKit) |
| 82 | +// - indirect dependency on CoreShip (via FlightKit) |
| 83 | +// - direct dependency on CoreMission (via FlightKit) |
| 84 | +// |
| 85 | +// RUN: %target-swift-frontend %s -DShipUI -module-name ShipUI -emit-module -o %t/ShipUI.swiftmodule -I %S/Inputs/imported_modules/ComplexModuleGraph -I %t -emit-loaded-module-trace |
| 86 | +// RUN: %FileCheck %s --check-prefix=SHIPUI < %t/ShipUI.trace.json |
| 87 | + |
| 88 | +#if ShipUI |
| 89 | +import FlightKit |
| 90 | +import LaunchKit |
| 91 | + |
| 92 | +// Both ObjC and Swift parts of CoreFuel are accessible via LaunchKit |
| 93 | +let _ = LaunchKit.hydrogenEnergyDensityInMJPerKg |
| 94 | +let _ = LaunchKit.totalEnergyInMJ |
| 95 | + |
| 96 | +// CoreMission's types are accessible via FlightKit |
| 97 | +let _cassini: FlightKit.Mission = (origin: "Earth", destination: "Saturn") |
| 98 | + |
| 99 | +// SHIPUI: "swiftmodulesDetailedInfo":[ |
| 100 | +// SHIPUI-DAG: {"name":"FlightKit","path":"{{[^"]*}}FlightKit.swiftmodule","isImportedDirectly":true, |
| 101 | +// SHIPUI-DAG: {"name":"LaunchKit","path":"{{[^"]*}}LaunchKit.swiftmodule","isImportedDirectly":true, |
| 102 | +// FIXME: rdar://64993153 - this should be direct |
| 103 | +// SHIPUI-DAG: {"name":"CoreFuel","path":"{{[^"]*}}CoreFuel.swiftmodule","isImportedDirectly":false, |
| 104 | +// SHIPUI-DAG: {"name":"CoreShip","path":"{{[^"]*}}CoreShip.swiftmodule","isImportedDirectly":false, |
| 105 | +// FIXME: rdar://64993153 - this should be direct |
| 106 | +// SHIPUI-DAG: {"name":"CoreMission","path":"{{[^"]*}}CoreMission.swiftmodule","isImportedDirectly":false, |
| 107 | +// SHIPUI: ] |
| 108 | +#endif |
0 commit comments