Skip to content

Commit fdddfbe

Browse files
committed
[android] Fix some parts of Bundle in Android.
While Android does not follow FHS, and it doesn't seem to have something similar published, it follows some conventions of Unix. One of them is that libraries are normally named prefixed with "lib" and suffixed with ".so" like Linux. Executables are also normally named without any prefix nor suffix. The changes in this commit lift up restrictions that were in place for Android, and allow some of the Bundle tests to pass on Android (and lift another restriction in TestObjCRuntime). While bundles might never be a common construct in Android, these changes at least allow to test some of the scenarios, in case someone needs this behaviour.
1 parent a55589e commit fdddfbe

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

CoreFoundation/PlugIn.subproj/CFBundle_Executable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static CFURLRef _CFBundleCopyExecutableURLRaw(CFURLRef urlPath, CFStringRef exeN
7474
CFURLRef executableURL = NULL;
7575
if (!urlPath || !exeName) return NULL;
7676

77-
#if !DEPLOYMENT_RUNTIME_OBJC && !DEPLOYMENT_TARGET_WINDOWS && !DEPLOYMENT_TARGET_ANDROID
77+
#if !DEPLOYMENT_RUNTIME_OBJC && !DEPLOYMENT_TARGET_WINDOWS
7878
if (!executableURL) {
7979
executableURL = CFURLCreateWithFileSystemPathRelativeToBase(kCFAllocatorSystemDefault, exeName, kCFURLPOSIXPathStyle, false, urlPath);
8080
if (!_binaryLoadable(executableURL)) {

CoreFoundation/PlugIn.subproj/CFBundle_Internal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ CF_EXTERN_C_BEGIN
3131
#endif
3232

3333
// FHS bundles are supported on the Swift and C runtimes, except on Windows.
34-
#if !DEPLOYMENT_RUNTIME_OBJC && !TARGET_OS_WIN32 && !TARGET_OS_ANDROID
34+
#if !DEPLOYMENT_RUNTIME_OBJC && !TARGET_OS_WIN32
3535

36-
#if TARGET_OS_LINUX || TARGET_OS_BSD
36+
#if TARGET_OS_LINUX || TARGET_OS_BSD || TARGET_OS_ANDROID
3737
#define _CFBundleFHSSharedLibraryFilenamePrefix CFSTR("lib")
3838
#define _CFBundleFHSSharedLibraryFilenameSuffix CFSTR(".so")
3939
#elif TARGET_OS_MAC
@@ -43,7 +43,7 @@ CF_EXTERN_C_BEGIN
4343
#error Disable FHS bundles or specify shared library prefixes and suffixes for this platform.
4444
#endif // DEPLOYMENT_TARGET_…
4545

46-
#endif // !DEPLOYMENT_RUNTIME_OBJC && !TARGET_OS_WIN32 && !TARGET_OS_ANDROID
46+
#endif // !DEPLOYMENT_RUNTIME_OBJC && !TARGET_OS_WIN32
4747

4848
#define CFBundleExecutableNotFoundError 4
4949
#define CFBundleExecutableNotLoadableError 3584

TestFoundation/TestObjCRuntime.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ class TestObjCRuntime: XCTestCase {
4343
let name = testBundleName()
4444
XCTAssertEqual(NSStringFromClass(NSObject.self), "NSObject")
4545
XCTAssertEqual(NSStringFromClass(SwiftClass.self), "\(name).SwiftClass")
46-
#if DEPLOYMENT_RUNTIME_OBJC || os(Linux)
47-
XCTAssertEqual(NSStringFromClass(XCTestCase.self), "XCTest.XCTestCase");
48-
#else
46+
#if canImport(SwiftXCTest) && !DEPLOYMENT_RUNTIME_OBJC
4947
XCTAssertEqual(NSStringFromClass(XCTestCase.self), "SwiftXCTest.XCTestCase");
48+
#else
49+
XCTAssertEqual(NSStringFromClass(XCTestCase.self), "XCTest.XCTestCase");
5050
#endif
5151
}
5252

0 commit comments

Comments
 (0)