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 a0eb2ac
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 @@ -18,6 +18,8 @@ private import _SwiftLibraryPluginProviderCShims
// because we don't want other modules depend on 'WinSDK'.
#if canImport(Darwin)
private import Darwin
#elseif canImport(Android)
private import Android
#elseif canImport(Glibc)
private import Glibc
#elseif canImport(Musl)
Expand All @@ -29,6 +31,8 @@ import SwiftSyntaxMacros
@_implementationOnly import _SwiftLibraryPluginProviderCShims
#if canImport(Darwin)
@_implementationOnly import Darwin
#elseif canImport(Android)
@_implementationOnly import Android
#elseif canImport(Glibc)
@_implementationOnly import Glibc
#elseif canImport(Musl)
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 a0eb2ac

Please sign in to comment.