-
Notifications
You must be signed in to change notification settings - Fork 18
Generate SDKSettings.json file for Swift SDKs for Swift 5.9-6.0 #185
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
78b3261
Add String.hasPrefix(in: [String]) method and use where applicable
xtremekforever f07b497
Add code to generate an SDKSettings.json file for Swift 5.9, 5.10, an…
xtremekforever 97a2063
Add missing newline at end of Swift+hasPrefixIn.swift
xtremekforever a572429
Add test for SwiftSDKGenerator.generateSDKSettingsFile()
xtremekforever 0c78b49
Rename String.hasPrefix(in:) to String.hasAnyPrefix(from:)
xtremekforever 414ecbe
Merge branch 'main' into sdk-settings-file
MaxDesiatov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
Sources/SwiftSDKGenerator/Extensions/String+hasPrefixIn.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
extension String { | ||
func hasPrefix(in array: [String]) -> Bool { | ||
for item in array { | ||
if self.hasPrefix(item) { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
Tests/SwiftSDKGeneratorTests/Generator/SwiftSDKGenerator+MetadataTests.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This source file is part of the Swift open source project | ||
// | ||
// Copyright (c) 2022-2025 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See https://swift.org/LICENSE.txt for license information | ||
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
import Logging | ||
import SystemPackage | ||
import XCTest | ||
|
||
@testable import SwiftSDKGenerator | ||
|
||
final class SwiftSDKGeneratorMetadataTests: XCTestCase { | ||
let logger = Logger(label: "SwiftSDKGeneratorMetadataTests") | ||
|
||
func testGenerateSDKSettingsFile() async throws { | ||
let testCases = [ | ||
( | ||
bundleVersion: "0.0.1", | ||
targetTriple: Triple("x86_64-unknown-linux-gnu"), | ||
expectedCanonicalName: "x86_64-swift-linux-gnu" | ||
), | ||
( | ||
bundleVersion: "0.0.2", | ||
targetTriple: Triple("aarch64-unknown-linux-gnu"), | ||
expectedCanonicalName: "aarch64-swift-linux-gnu" | ||
), | ||
( | ||
bundleVersion: "0.0.3", | ||
targetTriple: Triple("armv7-unknown-linux-gnueabihf"), | ||
expectedCanonicalName: "armv7-swift-linux-gnueabihf" | ||
) | ||
] | ||
|
||
for testCase in testCases { | ||
let sdk = try await SwiftSDKGenerator( | ||
bundleVersion: testCase.bundleVersion, | ||
targetTriple: testCase.targetTriple, | ||
artifactID: "6.0.3-RELEASE_ubuntu_jammy_\(testCase.targetTriple.archName)", | ||
isIncremental: false, | ||
isVerbose: false, | ||
logger: logger | ||
) | ||
let linuxDistribution = try LinuxDistribution(name: .ubuntu, version: "22.04") | ||
|
||
let sdkDirPath = FilePath(".") | ||
try await sdk.generateSDKSettingsFile(sdkDirPath: sdkDirPath, distribution: linuxDistribution) | ||
|
||
// Make sure the file exists | ||
let sdkSettingsFile = sdkDirPath.appending("SDKSettings.json") | ||
let fileExists = await sdk.doesFileExist(at: sdkSettingsFile) | ||
XCTAssertTrue(fileExists) | ||
|
||
// Read back file, make sure it contains the expected data | ||
let data = String(data: try await sdk.readFile(at: sdkSettingsFile), encoding: .utf8) | ||
XCTAssertNotNil(data) | ||
XCTAssertTrue(data!.contains(testCase.bundleVersion)) | ||
XCTAssertTrue(data!.contains("(\(testCase.targetTriple.archName))")) | ||
XCTAssertTrue(data!.contains(linuxDistribution.description)) | ||
XCTAssertTrue(data!.contains(testCase.expectedCanonicalName)) | ||
|
||
// Cleanup | ||
try await sdk.removeFile(at: sdkSettingsFile) | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.