Skip to content

Add a bare metal plugin (for "none" triples) #732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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"),
])
]),
])]
}
}
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 @@ import SWBTaskExecution
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
Loading