Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ xcode_trim_whitespace_on_empty_lines = true

[*.{yml,yaml}]
indent_size = 2

[CMakeLists.txt]
indent_size = 2
61 changes: 61 additions & 0 deletions Sources/SWBUniversalPlatform/BareMetal.swift
Original file line number Diff line number Diff line change
@@ -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"),
])
]),
])]
}
}
1 change: 1 addition & 0 deletions Sources/SWBUniversalPlatform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions Sources/SWBUniversalPlatform/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Tests/SWBCoreTests/SettingsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down