Skip to content

Commit b1c9466

Browse files
committed
Add a bare metal plugin (for "none" triples)
This is just going in SWBUniversalPlatform for now for simplicity / bringup, and should maybe move into a new SWBNonePlatformPlugin later on. Closes #726
1 parent e3d484f commit b1c9466

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift open source project
4+
//
5+
// Copyright (c) 2025 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
public import SWBUtil
14+
public import SWBCore
15+
import SWBMacro
16+
import Foundation
17+
18+
struct BareMetalPlatformExtension: PlatformInfoExtension {
19+
func additionalPlatforms(context: any PlatformInfoExtensionAdditionalPlatformsContext) throws -> [(path: Path, data: [String: PropertyListItem])] {
20+
[
21+
(.root, [
22+
"Type": .plString("Platform"),
23+
"Name": .plString("none"),
24+
"Identifier": .plString("none"),
25+
"Description": .plString("Bare Metal"),
26+
"FamilyName": .plString("None"),
27+
"FamilyIdentifier": .plString("none"),
28+
"IsDeploymentPlatform": .plString("YES"),
29+
])
30+
]
31+
}
32+
}
33+
34+
@_spi(Testing) public struct BareMetalSDKRegistryExtension: SDKRegistryExtension {
35+
public func additionalSDKs(context: any SDKRegistryExtensionAdditionalSDKsContext) async throws -> [(path: Path, platform: Platform?, data: [String: PropertyListItem])] {
36+
guard let platform = context.platformRegistry.lookup(name: "none") else {
37+
return []
38+
}
39+
40+
let defaultProperties: [String: PropertyListItem] = [
41+
"SDK_STAT_CACHE_ENABLE": "NO",
42+
]
43+
44+
return [(.root, platform, [
45+
"Type": .plString("SDK"),
46+
"Version": .plString("0.0.0"),
47+
"CanonicalName": .plString("none"),
48+
"IsBaseSDK": .plBool(true),
49+
"DefaultProperties": .plDict([
50+
"PLATFORM_NAME": .plString("none"),
51+
].merging(defaultProperties, uniquingKeysWith: { _, new in new })),
52+
"CustomProperties": .plDict([:]),
53+
"SupportedTargets": .plDict([
54+
"none": .plDict([
55+
"Archs": .plArray([]),
56+
"LLVMTargetTripleSys": .plString("none"),
57+
])
58+
]),
59+
])]
60+
}
61+
}

Sources/SWBUniversalPlatform/Plugin.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import SWBTaskExecution
2020
manager.register(UniversalPlatformSpecsExtension(), type: SpecificationsExtensionPoint.self)
2121
manager.register(UniversalPlatformTaskProducerExtension(), type: TaskProducerExtensionPoint.self)
2222
manager.register(UniversalPlatformTaskActionExtension(), type: TaskActionExtensionPoint.self)
23+
24+
manager.register(BareMetalPlatformExtension(), type: PlatformInfoExtensionPoint.self)
25+
manager.register(BareMetalSDKRegistryExtension(), type: SDKRegistryExtensionPoint.self)
2326
}
2427

2528
struct UniversalPlatformSpecsExtension: SpecificationsExtension {

Tests/SWBCoreTests/SettingsTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1773,7 +1773,7 @@ import SWBMacro
17731773
#expect(!core.platformRegistry.platforms.isEmpty)
17741774
for developmentTeam in ["ABCDWXYZ", ""] {
17751775
for platform in core.platformRegistry.platforms {
1776-
if ["android", "freebsd", "linux", "qnx", "windows"].contains(platform.name) {
1776+
if ["android", "freebsd", "linux", "none", "qnx", "windows"].contains(platform.name) {
17771777
continue
17781778
}
17791779
for sdk in platform.sdks {

0 commit comments

Comments
 (0)