@preeternal/react-native-godot 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/LICENSE +22 -0
  2. package/Package.swift +106 -0
  3. package/README.md +631 -2
  4. package/android/build.gradle +289 -0
  5. package/android/consumer-rules.pro +19 -0
  6. package/android/fix-prefab.gradle +54 -0
  7. package/android/src/main/AndroidManifest.xml +2 -0
  8. package/android/src/main/cpp/CMakeLists.txt +74 -0
  9. package/android/src/main/cpp/GodotModule.cpp +718 -0
  10. package/android/src/main/cpp/OnLoad.cpp +66 -0
  11. package/android/src/main/cpp/libgodot_android.h +79 -0
  12. package/android/src/main/cpp/libgodot_jni.cpp +585 -0
  13. package/android/src/main/cpp/libgodot_jni.h +130 -0
  14. package/android/src/main/cpp/native_godot_module_jni.cpp +86 -0
  15. package/android/src/main/cpp/native_godot_module_jni.h +58 -0
  16. package/android/src/main/java/com/preeternal/reactnativegodot/NativeGodotModuleModule.kt +83 -0
  17. package/android/src/main/java/com/preeternal/reactnativegodot/NativeGodotModulePackage.kt +41 -0
  18. package/android/src/main/java/com/preeternal/reactnativegodot/NativeLibraryLoader.kt +5 -0
  19. package/android/src/main/java/com/preeternal/reactnativegodot/RTNGodotView.kt +81 -0
  20. package/android/src/main/java/com/preeternal/reactnativegodot/RTNGodotViewManager.kt +34 -0
  21. package/android/src/main/java/com/preeternal/reactnativegodot/RTNLibGodot.kt +350 -0
  22. package/android/src/main/res/layout/downloading_expansion.xml +165 -0
  23. package/android/src/main/res/layout/godot_app_layout.xml +5 -0
  24. package/android/src/main/res/layout/snackbar.xml +27 -0
  25. package/android/src/main/res/layout/status_bar_ongoing_event_progress_bar.xml +108 -0
  26. package/android/src/main/res/mipmap/icon.png +0 -0
  27. package/android/src/main/res/mipmap/icon_background.png +0 -0
  28. package/android/src/main/res/mipmap/icon_foreground.png +0 -0
  29. package/android/src/main/res/mipmap/icon_monochrome.png +0 -0
  30. package/android/src/main/res/mipmap-anydpi-v26/icon.xml +8 -0
  31. package/android/src/main/res/mipmap-anydpi-v26/themed_icon.xml +11 -0
  32. package/android/src/main/res/mipmap-hdpi/icon.png +0 -0
  33. package/android/src/main/res/mipmap-hdpi/icon_background.png +0 -0
  34. package/android/src/main/res/mipmap-hdpi/icon_foreground.png +0 -0
  35. package/android/src/main/res/mipmap-hdpi/icon_monochrome.png +0 -0
  36. package/android/src/main/res/mipmap-mdpi/icon.png +0 -0
  37. package/android/src/main/res/mipmap-mdpi/icon_background.png +0 -0
  38. package/android/src/main/res/mipmap-mdpi/icon_foreground.png +0 -0
  39. package/android/src/main/res/mipmap-mdpi/icon_monochrome.png +0 -0
  40. package/android/src/main/res/mipmap-xhdpi/icon.png +0 -0
  41. package/android/src/main/res/mipmap-xhdpi/icon_background.png +0 -0
  42. package/android/src/main/res/mipmap-xhdpi/icon_foreground.png +0 -0
  43. package/android/src/main/res/mipmap-xhdpi/icon_monochrome.png +0 -0
  44. package/android/src/main/res/mipmap-xxhdpi/icon.png +0 -0
  45. package/android/src/main/res/mipmap-xxhdpi/icon_background.png +0 -0
  46. package/android/src/main/res/mipmap-xxhdpi/icon_foreground.png +0 -0
  47. package/android/src/main/res/mipmap-xxhdpi/icon_monochrome.png +0 -0
  48. package/android/src/main/res/mipmap-xxxhdpi/icon.png +0 -0
  49. package/android/src/main/res/mipmap-xxxhdpi/icon_background.png +0 -0
  50. package/android/src/main/res/mipmap-xxxhdpi/icon_foreground.png +0 -0
  51. package/android/src/main/res/mipmap-xxxhdpi/icon_monochrome.png +0 -0
  52. package/android/src/main/res/values/dimens.xml +9 -0
  53. package/android/src/main/res/values/strings.xml +61 -0
  54. package/android/src/main/res/values/styles.xml +25 -0
  55. package/android/src/main/res/values-fa/strings.xml +14 -0
  56. package/android/src/main/res/values-ko/strings.xml +54 -0
  57. package/android/src/main/res/xml/godot_provider_paths.xml +15 -0
  58. package/android/src/test/java/com/preeternal/reactnativegodot/NativeGodotModulePackageTest.kt +26 -0
  59. package/app.plugin.js +173 -0
  60. package/cpp/GodotModule.h +103 -0
  61. package/cpp/NativeGodotModule.cpp +825 -0
  62. package/cpp/NativeGodotModule.h +45 -0
  63. package/cpp/godot-log.h +64 -0
  64. package/ios/GodotModule.mm +661 -0
  65. package/ios/NativeGodotModuleProvider.h +35 -0
  66. package/ios/NativeGodotModuleProvider.mm +42 -0
  67. package/ios/RTNGodotView.h +42 -0
  68. package/ios/RTNGodotView.mm +711 -0
  69. package/ios/log.mm +38 -0
  70. package/lib/module/NativeNativeGodotModule.js +59 -0
  71. package/lib/module/NativeNativeGodotModule.js.map +1 -0
  72. package/lib/module/RTNGodotView.js +6 -0
  73. package/lib/module/RTNGodotView.js.map +1 -0
  74. package/lib/module/RTNGodotView.native.js +5 -0
  75. package/lib/module/RTNGodotView.native.js.map +1 -0
  76. package/lib/module/RTNGodotViewNativeComponent.ts +37 -0
  77. package/lib/module/index.js +30 -0
  78. package/lib/module/index.js.map +1 -0
  79. package/lib/module/package.json +1 -0
  80. package/lib/typescript/package.json +1 -0
  81. package/lib/typescript/src/NativeNativeGodotModule.d.ts +26 -0
  82. package/lib/typescript/src/NativeNativeGodotModule.d.ts.map +1 -0
  83. package/lib/typescript/src/RTNGodotView.d.ts +7 -0
  84. package/lib/typescript/src/RTNGodotView.d.ts.map +1 -0
  85. package/lib/typescript/src/RTNGodotView.native.d.ts +3 -0
  86. package/lib/typescript/src/RTNGodotView.native.d.ts.map +1 -0
  87. package/lib/typescript/src/RTNGodotViewNativeComponent.d.ts +11 -0
  88. package/lib/typescript/src/RTNGodotViewNativeComponent.d.ts.map +1 -0
  89. package/lib/typescript/src/index.d.ts +6 -0
  90. package/lib/typescript/src/index.d.ts.map +1 -0
  91. package/package.json +262 -4
  92. package/prebuilt-utils.rb +36 -0
  93. package/react-native-godot.podspec +41 -0
  94. package/react-native.config.js +15 -0
  95. package/scripts/check-16kb.sh +136 -0
  96. package/scripts/check-packaged-artifacts.sh +154 -0
  97. package/scripts/ci/verify-prebuilt-install.cjs +39 -0
  98. package/scripts/download-prebuilt.js +274 -0
  99. package/src/NativeNativeGodotModule.ts +90 -0
  100. package/src/RTNGodotView.native.tsx +2 -0
  101. package/src/RTNGodotView.tsx +12 -0
  102. package/src/RTNGodotViewNativeComponent.ts +37 -0
  103. package/src/index.tsx +28 -0
