diff --git a/Package.resolved b/Package.resolved index 27decbb2d6..2c0be97deb 100644 --- a/Package.resolved +++ b/Package.resolved @@ -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 } }, diff --git a/Package.swift b/Package.swift index 2bb7e36b58..307ed4134f 100644 --- a/Package.swift +++ b/Package.swift @@ -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)], @@ -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" )] : []) ) diff --git a/Source/SwiftLintFramework/Extensions/SwiftLintFile+Cache.swift b/Source/SwiftLintFramework/Extensions/SwiftLintFile+Cache.swift index a8c85115a3..e1b56786bf 100644 --- a/Source/SwiftLintFramework/Extensions/SwiftLintFile+Cache.swift +++ b/Source/SwiftLintFramework/Extensions/SwiftLintFile+Cache.swift @@ -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 diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 86d847b3c7..f2d38ceed3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -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