Skip to content

Commit aae9c3f

Browse files
committed
Refactor
1 parent 3fe2cbd commit aae9c3f

File tree

1 file changed

+93
-65
lines changed

1 file changed

+93
-65
lines changed

Package.swift

Lines changed: 93 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -627,18 +627,20 @@ extension Array where Element == Platform {
627627
return array
628628
}
629629

630-
static var desktop: Self {[.windows, .linux, .macOS]}
630+
static var desktop: Self {[.windows, .linux, .macOS, .macCatalyst, .openbsd]}
631631
static var mobile: Self {[.iOS, .android]}
632632
static var anyApple: Self {
633-
return [.macOS, .iOS, .tvOS, .watchOS, .visionOS]
633+
return [.macOS, .iOS, .tvOS, .watchOS, .visionOS, .macCatalyst]
634634
}
635635

636636
static var any: Self {
637637
return [
638-
.macOS, .iOS, .tvOS, .visionOS,
638+
.macOS, .iOS, .tvOS, .watchOS, .visionOS, .macCatalyst,
639639
.linux, .android,
640+
.openbsd,
640641
.windows,
641-
.wasi
642+
.wasi,
643+
.driverKit,
642644
]
643645
}
644646
}
@@ -663,74 +665,100 @@ extension Array where Element == SwiftSetting {
663665

664666
static var upcommingFeatureFlags: Self? {
665667
var settings: Self = []
666-
#if compiler(>=6.2)
667-
settings.append(contentsOf: [
668-
.enableUpcomingFeature("InferIsolatedConformances"),
669-
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
670-
.enableUpcomingFeature("NonescapableTypes"),
671-
])
672-
#endif
673-
#if compiler(>=6.1)
674-
settings.append(contentsOf: [
675-
.enableUpcomingFeature("MemberImportVisibility"),
676-
])
677-
#endif
678-
#if compiler(>=6.0)
679-
settings.append(contentsOf: [
680-
.enableUpcomingFeature("GlobalActorIsolatedTypesUsability"),
681-
.enableUpcomingFeature("DynamicActorIsolation"),
682-
.enableUpcomingFeature("InferSendableFromCaptures"),
683-
.enableUpcomingFeature("RegionBasedIsolation"),
684-
.enableUpcomingFeature("InternalImportsByDefault"),
685-
])
686-
#endif
687-
#if compiler(>=5.10)
688-
settings.append(contentsOf: [
689-
.enableUpcomingFeature("GlobalConcurrency"),
690-
.enableUpcomingFeature("IsolatedDefaultValues"),
691-
.enableUpcomingFeature("DeprecateApplicationMain"),
692-
])
693-
#endif
694-
#if compiler(>=5.9)
695-
settings.append(contentsOf: [
696-
.enableUpcomingFeature("DisableOutwardActorInference"),
697-
.enableUpcomingFeature("ImportObjcForwardDeclarations"),
698-
])
699-
#endif
700-
#if compiler(>=5.8)
701-
settings.append(contentsOf: [
702-
.enableUpcomingFeature("ConciseMagicFile"),
703-
])
704-
#endif
705-
#if compiler(>=5.7)
706-
settings.append(contentsOf: [
707-
.enableUpcomingFeature("BareSlashRegexLiterals"),
708-
.enableUpcomingFeature("ImplicitOpenExistentials"),
709-
])
710-
#endif
711-
#if compiler(>=5.6)
712-
settings.append(contentsOf: [
713-
.enableUpcomingFeature("StrictConcurrency=complete"),
714-
.enableUpcomingFeature("ExistentialAny"),
715-
])
716-
#endif
717-
#if compiler(>=5.3)
718-
settings.append(contentsOf: [
719-
.enableUpcomingFeature("ForwardTrailingClosures"),
720-
])
721-
#endif
722668

669+
#if compiler(>=6.2)
670+
#if !hasFeature(InferIsolatedConformances)
671+
enableFeature("InferIsolatedConformances")
672+
#endif
673+
#if !hasFeature(NonisolatedNonsendingByDefault)
674+
enableFeature("NonisolatedNonsendingByDefault")
675+
#endif
676+
#if !hasFeature(NonescapableTypes)
677+
enableFeature("NonescapableTypes")
678+
#endif
679+
#endif
680+
#if compiler(>=6.1)
681+
#if !hasFeature(MemberImportVisibility)
682+
enableFeature("MemberImportVisibility")
683+
#endif
684+
#endif
685+
#if compiler(>=6.0)
686+
#if !hasFeature(GlobalActorIsolatedTypesUsability)
687+
enableFeature("GlobalActorIsolatedTypesUsability")
688+
#endif
689+
#if !hasFeature(DynamicActorIsolation)
690+
enableFeature("DynamicActorIsolation")
691+
#endif
692+
#if !hasFeature(InferSendableFromCaptures)
693+
enableFeature("InferSendableFromCaptures")
694+
#endif
695+
#if !hasFeature(RegionBasedIsolation)
696+
enableFeature("RegionBasedIsolation")
697+
#endif
698+
#if !hasFeature(InternalImportsByDefault)
699+
enableFeature("InternalImportsByDefault")
700+
#endif
701+
#endif
702+
#if compiler(>=5.10)
703+
#if !hasFeature(GlobalConcurrency)
704+
enableFeature("GlobalConcurrency")
705+
#endif
706+
#if !hasFeature(IsolatedDefaultValues)
707+
enableFeature("IsolatedDefaultValues")
708+
#endif
709+
#if !hasFeature(DeprecateApplicationMain)
710+
enableFeature("DeprecateApplicationMain")
711+
#endif
712+
#endif
713+
#if compiler(>=5.9)
714+
#if !hasFeature(DisableOutwardActorInference)
715+
enableFeature("DisableOutwardActorInference")
716+
#endif
717+
#if !hasFeature(ImportObjcForwardDeclarations)
718+
enableFeature("ImportObjcForwardDeclarations")
719+
#endif
720+
#endif
721+
#if compiler(>=5.8)
722+
#if !hasFeature(ConciseMagicFile)
723+
enableFeature("ConciseMagicFile")
724+
#endif
725+
#endif
726+
#if compiler(>=5.7)
727+
#if !hasFeature(BareSlashRegexLiterals)
728+
enableFeature("BareSlashRegexLiterals")
729+
#endif
730+
#if !hasFeature(ImplicitOpenExistentials)
731+
enableFeature("ImplicitOpenExistentials")
732+
#endif
733+
#endif
734+
#if compiler(>=5.6)
735+
#if !hasFeature(StrictConcurrency)
736+
enableFeature("StrictConcurrency=complete")
737+
#endif
738+
#if !hasFeature(ExistentialAny)
739+
enableFeature("ExistentialAny")
740+
#endif
741+
#endif
742+
#if compiler(>=5.3)
743+
#if !hasFeature(ForwardTrailingClosures)
744+
enableFeature("ForwardTrailingClosures")
745+
#endif
746+
#endif
747+
748+
func enableFeature(_ feature: String) {settings.append(.enableUpcomingFeature(feature))}
723749
return settings.isEmpty ? nil : settings
724750
}
725751

726752
static var exprimentalFeatureFlags: Self? {
727753
var settings: Self = []
728-
#if compiler(>=6.2)
729-
settings.append(contentsOf: [
730-
.enableExperimentalFeature("IsolatedDeinit"),
731-
])
732-
#endif
733754

755+
#if compiler(>=6.2)
756+
#if !hasFeature(IsolatedDeinit)
757+
enableFeature("IsolatedDeinit")
758+
#endif
759+
#endif
760+
761+
func enableFeature(_ feature: String) {settings.append(.enableExperimentalFeature(feature))}
734762
return settings.isEmpty ? nil : settings
735763
}
736764
}

0 commit comments

Comments
 (0)