Skip to content
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

[android] add android build support #2707

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
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 = String(cString: dlerror()!)
#else
let err = String(cString: dlerror())
#endif
throw LibraryPluginError(message: "loader error: \(err)")
}
return dlHandle
}
Expand Down