forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not depend on OSS SoLoader anymore (facebook#45873)
Summary: Pull Request resolved: facebook#45873 I'm removing the Gradle dependency on OSS SoLoader and stubbing it with our own implementation. This will allow us to implement merging of further .so libraries and As Fresco also depends on SoLoader, I had to stub the `NativeLoader` dependency as well. Changelog: [Android] [Breaking] - Do not depend on OSS SoLoader anymore and do not expose Fresco `api` dependency. Reviewed By: mdvacca Differential Revision: D60652007
- Loading branch information
1 parent
7e41ea4
commit 6376ea3
Showing
10 changed files
with
140 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...s/react-native/sdks/ossonly-soloader/src/main/java/com/facebook/soloader/DoNotOptimize.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.facebook.soloader | ||
|
||
public annotation class DoNotOptimize {} |
55 changes: 55 additions & 0 deletions
55
packages/react-native/sdks/ossonly-soloader/src/main/java/com/facebook/soloader/SoLoader.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
@file:Suppress("UNUSED_EXPRESSION", "ControlFlowWithEmptyBody", "UNUSED_PARAMETER") | ||
|
||
package com.facebook.soloader | ||
|
||
import android.content.Context | ||
|
||
/** | ||
* This class is a stub of SoLoader used ONLY by React Native OSS. | ||
* | ||
* This allows us to do not mutate the SoLoader.init and SoLoader.loadLibrary methods, which are | ||
* used by the React Native, while also allowing us to implement custom JNI_OnLoad calling which | ||
* enables merging of SOs. | ||
*/ | ||
public object SoLoader { | ||
|
||
private val loadedLibraries = mutableSetOf<String>() | ||
|
||
private fun mapLibName(input: String) = input | ||
|
||
@Suppress("UNUSED_PARAMETER") | ||
private fun invokeJniOnload(libraryName: String) { | ||
// no-op for now, till we move library to So Merging in OSS | ||
} | ||
|
||
@Deprecated("This method is a no-op and you should not be calling it") | ||
@JvmStatic | ||
public fun init(context: Context, exoPackage: Boolean) { | ||
// Do nothing | ||
} | ||
|
||
@JvmStatic | ||
public fun loadLibrary(libraryName: String): Boolean { | ||
if (libraryName in loadedLibraries) { | ||
return false | ||
} | ||
val mapLibraryName = mapLibName(libraryName) | ||
System.loadLibrary(mapLibraryName) | ||
if (libraryName != mapLibraryName) { | ||
invokeJniOnload(mapLibraryName) | ||
} | ||
return true | ||
} | ||
|
||
@JvmStatic | ||
public fun setInTestMode() { | ||
// Do nothing | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...ve/sdks/ossonly-soloader/src/main/java/com/facebook/soloader/nativeloader/NativeLoader.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.facebook.soloader.nativeloader | ||
|
||
/** | ||
* This class is a stub of NativeLoader used ONLY by React Native OSS. | ||
* | ||
* Fresco in OSS depends on NativeLoader, but we don't want to include the real | ||
* NativeLoader/SoLoader in React Native OSS. This stub is used to make Fresco work properly for us. | ||
*/ | ||
public object NativeLoader { | ||
|
||
@JvmStatic | ||
public fun loadLibrary(libraryName: String): Boolean { | ||
System.loadLibrary(libraryName) | ||
return true | ||
} | ||
|
||
@JvmStatic public fun isInitialized(): Boolean = true | ||
|
||
@Suppress("UNUSED_PARAMETER") | ||
public fun initIfUninitialized(systemDelegate: SystemDelegate): Unit = Unit | ||
} |
23 changes: 23 additions & 0 deletions
23
...ossonly-soloader/src/main/java/com/facebook/soloader/nativeloader/NativeLoaderDelegate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.facebook.soloader.nativeloader | ||
|
||
/** | ||
* This class is a stub of NativeLoaderDelegate used ONLY by React Native OSS. | ||
* | ||
* Fresco in OSS depends on NativeLoader, but we don't want to include the real | ||
* NativeLoader/SoLoader in React Native OSS. This stub is used to make Fresco work properly for us. | ||
*/ | ||
public interface NativeLoaderDelegate { | ||
|
||
public fun loadLibrary(shortName: String?, flags: Int): Boolean | ||
|
||
public fun getLibraryPath(libName: String?): String | ||
|
||
public fun getSoSourcesVersion(): Int | ||
} |
10 changes: 10 additions & 0 deletions
10
.../sdks/ossonly-soloader/src/main/java/com/facebook/soloader/nativeloader/SystemDelegate.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.facebook.soloader.nativeloader | ||
|
||
public class SystemDelegate {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters