Update SwiftSyntax to 0.50600.0 (#3901)

Uses SwiftSyntax 5.5 on Linux when building with Swift 5.5. We use the 5.6 version of
SwiftSyntax when building with Swift 5.5 and 5.6 on macOS because we statically link
`lib_InternalSwiftSyntaxParser` thanks to
https://github.com/keith/StaticInternalSwiftSyntaxParser/releases/tag/5.6.

This keeps SwiftLint binaries portable across machines on macOS, regardless of
_where_ or even _if_ `lib_InternalSwiftSyntaxParser` is installed.

* Run TSan CI job with `--configuration release` to avoid stack overflows
* Add Swift 5.6 CI job
* Fix linker settings
This commit is contained in:
JP Simard 2022-03-17 13:19:48 -04:00 committed by GitHub
parent ca2712aaee
commit de3569cb3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 21 deletions

View File

@ -21,10 +21,10 @@
},
{
"package": "SwiftSyntax",
"repositoryURL": "https://github.com/apple/swift-syntax.git",
"repositoryURL": "https://github.com/apple/swift-syntax",
"state": {
"branch": null,
"revision": "cf40be70deaf4ce7d44eb1a7e14299c391e2363f",
"branch": "0.50600.0",
"revision": "0467d94e8123071e8e6c24039aadb405318f1838",
"version": null
}
},

View File

@ -1,18 +1,29 @@
// swift-tools-version:5.5
import PackageDescription
#if canImport(CommonCrypto)
private let addCryptoSwift = false
#else
private let addCryptoSwift = true
#endif
#if os(macOS)
private let addCryptoSwift = false
private let staticSwiftSyntax = true
#else
private let addCryptoSwift = true
private let staticSwiftSyntax = false
#endif
#if os(Linux) && compiler(<5.6)
private let swiftSyntaxFiveDotSix = false
#else
private let swiftSyntaxFiveDotSix = true
#endif
let frameworkDependencies: [Target.Dependency] = [
.product(name: "SourceKittenFramework", package: "SourceKitten"),
.product(name: "SwiftSyntax", package: "SwiftSyntax"),
"Yams",
]
+ (addCryptoSwift ? ["CryptoSwift"] : [])
+ (staticSwiftSyntax ? ["lib_InternalSwiftSyntaxParser"] : [])
+ (swiftSyntaxFiveDotSix ? [.product(name: "SwiftSyntaxParser", package: "SwiftSyntax")] : [])
let package = Package(
name: "SwiftLint",
platforms: [.macOS(.v10_12)],
@ -23,7 +34,7 @@ let package = Package(
dependencies: [
.package(name: "swift-argument-parser", url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "1.0.3")),
.package(name: "SwiftSyntax", url: "https://github.com/apple/swift-syntax.git",
.revision("cf40be70deaf4ce7d44eb1a7e14299c391e2363f")),
.revision(swiftSyntaxFiveDotSix ? "0467d94e8123071e8e6c24039aadb405318f1838" : "cf40be70deaf4ce7d44eb1a7e14299c391e2363f")),
.package(url: "https://github.com/jpsim/SourceKitten.git", from: "0.32.0"),
.package(url: "https://github.com/jpsim/Yams.git", from: "4.0.2"),
.package(url: "https://github.com/scottrhoyt/SwiftyTextTable.git", from: "0.9.0"),
@ -39,13 +50,11 @@ let package = Package(
),
.target(
name: "SwiftLintFramework",
dependencies: [
.product(name: "SourceKittenFramework", package: "SourceKitten"),
"SwiftSyntax",
"Yams",
]
+ (addCryptoSwift ? ["CryptoSwift"] : [])
+ (staticSwiftSyntax ? ["lib_InternalSwiftSyntaxParser"] : [])
dependencies: frameworkDependencies,
// Pass `-dead_strip_dylibs` to ignore the dynamic version of `lib_InternalSwiftSyntaxParser`
// that ships with SwiftSyntax because we want the static version from
// `StaticInternalSwiftSyntaxParser`.
linkerSettings: staticSwiftSyntax ? [.unsafeFlags(["-Xlinker", "-dead_strip_dylibs"])] : []
),
.testTarget(
name: "SwiftLintFrameworkTests",
@ -58,7 +67,7 @@ let package = Package(
),
] + (staticSwiftSyntax ? [.binaryTarget(
name: "lib_InternalSwiftSyntaxParser",
url: "https://github.com/keith/StaticInternalSwiftSyntaxParser/releases/download/5.5.2/lib_InternalSwiftSyntaxParser.xcframework.zip",
checksum: "96bbc9ab4679953eac9ee46778b498cb559b8a7d9ecc658e54d6679acfbb34b8"
url: "https://github.com/keith/StaticInternalSwiftSyntaxParser/releases/download/5.6/lib_InternalSwiftSyntaxParser.xcframework.zip",
checksum: "88d748f76ec45880a8250438bd68e5d6ba716c8042f520998a438db87083ae9d"
)] : [])
)

View File

@ -1,6 +1,9 @@
import Foundation
import SourceKittenFramework
import SwiftSyntax
#if canImport(SwiftSyntaxParser)
import SwiftSyntaxParser
#endif
private typealias FileCacheKey = UUID
private var responseCache = Cache({ file -> [String: SourceKitRepresentable]? in

View File

@ -10,6 +10,8 @@ jobs:
matrix:
swift55:
containerImage: swift:5.5
swift56:
containerImage: swift:5.6
container: $[ variables['containerImage'] ]
steps:
- script: swift test --parallel
@ -84,9 +86,11 @@ jobs:
variables:
DEVELOPER_DIR: /Applications/Xcode_13.2.1.app
steps:
- script: swift run --sanitize=thread swiftlint lint --lenient
- script: swift build --configuration release --sanitize thread
displayName: Build SwiftLint
- script: swift run --configuration release --sanitize thread swiftlint lint --lenient
displayName: Pre-cache SwiftLint Run
- script: swift run --sanitize=thread swiftlint lint --lenient
- script: swift run --configuration release --sanitize thread swiftlint lint --lenient
displayName: Post-cache SwiftLint Run
- script: make test_tsan
displayName: Test With TSan