Skip to content

Commit

Permalink
Update SwiftSyntax to 0.50600.0 (#3901)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jpsim authored Mar 17, 2022
1 parent ca2712a commit de3569c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 19 deletions.
6 changes: 3 additions & 3 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
},
Expand Down
37 changes: 23 additions & 14 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
// swift-tools-version:5.5
import PackageDescription

#if canImport(CommonCrypto)
#if os(macOS)
private let addCryptoSwift = false
private let staticSwiftSyntax = true
#else
private let addCryptoSwift = true
private let staticSwiftSyntax = false
#endif

#if os(macOS)
private let staticSwiftSyntax = true
#if os(Linux) && compiler(<5.6)
private let swiftSyntaxFiveDotSix = false
#else
private let staticSwiftSyntax = false
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)],
Expand All @@ -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"),
Expand All @@ -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",
Expand All @@ -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"
)] : [])
)
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 6 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ jobs:
matrix:
swift55:
containerImage: swift:5.5
swift56:
containerImage: swift:5.6
container: $[ variables['containerImage'] ]
steps:
- script: swift test --parallel
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit de3569c

Please sign in to comment.