Skip to content

[android] Use Bionic imports instead where possible #5149

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

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions Sources/Foundation/FileManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import WinSDK

#if os(WASI)
import WASILibc
#elseif canImport(Android)
import Android
#elseif canImport(Bionic)
import Bionic
#endif

#if os(Windows)
Expand Down
4 changes: 2 additions & 2 deletions Sources/Foundation/NSLock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

#if canImport(Glibc)
import Glibc
#elseif canImport(Android)
import Android
#elseif canImport(Bionic)
import Bionic
#endif

#if os(Windows)
Expand Down
4 changes: 2 additions & 2 deletions Sources/Foundation/NSURL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import Darwin
import Glibc
#elseif canImport(Musl)
import Musl
#elseif canImport(Android)
import Android
#elseif canImport(Bionic)
import Bionic
#endif

// NOTE: this represents PLATFORM_PATH_STYLE
Expand Down
4 changes: 2 additions & 2 deletions Sources/Foundation/Thread.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import WinSDK
import Glibc
#elseif canImport(Musl)
import Musl
#elseif canImport(Android)
import Android
#elseif canImport(Bionic)
import Bionic
#endif

// WORKAROUND_SR9811
Expand Down
2 changes: 2 additions & 0 deletions Sources/Testing/Testing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import Glibc
#elseif canImport(Musl)
import Musl
#elseif canImport(Bionic)
import Bionic
#elseif os(WASI)
import WASILibc
#elseif canImport(CRT)
Expand Down
4 changes: 2 additions & 2 deletions Sources/plutil/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import Glibc
#elseif canImport(Musl)
import Foundation
import Musl
#elseif canImport(Android)
#elseif canImport(Bionic)
import Foundation
import Android
import Bionic
#elseif canImport(CRT)
import Foundation
import CRT
Expand Down
2 changes: 1 addition & 1 deletion Sources/xdgTestHelper/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import FoundationNetworking
#endif
#if os(Windows)
import WinSDK
#elseif os(Android)
#elseif canImport(Android)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this should still be an os check.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two are pretty much equivalent, but I use this to guard imports like this and os(Android) for genuine OS differences that don't involve importing these C functions. I have seen this done for other platforms in the Swift codebase, so I'm following that distinction for Android too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only done for Darwin platforms because there is a large set of them and we don't have a way to uniformly identify them at once.

import Android
#endif

Expand Down