diff --git a/.editorconfig b/.editorconfig index ac8a0df1..9023c510 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,3 +11,6 @@ xcode_trim_whitespace_on_empty_lines = true [*.{yml,yaml}] indent_size = 2 + +[CMakeLists.txt] +indent_size = 2 diff --git a/Sources/SWBUniversalPlatform/BareMetal.swift b/Sources/SWBUniversalPlatform/BareMetal.swift new file mode 100644 index 00000000..7a30cfea --- /dev/null +++ b/Sources/SWBUniversalPlatform/BareMetal.swift @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See http://swift.org/LICENSE.txt for license information +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +public import SWBUtil +public import SWBCore +import SWBMacro +import Foundation + +struct BareMetalPlatformExtension: PlatformInfoExtension { + func additionalPlatforms(context: any PlatformInfoExtensionAdditionalPlatformsContext) throws -> [(path: Path, data: [String: PropertyListItem])] { + [ + (.root, [ + "Type": .plString("Platform"), + "Name": .plString("none"), + "Identifier": .plString("none"), + "Description": .plString("Bare Metal"), + "FamilyName": .plString("None"), + "FamilyIdentifier": .plString("none"), + "IsDeploymentPlatform": .plString("YES"), + ]) + ] + } +} + +@_spi(Testing) public struct BareMetalSDKRegistryExtension: SDKRegistryExtension { + public func additionalSDKs(context: any SDKRegistryExtensionAdditionalSDKsContext) async throws -> [(path: Path, platform: Platform?, data: [String: PropertyListItem])] { + guard let platform = context.platformRegistry.lookup(name: "none") else { + return [] + } + + let defaultProperties: [String: PropertyListItem] = [ + "SDK_STAT_CACHE_ENABLE": "NO", + ] + + return [(.root, platform, [ + "Type": .plString("SDK"), + "Version": .plString("0.0.0"), + "CanonicalName": .plString("none"), + "IsBaseSDK": .plBool(true), + "DefaultProperties": .plDict([ + "PLATFORM_NAME": .plString("none"), + ].merging(defaultProperties, uniquingKeysWith: { _, new in new })), + "CustomProperties": .plDict([:]), + "SupportedTargets": .plDict([ + "none": .plDict([ + "Archs": .plArray([]), + "LLVMTargetTripleSys": .plString("none"), + ]) + ]), + ])] + } +} diff --git a/Sources/SWBUniversalPlatform/CMakeLists.txt b/Sources/SWBUniversalPlatform/CMakeLists.txt index 9a9d436e..f50c3700 100644 --- a/Sources/SWBUniversalPlatform/CMakeLists.txt +++ b/Sources/SWBUniversalPlatform/CMakeLists.txt @@ -9,6 +9,7 @@ See http://swift.org/CONTRIBUTORS.txt for Swift project authors ]] add_library(SWBUniversalPlatform + BareMetal.swift CopyPlistFile.swift CopyStringsFile.swift CppTool.swift diff --git a/Sources/SWBUniversalPlatform/Plugin.swift b/Sources/SWBUniversalPlatform/Plugin.swift index 66dce209..91b2392e 100644 --- a/Sources/SWBUniversalPlatform/Plugin.swift +++ b/Sources/SWBUniversalPlatform/Plugin.swift @@ -20,6 +20,9 @@ public let initializePlugin: PluginInitializationFunction = { manager in manager.register(UniversalPlatformSpecsExtension(), type: SpecificationsExtensionPoint.self) manager.register(UniversalPlatformTaskProducerExtension(), type: TaskProducerExtensionPoint.self) manager.register(UniversalPlatformTaskActionExtension(), type: TaskActionExtensionPoint.self) + + manager.register(BareMetalPlatformExtension(), type: PlatformInfoExtensionPoint.self) + manager.register(BareMetalSDKRegistryExtension(), type: SDKRegistryExtensionPoint.self) } struct UniversalPlatformSpecsExtension: SpecificationsExtension { diff --git a/Tests/SWBCoreTests/SettingsTests.swift b/Tests/SWBCoreTests/SettingsTests.swift index d6d2dfe5..68394735 100644 --- a/Tests/SWBCoreTests/SettingsTests.swift +++ b/Tests/SWBCoreTests/SettingsTests.swift @@ -1773,7 +1773,7 @@ import SWBMacro #expect(!core.platformRegistry.platforms.isEmpty) for developmentTeam in ["ABCDWXYZ", ""] { for platform in core.platformRegistry.platforms { - if ["android", "freebsd", "linux", "qnx", "windows"].contains(platform.name) { + if ["android", "freebsd", "linux", "none", "qnx", "windows"].contains(platform.name) { continue } for sdk in platform.sdks { diff --git a/Tests/SWBTaskConstructionTests/PackageProductConstructionTests.swift b/Tests/SWBTaskConstructionTests/PackageProductConstructionTests.swift index ee33a453..607a280b 100644 --- a/Tests/SWBTaskConstructionTests/PackageProductConstructionTests.swift +++ b/Tests/SWBTaskConstructionTests/PackageProductConstructionTests.swift @@ -673,7 +673,7 @@ fileprivate struct PackageProductConstructionTests: CoreBasedTests { @Test(.requireSDKs(.macOS)) func packageProductReferences() async throws { let core = try await getCore() - let allPlatforms = core.platformRegistry.platforms.filter { !$0.isSimulator && core.sdkRegistry.lookup($0.name) != nil } + let allPlatforms = core.platformRegistry.platforms.filter { !$0.isSimulator && core.sdkRegistry.lookup($0.name) != nil && $0.name != "none" } #expect(allPlatforms.count > 0) // ensure we don't just pass this test because we somehow ended up with no platforms let targets = allPlatforms.map { $0.name }.map { commandLineDynamicLibraryTarget(name: "\($0)Lib", buildSettings: ["SDKROOT": $0])