Skip to content

Commit b1dea33

Browse files
committed
Restore some comments and logic for playground support
1 parent 03f36c1 commit b1dea33

File tree

10 files changed

+16
-6
lines changed

10 files changed

+16
-6
lines changed

Sources/SWBCore/BuildRequest.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ public final class BuildRequest: CustomStringConvertible, Sendable {
262262
public let schemeCommand: SchemeCommand?
263263

264264
/// Path of the root container being built. This is typically a .xcworkspace or .xcodeproj,
265-
/// but can also be the path to a directory containing a Package.swift file.
265+
/// but can also be a .playground or the path to a directory containing a Package.swift file.
266266
public let containerPath: Path?
267267

268268
/// JSON representation of the `SWBBuildRequest` public API object from which this build request was constructed, if provided.

Sources/SWBCore/Core.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public final class Core: Sendable {
189189

190190
let versionPath = self.developerPath.dirname.join("version.plist")
191191

192-
// Load the containing app (Xcode) version information, if available.
192+
// Load the containing app (Xcode or Playgrounds) version information, if available.
193193
//
194194
// We make this optional so tests do not need to provide it.
195195
if let info = try XcodeVersionInfo.versionInfo(versionPath: versionPath) {

Sources/SWBCore/DependencyResolution.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ extension SpecializationParameters {
477477
let platformBuildParameters: [PlatformBuildParameters]
478478

479479
/// Targets which should build dynamically according to the build request.
480-
/// This is only used by previews.
480+
/// This is only used by Playgrounds and previews.
481481
let dynamicallyBuildingTargets: Set<Target>
482482

483483
// TODO: Parameterize this.

Sources/SWBCore/Settings/Settings.swift

+2
Original file line numberDiff line numberDiff line change
@@ -2863,6 +2863,7 @@ private class SettingsBuilder {
28632863
table.push(BuiltinMacros.MAC_OS_X_PRODUCT_BUILD_VERSION, literal: systemInfo.productBuildVersion)
28642864
}
28652865

2866+
#if !RC_PLAYGROUNDS
28662867
// Xcode version settings.
28672868
let xcodeMajorStr = (core.xcodeVersion[0] * 100).toString(format: "%04d")
28682869
let xcodeMinorStr = (core.xcodeVersion[0] * 100 + core.xcodeVersion[1] * 10).toString(format: "%04d")
@@ -2871,6 +2872,7 @@ private class SettingsBuilder {
28712872
table.push(BuiltinMacros.XCODE_VERSION_MINOR, literal: xcodeMinorStr)
28722873
table.push(BuiltinMacros.XCODE_VERSION_ACTUAL, literal: xcodeActualStr)
28732874
table.push(BuiltinMacros.XCODE_PRODUCT_BUILD_VERSION, literal: core.xcodeProductBuildVersionString)
2875+
#endif
28742876

28752877
// Backward compatibility settings.
28762878
table.push(BuiltinMacros.BUILD_STYLE, Static { BuiltinMacros.namespace.parseString("$(CONFIGURATION)") })

Sources/SWBCore/WorkspaceContext.swift

+4
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ public struct UserPreferences: Sendable {
109109
public let allowsExternalToolExecution: Bool
110110

111111
public static var allowsExternalToolExecutionDefaultValue: Bool {
112+
#if RC_PLAYGROUNDS
113+
return true
114+
#else
112115
return false
116+
#endif
113117
}
114118

115119
static let `default` = UserPreferences(

Sources/SWBTaskExecution/TaskActions/DeferredExecutionTaskAction.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ extension TaskAction {
5757
case .deferred:
5858
try await dynamicExecutionDelegate.spawn(commandLine: commandLine, environment: environment, workingDirectory: workingDirectory, processDelegate: processDelegate)
5959
case let .result(status, stdout, stderr):
60-
// NOTE: This is not strictly correct, as we really should forward the merged output in the same order it was emitted, rather than all of stdout and then all of stderr. But we need much better APIs in order to do that.
60+
// NOTE: This is not strictly correct, as we really should forward the merged output in the same order it was emitted, rather than all of stdout and then all of stderr. But we need much better APIs in order to do that, and for the current (Swift Playgrounds) use case it shouldn't matter in practice.
6161
let pid = llbuild_pid_t.invalid
6262
processDelegate.processStarted(pid: pid)
6363
processDelegate.processHadOutput(output: Array(stdout))

Sources/SWBTaskExecution/TaskActions/InfoPlistProcessorTaskAction.swift

+2
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ public final class InfoPlistProcessorTaskAction: TaskAction
253253

254254
// These aren't harmful to the system if they're empty, but will cause App Store submission to fail, so elide them as well.
255255
"BuildMachineOSBuild",
256+
"DTSwiftPlaygroundsBuild",
257+
"DTSwiftPlaygroundsVersion",
256258
"DTXcode",
257259
"DTXcodeBuild",
258260
]))

Sources/SWBUtil/Xcode.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public struct XcodeVersionInfo: Sendable {
3939
public let shortVersion: Version
4040
public let productBuildVersion: ProductBuildVersion?
4141

42-
/// Extracts the version info from a version.plist in an Xcode installation at `versionPath`.
42+
/// Extracts the version info from a version.plist in an Xcode or Playgrounds installation at `versionPath`.
4343
///
4444
/// - Returns: A tuple of the short version and ProductBuildVersion, or `nil` if the Xcode at `appPath` does not have a version.plist. Note that the ProductBuildVersion may also be `nil` even if the version.plist was present, as it can be missing in some cases.
4545
/// - Throws: If there was an error reading the version.plist file or parsing its contents.

Sources/SwiftBuild/SWBBuildRequest.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ public struct SWBBuildRequest: Codable, Sendable {
275275
public var schemeCommand: SWBSchemeCommand? = .launch
276276

277277
/// Path of the root container being built. This is typically a .xcworkspace or .xcodeproj,
278-
/// but can also be the path to a directory containing a Package.swift file.
278+
/// but can also be a .playground or the path to a directory containing a Package.swift file.
279279
public var containerPath: String? = nil
280280

281281
/// Optional array of paths to files the build should be limited to.

Tests/SWBCoreTests/SettingsTests.swift

+2
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ import SWBMacro
111111
#expect(settings.tableForTesting.lookupMacro(BuiltinMacros.PROJECT_TEMP_DIR)?.expression.stringRep == "$(OBJROOT)/$(PROJECT_NAME).build")
112112
#expect(settings.tableForTesting.lookupMacro(BuiltinMacros.CONFIGURATION)?.expression.stringRep == "Config1")
113113
#expect(settings.tableForTesting.lookupMacro(BuiltinMacros.CONFIGURATION_BUILD_DIR)?.expression.stringRep == "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)")
114+
#if !RC_PLAYGROUNDS
114115
func checkXcodeVersion(_ settingName: StringMacroDeclaration, expectedVersion: Version, sourceLocation: SourceLocation = #_sourceLocation) {
115116
if let value = settings.tableForTesting.lookupMacro(settingName)?.expression.stringRep {
116117
if value.count >= 4, let uintValue = UInt(value) {
@@ -127,6 +128,7 @@ import SWBMacro
127128
checkXcodeVersion(BuiltinMacros.XCODE_VERSION_MINOR, expectedVersion: core.xcodeVersion.normalized(toNumberOfComponents: 2))
128129
checkXcodeVersion(BuiltinMacros.XCODE_VERSION_ACTUAL, expectedVersion: core.xcodeVersion)
129130
#expect(settings.tableForTesting.lookupMacro(BuiltinMacros.XCODE_PRODUCT_BUILD_VERSION)?.expression.stringRep == core.xcodeProductBuildVersionString)
131+
#endif
130132
#expect(settings.tableForTesting.lookupMacro(BuiltinMacros.USER)?.expression.stringRep == "exampleUser")
131133

132134
// Verify that the settings from the xcconfig were added.

0 commit comments

Comments
 (0)