|
1 | 1 | // swift-tools-version:6.0 |
2 | 2 | import PackageDescription |
3 | 3 |
|
| 4 | +var products: [Product] = [ |
| 5 | + .library(name: "MTH", targets: ["MTH"]), |
| 6 | + .library(name: "MTHColor", targets: ["MTHColor"]), |
| 7 | +] |
| 8 | + |
| 9 | +var targets: [Target] = [ |
| 10 | + // Thin C wrapper exposing system zlib to Swift. |
| 11 | + // zlib is present on macOS (SDK) and Linux (Swift toolchain dependency). |
| 12 | + .target( |
| 13 | + name: "CZlib", |
| 14 | + path: "Sources/CZlib", |
| 15 | + publicHeadersPath: "include", |
| 16 | + linkerSettings: [.linkedLibrary("z")] |
| 17 | + ), |
| 18 | + // New Swift targets |
| 19 | + .target( |
| 20 | + name: "MTH", |
| 21 | + dependencies: [ |
| 22 | + .target(name: "CZlib", condition: .when(platforms: [.macOS, .linux])), |
| 23 | + ], |
| 24 | + path: "Sources/SwiftMTH" |
| 25 | + ), |
| 26 | + .target( |
| 27 | + name: "MTHColor", |
| 28 | + dependencies: [], |
| 29 | + path: "Sources/SwiftMTHColor" |
| 30 | + ), |
| 31 | +] |
| 32 | + |
| 33 | +// C oracle targets require unix headers (sys/time.h, zlib.h) — exclude on Windows. |
| 34 | +#if !os(Windows) |
| 35 | +products += [ |
| 36 | + .library(name: "Cmth", targets: ["Cmth"]), |
| 37 | + .library(name: "CmthColor", targets: ["CmthColor"]), |
| 38 | +] |
| 39 | +targets += [ |
| 40 | + .target( |
| 41 | + name: "Cmth", |
| 42 | + dependencies: [], |
| 43 | + path: "Sources/cmth", |
| 44 | + sources: ["msdp.c", "mth.c", "telopt.c", "mud.c"], |
| 45 | + publicHeadersPath: "./", |
| 46 | + cSettings: [.define("MTH_LIBRARY")] |
| 47 | + ), |
| 48 | + .target( |
| 49 | + name: "CmthColor", |
| 50 | + dependencies: [], |
| 51 | + path: "Sources/cmthcolor", |
| 52 | + sources: ["color.c"], |
| 53 | + publicHeadersPath: "./", |
| 54 | + cSettings: [.define("MTH_LIBRARY")] |
| 55 | + ), |
| 56 | + .testTarget( |
| 57 | + name: "MTHTests", |
| 58 | + dependencies: ["MTH", "Cmth"] |
| 59 | + ), |
| 60 | + .testTarget( |
| 61 | + name: "MTHColorTests", |
| 62 | + dependencies: ["MTHColor", "CmthColor"] |
| 63 | + ), |
| 64 | +] |
| 65 | +#else |
| 66 | +targets += [ |
| 67 | + .testTarget( |
| 68 | + name: "MTHTests", |
| 69 | + dependencies: ["MTH"] |
| 70 | + ), |
| 71 | + .testTarget( |
| 72 | + name: "MTHColorTests", |
| 73 | + dependencies: ["MTHColor"] |
| 74 | + ), |
| 75 | +] |
| 76 | +#endif |
| 77 | + |
4 | 78 | let package = Package( |
5 | 79 | name: "mth", |
6 | | - products: [ |
7 | | - .library(name: "MTH", targets: ["MTH"]), |
8 | | - .library(name: "MTHColor", targets: ["MTHColor"]), |
9 | | - // C targets retained as oracle for testing |
10 | | - .library(name: "Cmth", targets: ["Cmth"]), |
11 | | - .library(name: "CmthColor", targets: ["CmthColor"]), |
12 | | - ], |
13 | | - targets: [ |
14 | | - // Thin C wrapper exposing system zlib to Swift. |
15 | | - // zlib is present on macOS (SDK) and Linux (Swift toolchain dependency). |
16 | | - .target( |
17 | | - name: "CZlib", |
18 | | - path: "Sources/CZlib", |
19 | | - publicHeadersPath: "include", |
20 | | - linkerSettings: [.linkedLibrary("z")] |
21 | | - ), |
22 | | - // Existing C targets (renamed) |
23 | | - .target( |
24 | | - name: "Cmth", |
25 | | - dependencies: [], |
26 | | - path: "Sources/cmth", |
27 | | - sources: ["msdp.c", "mth.c", "telopt.c", "mud.c"], |
28 | | - publicHeadersPath: "./", |
29 | | - cSettings: [.define("MTH_LIBRARY")] |
30 | | - ), |
31 | | - .target( |
32 | | - name: "CmthColor", |
33 | | - dependencies: [], |
34 | | - path: "Sources/cmthcolor", |
35 | | - sources: ["color.c"], |
36 | | - publicHeadersPath: "./", |
37 | | - cSettings: [.define("MTH_LIBRARY")] |
38 | | - ), |
39 | | - // New Swift targets |
40 | | - .target( |
41 | | - name: "MTH", |
42 | | - dependencies: [ |
43 | | - .target(name: "CZlib", condition: .when(platforms: [.macOS, .linux])), |
44 | | - ], |
45 | | - path: "Sources/SwiftMTH" |
46 | | - ), |
47 | | - .target( |
48 | | - name: "MTHColor", |
49 | | - dependencies: [], |
50 | | - path: "Sources/SwiftMTHColor" |
51 | | - ), |
52 | | - // Test targets |
53 | | - .testTarget( |
54 | | - name: "MTHTests", |
55 | | - dependencies: ["MTH", "Cmth"] |
56 | | - ), |
57 | | - .testTarget( |
58 | | - name: "MTHColorTests", |
59 | | - dependencies: ["MTHColor", "CmthColor"] |
60 | | - ), |
61 | | - ] |
| 80 | + products: products, |
| 81 | + targets: targets |
62 | 82 | ) |
0 commit comments