|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: split-file %S/diamond.swift %t |
| 3 | + |
| 4 | +// Test: Main drives code generation |
| 5 | +// RUN: %target-swift-frontend -c -emit-module -o %t/Root.o %t/Root.swift -enable-experimental-feature Embedded -enable-experimental-feature DeferredCodeGen -parse-as-library -enable-experimental-feature EmbeddedExistentials |
| 6 | +// RUN: %target-swift-frontend -c -I %t -emit-module -o %t/ClientA.o %t/ClientA.swift -enable-experimental-feature Embedded -enable-experimental-feature DeferredCodeGen -parse-as-library -enable-experimental-feature EmbeddedExistentials |
| 7 | +// RUN: %target-swift-frontend -c -I %t -emit-module -o %t/ClientB.o %t/ClientB.swift -enable-experimental-feature Embedded -enable-experimental-feature DeferredCodeGen -parse-as-library -enable-experimental-feature EmbeddedExistentials |
| 8 | +// RUN: %target-swift-frontend -c -I %t -emit-module -o %t/Application.o %t/Application.swift -enable-experimental-feature Embedded -enable-experimental-feature DeferredCodeGen -parse-as-library -enable-experimental-feature EmbeddedExistentials |
| 9 | +// RUN: %target-clang %target-clang-resource-dir-opt %t/Root.o %t/ClientA.o %t/ClientB.o %t/Application.o -o %t/Application |
| 10 | +// RUN: %target-run %t/Application | %FileCheck %s |
| 11 | + |
| 12 | +// But use this file's Root.swift |
| 13 | +// RUN: %empty-directory(%t) |
| 14 | +// RUN: split-file %S/diamond.swift %t |
| 15 | +// RUN: split-file %s %t |
| 16 | + |
| 17 | +// Test: Main drives most code generation but Root.swift references PointClass. |
| 18 | +// RUN: %target-swift-frontend -c -emit-module -o %t/Root.o %t/Root.swift -enable-experimental-feature Embedded -enable-experimental-feature DeferredCodeGen -parse-as-library -enable-experimental-feature EmbeddedExistentials |
| 19 | +// RUN: %target-swift-frontend -c -I %t -emit-module -o %t/ClientA.o %t/ClientA.swift -enable-experimental-feature Embedded -enable-experimental-feature DeferredCodeGen -parse-as-library -enable-experimental-feature EmbeddedExistentials |
| 20 | +// RUN: %target-swift-frontend -c -I %t -emit-module -o %t/ClientB.o %t/ClientB.swift -enable-experimental-feature Embedded -enable-experimental-feature DeferredCodeGen -parse-as-library -enable-experimental-feature EmbeddedExistentials |
| 21 | +// RUN: %target-swift-frontend -c -I %t -emit-module -o %t/Application.o %t/Application.swift -enable-experimental-feature Embedded -enable-experimental-feature DeferredCodeGen -parse-as-library -enable-experimental-feature EmbeddedExistentials |
| 22 | +// RUN: %target-clang %target-clang-resource-dir-opt %t/Root.o %t/ClientA.o %t/ClientB.o %t/Application.o -o %t/Application |
| 23 | +// RUN: %target-run %t/Application | %FileCheck %s |
| 24 | + |
| 25 | +// REQUIRES: swift_in_compiler |
| 26 | +// REQUIRES: executable_test |
| 27 | +// REQUIRES: swift_feature_Embedded |
| 28 | +// REQUIRES: swift_feature_EmbeddedExistentials |
| 29 | +// REQUIRES: swift_feature_DeferredCodeGen |
| 30 | + |
| 31 | +//--- Root.swift |
| 32 | +struct Point { |
| 33 | + var x, y: Int |
| 34 | +} |
| 35 | + |
| 36 | +public func enumerateByteOffsets<T>(_: T.Type) -> [Int] { |
| 37 | + var array: [Int] = [] |
| 38 | + for i in 0..<MemoryLayout<T>.size { |
| 39 | + array.append(i) |
| 40 | + } |
| 41 | + return array |
| 42 | +} |
| 43 | + |
| 44 | +public func getPointOffsets() -> [Int] { |
| 45 | + enumerateByteOffsets(Point.self) |
| 46 | +} |
| 47 | + |
| 48 | +public class PointClass { |
| 49 | + public var x, y: Int |
| 50 | + |
| 51 | + public init(x: Int, y: Int) { |
| 52 | + self.x = x |
| 53 | + self.y = y |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +public protocol Reflectable: AnyObject { |
| 58 | + func reflect() |
| 59 | +} |
| 60 | + |
| 61 | +extension PointClass: Reflectable { |
| 62 | + public func reflect() { |
| 63 | + swap(&x, &y) |
| 64 | + } |
| 65 | +} |
| 66 | + |
| 67 | +@used |
| 68 | +public func getPointClass() -> PointClass { |
| 69 | + return PointClass(x: 1, y: 2) |
| 70 | +} |
| 71 | + |
| 72 | +// CHECK: DONE |
0 commit comments