Skip to content

Use an active compilation condition to build SourceKit-LSP without SwiftPM support #1970

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to ask where this was set, but we apparently had it already 😅. The double negative is a bit weird, but I suppose having SWIFTPM_DEPENDENCY would also be a bit weird, so maybe the double negative is the lesser of two evils.

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
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