Skip to content

Commit d8ae00b

Browse files
omochijakepetroules
authored andcommitted
generate custom case
1 parent e118398 commit d8ae00b

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Sources/PackageModel/ManifestSourceGeneration.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,19 @@ fileprivate extension SourceCodeFragment {
407407
case "watchos": return SourceCodeFragment(enum: "watchOS")
408408
case "visionos": return SourceCodeFragment(enum: "visionOS")
409409
case "driverkit": return SourceCodeFragment(enum: "driverKit")
410-
default: return SourceCodeFragment(enum: platformName)
410+
411+
// Among known cases, those not requiring capitalization changes
412+
case "linux", "windows", "android", "wasi", "openbsd":
413+
return SourceCodeFragment(enum: platformName)
414+
415+
// Known cases but not yet available
416+
case "freebsd": fallthrough
417+
default:
418+
// For unknown cases, output using custom notation
419+
return SourceCodeFragment(
420+
enum: "custom",
421+
subnodes: [.init(string: platformName)]
422+
)
411423
}
412424
}
413425
if !platformNodes.isEmpty {

Tests/WorkspaceTests/ManifestSourceGenerationTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,8 @@ final class ManifestSourceGenerationTests: XCTestCase {
503503
dependencies: [
504504
.target(name: "MyLib", condition: .when(platforms: [
505505
.macOS, .macCatalyst, .iOS, .tvOS, .watchOS, .visionOS,
506-
.driverKit, .linux, .windows, .android, .wasi, .openbsd
506+
.driverKit, .linux, .windows, .android, .wasi, .openbsd,
507+
.custom("freebsd"), .custom("toasterOS")
507508
]))
508509
]
509510
),

0 commit comments

Comments
 (0)