Skip to content

Commit

Permalink
[android] add android build support
Browse files Browse the repository at this point in the history
this is needed to build swift-corelibs-foundation for android, using the 'package' branch that is based on new swift-foundation
  • Loading branch information
hyp committed Jun 27, 2024
1 parent c57764a commit ab7f8d0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Sources/SwiftLibraryPluginProvider/LibraryPluginProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ private import Darwin
private import Glibc
#elseif canImport(Musl)
private import Musl
#elseif canImport(Android)
private import Android
#endif
#else
import SwiftSyntaxMacros
Expand All @@ -33,6 +35,8 @@ import SwiftSyntaxMacros
@_implementationOnly import Glibc
#elseif canImport(Musl)
@_implementationOnly import Musl
#elseif canImport(Android)
@_implementationOnly import Android
#endif
#endif

Expand Down Expand Up @@ -137,7 +141,12 @@ private func _loadLibrary(_ path: String) throws -> UnsafeMutableRawPointer {
#else
private func _loadLibrary(_ path: String) throws -> UnsafeMutableRawPointer {
guard let dlHandle = dlopen(path, RTLD_LAZY | RTLD_LOCAL) else {
throw LibraryPluginError(message: "loader error: \(String(cString: dlerror()))")
#if canImport(Android)
let err = dlerror()!
#else
let err = dlerror()
#endif
throw LibraryPluginError(message: "loader error: \(String(cString: err))")
}
return dlHandle
}
Expand Down

0 comments on commit ab7f8d0

Please sign in to comment.