Skip to content

Commit

Permalink
Merge pull request #1970 from ahoppen/active-compilation-condition-no…
Browse files Browse the repository at this point in the history
…-swiftpm

Use an active compilation condition to build SourceKit-LSP without SwiftPM support
  • Loading branch information
ahoppen authored Feb 6, 2025
2 parents f151447 + 6678fb0 commit 825c17e
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 10 deletions.
14 changes: 10 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ import Foundation
import PackageDescription

/// Swift settings that should be applied to every Swift target.
let globalSwiftSettings: [SwiftSetting] = [
.enableUpcomingFeature("InternalImportsByDefault"),
.enableUpcomingFeature("MemberImportVisibility"),
]
var globalSwiftSettings: [SwiftSetting] {
var result: [SwiftSetting] = [
.enableUpcomingFeature("InternalImportsByDefault"),
.enableUpcomingFeature("MemberImportVisibility"),
]
if noSwiftPMDependency {
result += [.define("NO_SWIFTPM_DEPENDENCY")]
}
return result
}

var products: [Product] = [
.executable(name: "sourcekit-lsp", targets: ["sourcekit-lsp"]),
Expand Down
2 changes: 1 addition & 1 deletion Sources/BuildSystemIntegration/BuildSystemManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private extension BuildSystemSpec {
)
}
case .swiftPM:
#if canImport(PackageModel)
#if !NO_SWIFTPM_DEPENDENCY
return await createBuiltInBuildSystemAdapter(
messagesToSourceKitLSPHandler: messagesToSourceKitLSPHandler,
buildSystemHooks: buildSystemHooks
Expand Down
2 changes: 1 addition & 1 deletion Sources/BuildSystemIntegration/DetermineBuildSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ package func determineBuildSystem(
case .compilationDatabase:
spec = searchForCompilationDatabaseConfig(in: workspaceFolderUrl, options: options)
case .swiftPM:
#if canImport(PackageModel)
#if !NO_SWIFTPM_DEPENDENCY
spec = SwiftPMBuildSystem.searchForConfig(in: workspaceFolderUrl, options: options)
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/BuildSystemIntegration/SwiftPMBuildSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//

#if canImport(PackageModel)
#if !NO_SWIFTPM_DEPENDENCY
import Basics
@preconcurrency import Build
import Dispatch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//

#if canImport(PackageModel)
#if !NO_SWIFTPM_DEPENDENCY

import Foundation
import LanguageServerProtocol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let allSyntaxCodeActions: [SyntaxCodeActionProvider.Type] = {
OpaqueParameterToGeneric.self,
RemoveSeparatorsFromIntegerLiteral.self,
]
#if canImport(PackageModel)
#if !NO_SWIFTPM_DEPENDENCY
result.append(PackageManifestEdits.self)
#endif
return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//

#if canImport(PackageModel)
#if !NO_SWIFTPM_DEPENDENCY
import BuildServerProtocol
@_spi(Testing) import BuildSystemIntegration
import LanguageServerProtocol
Expand Down

0 comments on commit 825c17e

Please sign in to comment.