Link against everything on Linux
This commit is contained in:
parent
a20339a1f2
commit
13076ab5b8
27
build.rs
27
build.rs
|
@ -9,11 +9,33 @@ fn main() {
|
|||
if target.target.unversioned_triple.contains("linux") {
|
||||
// include the swift runtime library path in the rpath
|
||||
target.paths.runtime_library_paths.iter().for_each(|path| {
|
||||
println!("cargo:rustc-link-arg-Wl,-rpath={}", path);
|
||||
println!("cargo:rustc-link-arg=-Wl,-rpath={}", path);
|
||||
});
|
||||
// need to link against libswiftCore and libFoundation
|
||||
println!("cargo:rustc-link-lib=dylib=swiftCore");
|
||||
|
||||
println!("cargo:rustc-link-lib=dylib=BlocksRuntime");
|
||||
println!("cargo:rustc-link-lib=dylib=dispatch");
|
||||
println!("cargo:rustc-link-lib=dylib=FoundationNetworking");
|
||||
println!("cargo:rustc-link-lib=dylib=Foundation");
|
||||
println!("cargo:rustc-link-lib=dylib=FoundationXML");
|
||||
println!("cargo:rustc-link-lib=dylib=icudataswift");
|
||||
println!("cargo:rustc-link-lib=dylib=icui18nswift");
|
||||
println!("cargo:rustc-link-lib=dylib=icuucswift");
|
||||
println!("cargo:rustc-link-lib=dylib=_InternalSwiftScan");
|
||||
println!("cargo:rustc-link-lib=dylib=_InternalSwiftStaticMirror");
|
||||
println!("cargo:rustc-link-lib=dylib=_InternalSwiftSyntaxParser");
|
||||
println!("cargo:rustc-link-lib=dylib=swift_Concurrency");
|
||||
println!("cargo:rustc-link-lib=dylib=swiftCore");
|
||||
println!("cargo:rustc-link-lib=dylib=swift_Differentiation");
|
||||
println!("cargo:rustc-link-lib=dylib=swiftDispatch");
|
||||
println!("cargo:rustc-link-lib=dylib=swiftDistributed");
|
||||
println!("cargo:rustc-link-lib=dylib=swiftGlibc");
|
||||
println!("cargo:rustc-link-lib=dylib=swiftRegexBuilder");
|
||||
println!("cargo:rustc-link-lib=dylib=swift_RegexParser");
|
||||
println!("cargo:rustc-link-lib=dylib=swiftRemoteMirror");
|
||||
println!("cargo:rustc-link-lib=dylib=swift_StringProcessing");
|
||||
println!("cargo:rustc-link-lib=dylib=swiftSwiftOnoneSupport");
|
||||
println!("cargo:rustc-link-lib=dylib=XCTest");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,6 +94,7 @@ pub fn link_swift() {
|
|||
|
||||
pub fn link_swift_package(package_name: &str, package_root: &str) {
|
||||
let profile = env::var("PROFILE").unwrap();
|
||||
dbg!(&profile);
|
||||
|
||||
if !Command::new("swift")
|
||||
.args(&["build", "-c", &profile])
|
||||
|
|
|
@ -2,19 +2,27 @@ import Foundation
|
|||
import Splash
|
||||
|
||||
@_cdecl("highlight_swift")
|
||||
public func highlight(codePtr: UnsafePointer<UInt8>, codeLen: UInt64, htmlLenPtr: UnsafeMutablePointer<UInt64>) -> UnsafeMutableRawPointer {
|
||||
public func highlight(codePtr: UnsafePointer<UInt8>, codeLen: UInt64, htmlLenPtr: UnsafeMutablePointer<UInt64>) -> UnsafeMutablePointer<UInt8> {
|
||||
let buf = UnsafeBufferPointer(start: codePtr, count: Int(codeLen))
|
||||
let data = Data(buffer: buf)
|
||||
let code = String(data: data, encoding: .utf8)!
|
||||
|
||||
print("a")
|
||||
debugPrint(MyOutputFormat())
|
||||
let highligher = SyntaxHighlighter(format: MyOutputFormat())
|
||||
withUnsafePointer(to: highligher) { ptr in
|
||||
debugPrint(UnsafeRawPointer(ptr))
|
||||
}
|
||||
print("b")
|
||||
debugPrint(highligher)
|
||||
debugPrint(code)
|
||||
var html = highligher.highlight(code)
|
||||
let outPtr = UnsafeMutableBufferPointer<UInt8>.allocate(capacity: html.utf8.count)
|
||||
_ = html.withUTF8 { buf in
|
||||
buf.copyBytes(to: outPtr, count: buf.count)
|
||||
}
|
||||
htmlLenPtr.pointee = UInt64(html.utf8.count)
|
||||
return UnsafeMutableRawPointer(outPtr.baseAddress!)
|
||||
htmlLenPtr.pointee = UInt64(outPtr.count)
|
||||
return outPtr.baseAddress!
|
||||
}
|
||||
|
||||
struct MyOutputFormat: OutputFormat {
|
||||
|
@ -119,4 +127,3 @@ extension StringProtocol {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import XCTest
|
||||
@testable import highlight_swift_tests
|
||||
|
||||
XCTMain([
|
||||
testCase(HighlightTests.allTests),
|
||||
|
|
|
@ -21,8 +21,7 @@ class HighlightTests: XCTestCase {
|
|||
highlight(codePtr: codePtr.baseAddress!, codeLen: UInt64(codePtr.count), htmlLenPtr: lenPtr)
|
||||
}
|
||||
}
|
||||
let start = UnsafePointer(result.assumingMemoryBound(to: UInt8.self))
|
||||
let htmlPtr = UnsafeBufferPointer(start: start, count: Int(len))
|
||||
let htmlPtr = UnsafeBufferPointer(start: result, count: Int(len))
|
||||
let data = Data(buffer: htmlPtr)
|
||||
let expected = "<span class=\"hl-num\">1</span>+<span class=\"hl-num\">1</span>"
|
||||
XCTAssertEqual(String(data: data, encoding: .utf8), expected)
|
||||
|
|
Loading…
Reference in New Issue