Skip to content

Commit 0548b1d

Browse files
committed
fixup! Exclude C oracle targets on Windows.
1 parent ae9173a commit 0548b1d

3 files changed

Lines changed: 80 additions & 56 deletions

File tree

Package.swift

Lines changed: 76 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,82 @@
11
// swift-tools-version:6.0
22
import PackageDescription
33

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+
478
let package = Package(
579
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
6282
)

Tests/MTHColorTests/ColorOracleTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(CmthColor)
12
import Testing
23
import CmthColor
34
import MTHColor
@@ -141,3 +142,4 @@ private func assertOracleMatch(_ input: String, depth: ColorDepth, sourceLocatio
141142
assertOracleMatch("<FABC><BDEF>truemix", depth: depth)
142143
}
143144
}
145+
#endif

Tests/MTHTests/MTHTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#if canImport(Cmth)
12
import Testing
23
import Cmth
34
import MTH
@@ -172,3 +173,4 @@ private func gmcpPacket(_ payload: [UInt8]) -> [UInt8] {
172173
let cBackToMsdp = cJson2Msdp(cJson)
173174
#expect(backToMsdp == cBackToMsdp, "Round-trip mismatch")
174175
}
176+
#endif

0 commit comments

Comments
 (0)