@@ -0,0 +1,289 @@
1
+ import org.apache.tools.ant.taskdefs.condition.Os
2
+ import groovy.json.JsonSlurper
3
+
4
+ def safeAppExtGet(prop, fallback) {
5
+ def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
6
+ appProject?.ext?.has(prop) ? appProject.ext.get(prop) : fallback
7
+ }
8
+
9
+ def libGodotSupportedAbis() {
10
+ return ["armeabi-v7a", "arm64-v8a"]
11
+ }
12
+
13
+ def reactNativeArchitectures() {
14
+ if (project.ext.has("rtngodotArchitectures")) {
15
+ return project.ext.get("rtngodotArchitectures")
16
+ }
17
+
18
+ def availableAbis = libGodotSupportedAbis()
19
+ def requested = project.getProperties().get("reactNativeArchitectures")
20
+ def requestedAbis = requested ? requested.split(",")*.trim() : availableAbis
21
+ def supportedAbis = requestedAbis.findAll { availableAbis.contains(it) }
22
+ def unsupportedAbis = requestedAbis - supportedAbis
23
+
24
+ if (!unsupportedAbis.isEmpty()) {
25
+ logger.lifecycle(
26
+ "[RTNGodot] Ignoring unsupported Android ABIs ${unsupportedAbis}. " +
27
+ "The bundled LibGodot binaries support ${availableAbis}."
28
+ )
29
+ }
30
+
31
+ if (supportedAbis.isEmpty()) {
32
+ throw new GradleException(
33
+ "[RTNGodot] None of the requested Android ABIs (${requestedAbis}) are supported. " +
34
+ "Use one of ${availableAbis}."
35
+ )
36
+ }
37
+
38
+ project.ext.set("rtngodotArchitectures", supportedAbis)
39
+ return supportedAbis
40
+ }
41
+
42
+ def resolveBuildType() {
43
+ Gradle gradle = getGradle()
44
+ String tskReqStr = gradle.getStartParameter().getTaskRequests()['args'].toString()
45
+ return tskReqStr.contains('Release') ? 'release' : 'debug'
46
+ }
47
+
48
+ def resolveReactNativeDirectory() {
49
+ def reactNativeLocation = safeAppExtGet("REACT_NATIVE_NODE_MODULES_DIR", null)
50
+ if (reactNativeLocation != null) {
51
+ return file(reactNativeLocation).canonicalFile
52
+ }
53
+
54
+ def command = [
55
+ "node",
56
+ "--print",
57
+ "require.resolve('react-native/package.json', { paths: [process.argv[1], process.argv[2]] })",
58
+ projectDir.absolutePath,
59
+ rootProject.projectDir.absolutePath,
60
+ ]
61
+ def process = command.execute(null, projectDir)
62
+ def stdout = new StringBuilder()
63
+ def stderr = new StringBuilder()
64
+ process.consumeProcessOutput(stdout, stderr)
65
+ def exitCode = process.waitFor()
66
+
67
+ if (exitCode == 0) {
68
+ def packageJson = file(stdout.toString().trim())
69
+ if (packageJson.exists()) {
70
+ return packageJson.parentFile.canonicalFile
71
+ }
72
+ }
73
+
74
+ throw new GradleException(
75
+ "[RTNGodot] Unable to resolve react-native from ${projectDir}. " +
76
+ "Set the app extension property REACT_NATIVE_NODE_MODULES_DIR when using a non-standard package layout. " +
77
+ stderr.toString().trim()
78
+ )
79
+ }
80
+
81
+ def toPlatformFileString(String path) {
82
+ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
83
+ path = path.replace(File.separatorChar, '/' as char)
84
+ }
85
+ return path
86
+ }
87
+
88
+ def isNewArchitectureEnabled() {
89
+ return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
90
+ }
91
+
92
+ def reactNativeRootDir = resolveReactNativeDirectory()
93
+
94
+ def prefabHeadersDir = project.file("$buildDir/prefab-headers/rtngodot")
95
+
96
+ def getPrebuiltLibraryVersion(libName) {
97
+ // package.json resides at the repository root (one level up from android/)
98
+ def packageFile = file("$projectDir/../package.json")
99
+ if (!packageFile.exists()) {
100
+ throw new GradleException("Unable to locate package.json at ${packageFile}")
101
+ }
102
+
103
+ def json = new JsonSlurper().parse(packageFile)
104
+
105
+ def entry = json.prebuiltFiles?.find { it.name == libName }
106
+
107
+ if (!entry) {
108
+ throw new GradleException("Prebuilt entry not found for library '${libName}'. Ensure it exists in package.json.")
109
+ }
110
+
111
+ return entry.version
112
+ }
113
+
114
+ def libGodotVersion = getPrebuiltLibraryVersion("libgodot-android")
115
+ def godotCppVersion = getPrebuiltLibraryVersion("libgodot-cpp-android")
116
+ def libGodotMavenRepo = file("$projectDir/libs/libgodot-android/${libGodotVersion}").canonicalFile
117
+
118
+ if (!libGodotMavenRepo.isDirectory()) {
119
+ throw new GradleException(
120
+ "[RTNGodot] Bundled LibGodot Maven repository was not found at ${libGodotMavenRepo}. " +
121
+ "Run the package's download-prebuilt command before building Android."
122
+ )
123
+ }
124
+
125
+ // Maven repositories are not transitive. Register the repository bundled with this
126
+ // package directly on every consumer project, using this module's real location so
127
+ // hoisted dependencies, workspaces, portals, and conventional node_modules layouts
128
+ // all resolve without android.extraMavenRepos or expo-build-properties.
129
+ rootProject.allprojects { targetProject ->
130
+ if (targetProject.repositories.findByName("libgodot") == null) {
131
+ targetProject.repositories.maven {
132
+ name = "libgodot"
133
+ url = uri(libGodotMavenRepo)
134
+ content {
135
+ includeGroup("com.migeran.libgodot")
136
+ }
137
+ }
138
+ }
139
+
140
+ }
141
+
142
+ buildscript {
143
+ ext.safeExtGet = {prop, fallback ->
144
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
145
+ }
146
+ repositories {
147
+ google()
148
+ mavenCentral()
149
+ }
150
+ dependencies {
151
+ classpath("com.android.tools.build:gradle:8.2.1")
152
+ }
153
+ }
154
+
155
+ apply plugin: 'com.android.library'
156
+ if (project.extensions.findByName('kotlin') == null) {
157
+ apply plugin: 'kotlin-android'
158
+ }
159
+ apply from: "./fix-prefab.gradle"
160
+ apply plugin: 'com.facebook.react'
161
+
162
+
163
+ android {
164
+ compileSdk = safeExtGet('compileSdkVersion', 33)
165
+ namespace = "com.preeternal.reactnativegodot"
166
+
167
+ buildFeatures {
168
+ prefab = true
169
+ prefabPublishing = true
170
+ }
171
+
172
+ // If it doesn't exist
173
+ if( !prefabHeadersDir.exists() ) {
174
+ prefabHeadersDir.mkdirs()
175
+ }
176
+
177
+ prefab {
178
+ rtngodot {
179
+ headers = prefabHeadersDir.absolutePath
180
+ }
181
+ }
182
+
183
+
184
+ defaultConfig {
185
+ // SurfaceControl is the foundation of the embedded window implementation
186
+ // and is only available from Android 10 (API 29).
187
+ minSdk = 29
188
+ targetSdk = safeExtGet('targetSdkVersion', 33)
189
+ ndkVersion = safeExtGet('ndkVersion', "26.1.10909125")
190
+ consumerProguardFiles("consumer-rules.pro")
191
+ ndk {
192
+ // Specifies the ABI configurations of your native
193
+ // libraries Gradle should build and package with your app.
194
+ // abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a'
195
+ abiFilters(*reactNativeArchitectures())
196
+ }
197
+ externalNativeBuild {
198
+ cmake {
199
+ arguments "-DANDROID_STL=c++_shared",
200
+ "-DANDROID_TOOLCHAIN=clang",
201
+ "-DREACT_NATIVE_DIR=${toPlatformFileString(reactNativeRootDir.path)}",
202
+ "-DIS_NEW_ARCHITECTURE_ENABLED=${isNewArchitectureEnabled().toString()}",
203
+ "-DGODOT_CPP_VERSION=${godotCppVersion}"
204
+ }
205
+ }
206
+ }
207
+
208
+ sourceSets {
209
+ main {
210
+ java.srcDirs += ['src/generated/java']
211
+ }
212
+ }
213
+
214
+ externalNativeBuild {
215
+ cmake {
216
+ path "src/main/cpp/CMakeLists.txt"
217
+ }
218
+ }
219
+
220
+ packagingOptions {
221
+ doNotStrip resolveBuildType() == 'debug' ? "**/**/*.so" : ''
222
+ excludes = [
223
+ "META-INF",
224
+ "META-INF/**",
225
+ "**/libc++_shared.so",
226
+ "**/libfolly_json.so",
227
+ "**/libfolly_runtime.so",
228
+ "**/libglog.so",
229
+ "**/libjsi.so",
230
+ "**/libreactnative.so",
231
+ "**/libreactnativejni.so",
232
+ "**/libreact_codegen_rncore.so",
233
+ "**/libreact_cxxreactpackage.so",
234
+ "**/libreact_debug.so",
235
+ "**/libreact_nativemodule_core.so",
236
+ "**/libreact_render_componentregistry.so",
237
+ "**/libreact_render_core.so",
238
+ "**/libreact_render_debug.so",
239
+ "**/libreact_render_graphics.so",
240
+ "**/libreact_render_imagemanager.so",
241
+ "**/libreact_render_mapbuffer.so",
242
+ "**/libreact_utils.so",
243
+ "**/librrc_image.so",
244
+ "**/librrc_view.so",
245
+ "**/libreact_newarchdefaults.so",
246
+ "**/libturbomodulejsijni.so",
247
+ "**/libyoga.so",
248
+ "**/libfabricjni.so",
249
+ "**/libfbjni.so",
250
+ "**/libhermes.so",
251
+ "**/libhermes-executor-debug.so",
252
+ "**/libhermes_executor.so",
253
+ "**/libjscexecutor.so",
254
+ "**/libv8executor.so",
255
+ ]
256
+ }
257
+ }
258
+
259
+ repositories {
260
+ maven {
261
+ name = "libgodot"
262
+ url = uri(libGodotMavenRepo)
263
+ content {
264
+ includeGroup("com.migeran.libgodot")
265
+ }
266
+ }
267
+ mavenCentral()
268
+ google()
269
+ }
270
+
271
+ dependencies {
272
+ implementation 'com.facebook.react:react-native'
273
+ implementation project(':react-native-worklets')
274
+ api "com.migeran.libgodot:godot:${libGodotVersion}-SNAPSHOT"
275
+ testImplementation 'junit:junit:4.13.2'
276
+ }
277
+
278
+ task deleteCmakeCache() {
279
+ doFirst {
280
+ delete "${projectDir}/.cxx"
281
+ }
282
+ }
283
+
284
+ tasks.configureEach { task ->
285
+ // C++ clean
286
+ if (task.name.contains('clean')) {
287
+ task.dependsOn(deleteCmakeCache)
288
+ }
289
+ }
@@ -0,0 +1,19 @@
1
+ # The embedded Godot engine calls these Java APIs through JNI. R8 cannot see
2
+ # those calls and would otherwise remove or rename the entry points.
3
+ -keep,allowoptimization class com.preeternal.reactnativegodot.NativeGodotModuleModule { *; }
4
+ -keep,allowoptimization class com.preeternal.reactnativegodot.RTNLibGodot { *; }
5
+
6
+ -keep,allowoptimization class org.godotengine.godot.Dictionary { *; }
7
+ -keep,allowoptimization class org.godotengine.godot.Godot { *; }
8
+ -keep,allowoptimization class org.godotengine.godot.GodotIO { *; }
9
+ -keep,allowoptimization class org.godotengine.godot.io.directory.DirectoryAccessHandler { *; }
10
+ -keep,allowoptimization class org.godotengine.godot.io.file.FileAccessHandler { *; }
11
+ -keep,allowoptimization class org.godotengine.godot.tts.GodotTTS { *; }
12
+ -keep,allowoptimization class org.godotengine.godot.utils.GodotNetUtils { *; }
13
+ -keep,allowoptimization class org.godotengine.godot.variant.Callable { *; }
14
+
15
+ # Godot discovers Android plugin methods through this runtime annotation.
16
+ -keep @interface org.godotengine.godot.plugin.UsedByGodot
17
+ -keepclassmembers,allowoptimization class * {
18
+ @org.godotengine.godot.plugin.UsedByGodot <methods>;
19
+ }
@@ -0,0 +1,54 @@
1
+ // From: react-native-worklets/android/fix-prefab.gradle
2
+
3
+ tasks.configureEach { task ->
4
+ // Make sure that we generate our prefab publication file only after having built the native library
5
+ // so that not a header publication file, but a full configuration publication will be generated, which
6
+ // will include the .so file
7
+
8
+ def prefabConfigurePattern = ~/^prefab(.+)ConfigurePackage$/
9
+ def matcher = task.name =~ prefabConfigurePattern
10
+ if (matcher.matches()) {
11
+ def variantName = matcher[0][1]
12
+ task.outputs.upToDateWhen { false }
13
+ task.dependsOn("externalNativeBuild${variantName}")
14
+ }
15
+
16
+ }
17
+
18
+ afterEvaluate {
19
+ def abis = reactNativeArchitectures()
20
+ rootProject.allprojects.each { proj ->
21
+ if (proj === rootProject) return
22
+
23
+ def dependsOnThisLib = proj.configurations.any { config ->
24
+ config.canBeResolved && config.dependencies.any { dep ->
25
+ dep.group == project.group && dep.name == project.name
26
+ }
27
+ }
28
+ if (!dependsOnThisLib && proj != project) return
29
+
30
+ if (!proj.plugins.hasPlugin('com.android.application') && !proj.plugins.hasPlugin('com.android.library')) {
31
+ return
32
+ }
33
+
34
+ // Touch the prefab_config.json files to ensure that in ExternalNativeJsonGenerator.kt we will re-trigger the prefab CLI to
35
+ // generate a libnameConfig.cmake file that will contain our native library (.so).
36
+ // See this condition: https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:build-system/gradle-core/src/main/java/com/android/build/gradle/tasks/ExternalNativeJsonGenerator.kt;l=207-219?q=createPrefabBuildSystemGlue
37
+ // This workaround only needs existing CMake caches, not AGP Variant objects.
38
+ // Consumers may already be evaluated, so registering onVariants here is too late.
39
+ def cxxDir = new File(proj.projectDir, ".cxx")
40
+ if (!cxxDir.exists()) return
41
+ cxxDir.eachDir { searchDir ->
42
+ abis.each { abi ->
43
+ def matches = []
44
+ searchDir.eachDir { randomDir ->
45
+ def prefabFile = new File(randomDir, "${abi}/prefab_config.json")
46
+ if (prefabFile.exists()) matches << prefabFile
47
+ }
48
+ matches.each { prefabConfig ->
49
+ prefabConfig.setLastModified(System.currentTimeMillis())
50
+ }
51
+ }
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,74 @@
1
+ project(rtngodot)
2
+
3
+ cmake_minimum_required(VERSION 3.13)
4
+ set(CMAKE_VERBOSE_MAKEFILE on)
5
+
6
+ set (CMAKE_CXX_STANDARD 20)
7
+
8
+ include("${REACT_NATIVE_DIR}/ReactAndroid/cmake-utils/folly-flags.cmake")
9
+ add_compile_options(${folly_FLAGS})
10
+
11
+ include("${REACT_NATIVE_DIR}/ReactCommon/cmake-utils/react-native-flags.cmake")
12
+
13
+ string(APPEND CMAKE_CXX_FLAGS " -fexceptions -fno-omit-frame-pointer -frtti -fstack-protector-all -std=c++${CMAKE_CXX_STANDARD} -Wall")
14
+
15
+ if(${IS_NEW_ARCHITECTURE_ENABLED})
16
+ string(APPEND CMAKE_CXX_FLAGS " -DRCT_NEW_ARCH_ENABLED")
17
+ endif()
18
+
19
+ if(NOT ${CMAKE_BUILD_TYPE} MATCHES "Debug")
20
+ string(APPEND CMAKE_CXX_FLAGS " -DNDEBUG")
21
+ endif()
22
+
23
+ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
24
+
25
+ # Prefab packages from React Native
26
+ find_package(fbjni REQUIRED CONFIG)
27
+ add_library(fbjni ALIAS fbjni::fbjni)
28
+ find_package(ReactAndroid REQUIRED CONFIG)
29
+ add_library(jsi ALIAS ReactAndroid::jsi)
30
+ add_library(reactnative ALIAS ReactAndroid::reactnative)
31
+ find_package(react-native-worklets REQUIRED CONFIG)
32
+
33
+ add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../../../build/generated/source/codegen/jni" generated)
34
+ set(LIBGODOT_CPP_VERSION ${GODOT_CPP_VERSION})
35
+ set(LIBGODOT_CPP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/libgodot-cpp-android/${LIBGODOT_CPP_VERSION}/godot-cpp-android)
36
+
37
+ add_library(
38
+ godot-cpp
39
+ STATIC
40
+ IMPORTED
41
+ )
42
+ set_target_properties(godot-cpp PROPERTIES IMPORTED_LOCATION ${LIBGODOT_CPP_DIR}/${ANDROID_ABI}/libgodot-cpp.a)
43
+ target_include_directories(godot-cpp INTERFACE ${LIBGODOT_CPP_DIR}/include)
44
+
45
+ file(GLOB rtngodot_SRC CONFIGURE_DEPENDS *.cpp)
46
+ file(GLOB rtngodot_cpp_SRC CONFIGURE_DEPENDS ../../../../cpp/*.cpp)
47
+ add_library(rtngodot SHARED ${rtngodot_SRC} ${rtngodot_cpp_SRC})
48
+
49
+ # Android 15+ devices may use 16 KiB memory pages. Keep this module loadable
50
+ # there instead of relying on the OS page-size compatibility mode.
51
+ target_link_options(rtngodot PRIVATE "-Wl,-z,max-page-size=16384")
52
+
53
+ target_include_directories(rtngodot PRIVATE
54
+ ${CMAKE_CURRENT_SOURCE_DIR}
55
+ "../../../../cpp"
56
+ )
57
+
58
+ target_link_libraries(
59
+ rtngodot
60
+ fbjni::fbjni
61
+ ReactAndroid::jsi
62
+ ReactAndroid::reactnative
63
+ react-native-worklets::worklets
64
+ react_codegen_RTNGodotSpec
65
+ )
66
+
67
+ target_link_libraries(rtngodot
68
+ log
69
+ godot-cpp
70
+ OpenSLES
71
+ android
72
+ z
73
+ dl
74
+ )