Skip to content

Commit 76965d7

Browse files
authored
Merge pull request #18495 from nkcsgexi/revert-sourcekit-linx
Revert "SourceKit: make SwiftLang build in linux. (#18455)"
2 parents 285b337 + 960d764 commit 76965d7

File tree

10 files changed

+26
-26
lines changed

10 files changed

+26
-26
lines changed

test/SwiftSyntax/AbsolutePosition.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func getInput(_ file: String) -> URL {
1717
}
1818

1919
func getSyntaxTree(_ url: URL) throws -> SourceFileSyntax {
20-
let content = try SwiftLang.parse(path: url.path).data(using: .utf8)!
20+
let content = try SwiftLang.parse(url).data(using: .utf8)!
2121
return try SyntaxTreeDeserializer().deserialize(content)
2222
}
2323

test/SwiftSyntax/DeserializeFile.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var DecodeTests = TestSuite("DecodeSyntax")
2020

2121
DecodeTests.test("Basic") {
2222
expectDoesNotThrow({
23-
let content = try SwiftLang.parse(path: getInput("visitor.swift").path)
23+
let content = try SwiftLang.parse(getInput("visitor.swift"))
2424
let contentData = content.data(using: .utf8)!
2525
let source = try String(contentsOf: getInput("visitor.swift"))
2626
let parsed = try SyntaxTreeDeserializer().deserialize(contentData)

test/SwiftSyntax/ParseFile.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ParseFile.test("ParseSingleFile") {
3131
let currentFile = URL(fileURLWithPath: #file)
3232
expectDoesNotThrow({
3333
let fileContents = try String(contentsOf: currentFile)
34-
let syntaxTreeData = try SwiftLang.parse(source: fileContents).data(using: .utf8)!
34+
let syntaxTreeData = try SwiftLang.parse(fileContents).data(using: .utf8)!
3535
let parsed = try SyntaxTreeDeserializer().deserialize(syntaxTreeData)
3636
expectEqual("\(parsed)", fileContents)
3737
})
@@ -40,7 +40,7 @@ ParseFile.test("ParseSingleFile") {
4040
ParseFile.test("ParseBuffer") {
4141
expectDoesNotThrow({
4242
let content = "func foo() {}"
43-
let syntaxTreeData = try SwiftLang.parse(source: content).data(using: .utf8)!
43+
let syntaxTreeData = try SwiftLang.parse(content).data(using: .utf8)!
4444
let parsed = try SyntaxTreeDeserializer().deserialize(syntaxTreeData)
4545
expectEqual("\(parsed)", content)
4646
})

test/SwiftSyntax/VisitorTest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func getInput(_ file: String) -> URL {
1717
}
1818

1919
func getSyntaxTree(_ url: URL) throws -> SourceFileSyntax {
20-
let content = try SwiftLang.parse(path: url.path).data(using: .utf8)!
20+
let content = try SwiftLang.parse(url).data(using: .utf8)!
2121
return try SyntaxTreeDeserializer().deserialize(content)
2222
}
2323

tools/SourceKit/tools/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ if(HAVE_UNICODE_LIBEDIT)
1010
add_swift_tool_subdirectory(sourcekitd-repl)
1111
endif()
1212
add_swift_tool_subdirectory(complete-test)
13-
add_subdirectory(swift-lang)
13+
if(BUILD_FOUNDATION)
14+
add_subdirectory(swift-lang)
15+
endif()

tools/SourceKit/tools/sourcekitd/include/sourcekitd/module.modulemap

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
if(SWIFT_SOURCEKIT_USE_INPROC_LIBRARY)
2-
set(EXTRA_COMPILE_FLAGS "-I" "${SOURCEKITD_SOURCE_DIR}/include/sourcekitd")
3-
set(SOURCEKITD_LINK_LIBS sourcekitdInProc)
4-
set(INSTALLED_COMP sourcekit-inproc)
5-
else()
6-
set(EXTRA_COMPILE_FLAGS "-F" "${SWIFT_LIBRARY_OUTPUT_INTDIR}")
7-
set(SOURCEKITD_LINK_LIBS sourcekitd)
8-
set(INSTALLED_COMP sourcekit-xpc-service)
9-
endif()
1+
set(EXTRA_COMPILE_FLAGS "-F" "${SWIFT_LIBRARY_OUTPUT_INTDIR}")
2+
set(EXTRA_LINKER_FLAGS "-Xlinker" "-rpath" "-Xlinker" "${SWIFT_LIBRARY_OUTPUT_INTDIR}"
3+
"-Xlinker" "-F" "-Xlinker" "${SWIFT_LIBRARY_OUTPUT_INTDIR}")
104

115
add_swift_library(swiftSwiftLang SHARED
126
SwiftLang.swift
@@ -17,7 +11,10 @@ add_swift_library(swiftSwiftLang SHARED
1711
UIDs.swift.gyb
1812

1913
DEPENDS sourcekitd-test
20-
PRIVATE_LINK_LIBRARIES ${SOURCEKITD_LINK_LIBS}
14+
PRIVATE_LINK_LIBRARIES sourcekitd
2115
SWIFT_COMPILE_FLAGS ${EXTRA_COMPILE_FLAGS}
22-
INSTALL_IN_COMPONENT ${INSTALLED_COMP}
16+
LINK_FLAGS ${EXTRA_LINKER_FLAGS}
17+
SWIFT_MODULE_DEPENDS Foundation
18+
INSTALL_IN_COMPONENT sourcekit-xpc-service
19+
TARGET_SDKS OSX
2320
IS_STDLIB)

tools/SourceKit/tools/swift-lang/SourceKitdClient.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
import sourcekitd
16+
import Foundation
1617

1718
public class SourceKitdService {
1819

tools/SourceKit/tools/swift-lang/SourceKitdResponse.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// This file provides convenient APIs to interpret a SourceKitd response.
1313
//===----------------------------------------------------------------------===//
1414

15+
import Foundation
1516
import sourcekitd
1617

1718
public class SourceKitdResponse: CustomStringConvertible {
@@ -252,6 +253,6 @@ extension sourcekitd_variant_t: CustomStringConvertible {
252253
}
253254

254255
private func fromCStringLen(_ ptr: UnsafePointer<Int8>, length: Int) -> String? {
255-
return String(decoding: Array(UnsafeBufferPointer(start: ptr, count: length)).map {
256-
UInt8(bitPattern: $0) }, as: UTF8.self)
256+
return NSString(bytes: ptr, length: length,
257+
encoding: String.Encoding.utf8.rawValue) as String?
257258
}

tools/SourceKit/tools/swift-lang/SwiftLang.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// This file provides Swift language support by invoking SourceKit internally.
1313
//===----------------------------------------------------------------------===//
1414

15+
import Foundation
16+
1517
enum SourceKitdError: Error, CustomStringConvertible {
1618
case EditorOpenError(message: String)
1719
case EditorCloseError(message: String)
@@ -63,15 +65,16 @@ public class SwiftLang {
6365
/// thread safe.
6466
/// - Parameter url: The URL you wish to parse.
6567
/// - Returns: The syntax tree in Json format string.
66-
public static func parse(path: String) throws -> String {
67-
return try parse(content: path, name: path, isURL: true)
68+
public static func parse(_ url: URL) throws -> String {
69+
let Path = url.path
70+
return try parse(content: Path, name: Path, isURL: true)
6871
}
6972

7073
/// Parses a given source buffer into a `Syntax` tree in Json serialization
7174
/// format by querying SourceKitd service. This function isn't thread safe.
7275
/// - Parameter source: The source buffer you wish to parse.
7376
/// - Returns: The syntax tree in Json format string.
74-
public static func parse(source: String) throws -> String {
77+
public static func parse(_ source: String) throws -> String {
7578
return try parse(content: source, name: "foo", isURL: false)
7679
}
7780
}

0 commit comments

Comments
 (0)