@preeternal/react-native-godot 0.0.0-stage → 0.2.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 (109) hide show
  1. package/LICENSE +22 -0
  2. package/Package.swift +106 -0
  3. package/README.md +590 -2
  4. package/android/build.gradle +291 -0
  5. package/android/consumer-rules.pro +20 -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 +78 -0
  9. package/android/src/main/cpp/GodotModule.cpp +764 -0
  10. package/android/src/main/cpp/OnLoad.cpp +66 -0
  11. package/android/src/main/cpp/libgodot_android.h +73 -0
  12. package/android/src/main/cpp/libgodot_jni.cpp +658 -0
  13. package/android/src/main/cpp/libgodot_jni.h +116 -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/RTNGodotIO.kt +123 -0
  20. package/android/src/main/java/com/preeternal/reactnativegodot/RTNGodotView.kt +92 -0
  21. package/android/src/main/java/com/preeternal/reactnativegodot/RTNGodotViewManager.kt +34 -0
  22. package/android/src/main/java/com/preeternal/reactnativegodot/RTNLibGodot.kt +215 -0
  23. package/android/src/main/res/layout/downloading_expansion.xml +165 -0
  24. package/android/src/main/res/layout/godot_app_layout.xml +5 -0
  25. package/android/src/main/res/layout/snackbar.xml +27 -0
  26. package/android/src/main/res/layout/status_bar_ongoing_event_progress_bar.xml +108 -0
  27. package/android/src/main/res/mipmap/icon.png +0 -0
  28. package/android/src/main/res/mipmap/icon_background.png +0 -0
  29. package/android/src/main/res/mipmap/icon_foreground.png +0 -0
  30. package/android/src/main/res/mipmap/icon_monochrome.png +0 -0
  31. package/android/src/main/res/mipmap-anydpi-v26/icon.xml +8 -0
  32. package/android/src/main/res/mipmap-anydpi-v26/themed_icon.xml +11 -0
  33. package/android/src/main/res/mipmap-hdpi/icon.png +0 -0
  34. package/android/src/main/res/mipmap-hdpi/icon_background.png +0 -0
  35. package/android/src/main/res/mipmap-hdpi/icon_foreground.png +0 -0
  36. package/android/src/main/res/mipmap-hdpi/icon_monochrome.png +0 -0
  37. package/android/src/main/res/mipmap-mdpi/icon.png +0 -0
  38. package/android/src/main/res/mipmap-mdpi/icon_background.png +0 -0
  39. package/android/src/main/res/mipmap-mdpi/icon_foreground.png +0 -0
  40. package/android/src/main/res/mipmap-mdpi/icon_monochrome.png +0 -0
  41. package/android/src/main/res/mipmap-xhdpi/icon.png +0 -0
  42. package/android/src/main/res/mipmap-xhdpi/icon_background.png +0 -0
  43. package/android/src/main/res/mipmap-xhdpi/icon_foreground.png +0 -0
  44. package/android/src/main/res/mipmap-xhdpi/icon_monochrome.png +0 -0
  45. package/android/src/main/res/mipmap-xxhdpi/icon.png +0 -0
  46. package/android/src/main/res/mipmap-xxhdpi/icon_background.png +0 -0
  47. package/android/src/main/res/mipmap-xxhdpi/icon_foreground.png +0 -0
  48. package/android/src/main/res/mipmap-xxhdpi/icon_monochrome.png +0 -0
  49. package/android/src/main/res/mipmap-xxxhdpi/icon.png +0 -0
  50. package/android/src/main/res/mipmap-xxxhdpi/icon_background.png +0 -0
  51. package/android/src/main/res/mipmap-xxxhdpi/icon_foreground.png +0 -0
  52. package/android/src/main/res/mipmap-xxxhdpi/icon_monochrome.png +0 -0
  53. package/android/src/main/res/values/dimens.xml +9 -0
  54. package/android/src/main/res/values/strings.xml +61 -0
  55. package/android/src/main/res/values/styles.xml +25 -0
  56. package/android/src/main/res/values-fa/strings.xml +14 -0
  57. package/android/src/main/res/values-ko/strings.xml +54 -0
  58. package/android/src/main/res/xml/godot_provider_paths.xml +15 -0
  59. package/android/src/test/java/com/preeternal/reactnativegodot/NativeGodotModulePackageTest.kt +26 -0
  60. package/app.plugin.js +169 -0
  61. package/cpp/AppleRendererPolicy.h +95 -0
  62. package/cpp/GodotModule.h +126 -0
  63. package/cpp/LibGodotABI.h +52 -0
  64. package/cpp/NativeGodotModule.cpp +825 -0
  65. package/cpp/NativeGodotModule.h +45 -0
  66. package/cpp/godot-log.h +64 -0
  67. package/ios/GodotModule.mm +695 -0
  68. package/ios/NativeGodotModuleProvider.h +35 -0
  69. package/ios/NativeGodotModuleProvider.mm +42 -0
  70. package/ios/RTNGodotView.h +42 -0
  71. package/ios/RTNGodotView.mm +671 -0
  72. package/ios/log.mm +38 -0
  73. package/lib/module/NativeNativeGodotModule.js +59 -0
  74. package/lib/module/NativeNativeGodotModule.js.map +1 -0
  75. package/lib/module/RTNGodotView.js +6 -0
  76. package/lib/module/RTNGodotView.js.map +1 -0
  77. package/lib/module/RTNGodotView.native.js +5 -0
  78. package/lib/module/RTNGodotView.native.js.map +1 -0
  79. package/lib/module/RTNGodotViewNativeComponent.ts +37 -0
  80. package/lib/module/index.js +30 -0
  81. package/lib/module/index.js.map +1 -0
  82. package/lib/module/package.json +1 -0
  83. package/lib/typescript/package.json +1 -0
  84. package/lib/typescript/src/NativeNativeGodotModule.d.ts +26 -0
  85. package/lib/typescript/src/NativeNativeGodotModule.d.ts.map +1 -0
  86. package/lib/typescript/src/RTNGodotView.d.ts +7 -0
  87. package/lib/typescript/src/RTNGodotView.d.ts.map +1 -0
  88. package/lib/typescript/src/RTNGodotView.native.d.ts +3 -0
  89. package/lib/typescript/src/RTNGodotView.native.d.ts.map +1 -0
  90. package/lib/typescript/src/RTNGodotViewNativeComponent.d.ts +11 -0
  91. package/lib/typescript/src/RTNGodotViewNativeComponent.d.ts.map +1 -0
  92. package/lib/typescript/src/index.d.ts +6 -0
  93. package/lib/typescript/src/index.d.ts.map +1 -0
  94. package/package.json +282 -4
  95. package/prebuilt-utils.rb +46 -0
  96. package/react-native-godot.podspec +41 -0
  97. package/react-native.config.js +16 -0
  98. package/scripts/check-16kb.sh +136 -0
  99. package/scripts/check-packaged-artifacts.sh +156 -0
  100. package/scripts/ci/verify-ios-simulator.py +48 -0
  101. package/scripts/ci/verify-prebuilt-install.cjs +41 -0
  102. package/scripts/download-prebuilt.js +283 -0
  103. package/scripts/prebuilt-config.js +80 -0
  104. package/scripts/spm-autolinking-plugin.js +87 -0
  105. package/src/NativeNativeGodotModule.ts +90 -0
  106. package/src/RTNGodotView.native.tsx +2 -0
  107. package/src/RTNGodotView.tsx +12 -0
  108. package/src/RTNGodotViewNativeComponent.ts +37 -0
  109. package/src/index.tsx +28 -0
@@ -0,0 +1,291 @@
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 selectionProcess = [
97
+ "node", file("$projectDir/../scripts/prebuilt-config.js").absolutePath,
98
+ "--app-root", rootProject.projectDir.absolutePath,
99
+ ].execute(null, projectDir)
100
+ def selectionOut = new StringBuilder()
101
+ def selectionErr = new StringBuilder()
102
+ selectionProcess.consumeProcessOutput(selectionOut, selectionErr)
103
+ if (selectionProcess.waitFor() != 0) {
104
+ throw new GradleException("[RTNGodot] Unable to select LibGodot: ${selectionErr}")
105
+ }
106
+ def selectedPrebuilts = new JsonSlurper().parseText(selectionOut.toString()).prebuiltFiles
107
+
108
+ def getPrebuiltLibrary = { libName ->
109
+ def entry = selectedPrebuilts.find { it.name == libName }
110
+
111
+ if (!entry) {
112
+ throw new GradleException("Prebuilt entry not found for library '${libName}'. Ensure it exists in package.json.")
113
+ }
114
+
115
+ return entry
116
+ }
117
+
118
+ def libGodotPackage = getPrebuiltLibrary("libgodot-android")
119
+ def libGodotVersion = libGodotPackage.version
120
+ def libGodotMavenVersion = libGodotPackage.maven_version
121
+ def godotCppVersion = getPrebuiltLibrary("libgodot-cpp-android").version
122
+ def libGodotMavenRepo = file("$projectDir/libs/libgodot-android/${libGodotVersion}").canonicalFile
123
+
124
+ if (!libGodotMavenVersion) {
125
+ throw new GradleException("[RTNGodot] Android Maven version is missing from package.json.")
126
+ }
127
+
128
+ if (!libGodotMavenRepo.isDirectory()) {
129
+ throw new GradleException(
130
+ "[RTNGodot] LibGodot Maven repository was not found at ${libGodotMavenRepo}. " +
131
+ "Run the package's download-prebuilt command before building Android."
132
+ )
133
+ }
134
+
135
+ // Maven repositories are not transitive. Register the repository bundled with this
136
+ // package directly on every consumer project, using this module's real location so
137
+ // hoisted dependencies, workspaces, portals, and conventional node_modules layouts
138
+ // all resolve without android.extraMavenRepos or expo-build-properties.
139
+ rootProject.allprojects { targetProject ->
140
+ if (targetProject.repositories.findByName("libgodot") == null) {
141
+ targetProject.repositories.maven {
142
+ name = "libgodot"
143
+ url = uri(libGodotMavenRepo)
144
+ content {
145
+ includeGroup("com.migeran.libgodot")
146
+ }
147
+ }
148
+ }
149
+ }
150
+
151
+ buildscript {
152
+ ext.safeExtGet = {prop, fallback ->
153
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
154
+ }
155
+ repositories {
156
+ google()
157
+ mavenCentral()
158
+ }
159
+ dependencies {
160
+ classpath("com.android.tools.build:gradle:8.2.1")
161
+ }
162
+ }
163
+
164
+ apply plugin: 'com.android.library'
165
+ if (project.extensions.findByName('kotlin') == null) {
166
+ apply plugin: 'kotlin-android'
167
+ }
168
+ apply from: "./fix-prefab.gradle"
169
+ apply plugin: 'com.facebook.react'
170
+
171
+
172
+ android {
173
+ compileSdk = safeExtGet('compileSdkVersion', 33)
174
+ namespace = "com.preeternal.reactnativegodot"
175
+
176
+ buildFeatures {
177
+ prefab = true
178
+ prefabPublishing = true
179
+ }
180
+
181
+ // If it doesn't exist
182
+ if( !prefabHeadersDir.exists() ) {
183
+ prefabHeadersDir.mkdirs()
184
+ }
185
+
186
+ prefab {
187
+ rtngodot {
188
+ headers = prefabHeadersDir.absolutePath
189
+ }
190
+ }
191
+
192
+
193
+ defaultConfig {
194
+ // SurfaceControl is the foundation of the embedded window implementation
195
+ // and is only available from Android 10 (API 29).
196
+ minSdk = 29
197
+ targetSdk = safeExtGet('targetSdkVersion', 33)
198
+ ndkVersion = safeExtGet('ndkVersion', "26.1.10909125")
199
+ consumerProguardFiles("consumer-rules.pro")
200
+ ndk {
201
+ // Specifies the ABI configurations of your native
202
+ // libraries Gradle should build and package with your app.
203
+ // abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a'
204
+ abiFilters(*reactNativeArchitectures())
205
+ }
206
+ externalNativeBuild {
207
+ cmake {
208
+ arguments "-DANDROID_STL=c++_shared",
209
+ "-DANDROID_TOOLCHAIN=clang",
210
+ "-DREACT_NATIVE_DIR=${toPlatformFileString(reactNativeRootDir.path)}",
211
+ "-DIS_NEW_ARCHITECTURE_ENABLED=${isNewArchitectureEnabled().toString()}",
212
+ "-DGODOT_CPP_VERSION=${godotCppVersion}"
213
+ }
214
+ }
215
+ }
216
+
217
+ sourceSets {
218
+ main {
219
+ java.srcDirs += ['src/generated/java']
220
+ }
221
+ }
222
+
223
+ externalNativeBuild {
224
+ cmake {
225
+ path "src/main/cpp/CMakeLists.txt"
226
+ }
227
+ }
228
+
229
+ packagingOptions {
230
+ doNotStrip resolveBuildType() == 'debug' ? "**/**/*.so" : ''
231
+ excludes = [
232
+ "META-INF",
233
+ "META-INF/**",
234
+ "**/libc++_shared.so",
235
+ "**/libfolly_json.so",
236
+ "**/libfolly_runtime.so",
237
+ "**/libglog.so",
238
+ "**/libjsi.so",
239
+ "**/libreactnative.so",
240
+ "**/libreactnativejni.so",
241
+ "**/libreact_codegen_rncore.so",
242
+ "**/libreact_cxxreactpackage.so",
243
+ "**/libreact_debug.so",
244
+ "**/libreact_nativemodule_core.so",
245
+ "**/libreact_render_componentregistry.so",
246
+ "**/libreact_render_core.so",
247
+ "**/libreact_render_debug.so",
248
+ "**/libreact_render_graphics.so",
249
+ "**/libreact_render_imagemanager.so",
250
+ "**/libreact_render_mapbuffer.so",
251
+ "**/libreact_utils.so",
252
+ "**/librrc_image.so",
253
+ "**/librrc_view.so",
254
+ "**/libreact_newarchdefaults.so",
255
+ "**/libturbomodulejsijni.so",
256
+ "**/libyoga.so",
257
+ "**/libfabricjni.so",
258
+ "**/libfbjni.so",
259
+ "**/libhermes.so",
260
+ "**/libhermes-executor-debug.so",
261
+ "**/libhermes_executor.so",
262
+ "**/libjscexecutor.so",
263
+ "**/libv8executor.so",
264
+ ]
265
+ }
266
+ }
267
+
268
+ repositories {
269
+ mavenCentral()
270
+ google()
271
+ }
272
+
273
+ dependencies {
274
+ implementation 'com.facebook.react:react-native'
275
+ implementation project(':react-native-worklets')
276
+ api "com.migeran.libgodot:godot:${libGodotMavenVersion}"
277
+ testImplementation 'junit:junit:4.13.2'
278
+ }
279
+
280
+ task deleteCmakeCache() {
281
+ doFirst {
282
+ delete "${projectDir}/.cxx"
283
+ }
284
+ }
285
+
286
+ tasks.configureEach { task ->
287
+ // C++ clean
288
+ if (task.name.contains('clean')) {
289
+ task.dependsOn(deleteCmakeCache)
290
+ }
291
+ }
@@ -0,0 +1,20 @@
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
+ -keep,allowoptimization class com.preeternal.reactnativegodot.RTNGodotIO { *; }
6
+
7
+ -keep,allowoptimization class org.godotengine.godot.Dictionary { *; }
8
+ -keep,allowoptimization class org.godotengine.godot.Godot { *; }
9
+ -keep,allowoptimization class org.godotengine.godot.GodotIO { *; }
10
+ -keep,allowoptimization class org.godotengine.godot.io.directory.DirectoryAccessHandler { *; }
11
+ -keep,allowoptimization class org.godotengine.godot.io.file.FileAccessHandler { *; }
12
+ -keep,allowoptimization class org.godotengine.godot.tts.GodotTTS { *; }
13
+ -keep,allowoptimization class org.godotengine.godot.utils.GodotNetUtils { *; }
14
+ -keep,allowoptimization class org.godotengine.godot.variant.Callable { *; }
15
+
16
+ # Godot discovers Android plugin methods through this runtime annotation.
17
+ -keep @interface org.godotengine.godot.plugin.UsedByGodot
18
+ -keepclassmembers,allowoptimization class * {
19
+ @org.godotengine.godot.plugin.UsedByGodot <methods>;
20
+ }
@@ -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,78 @@
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
+ set(LIBGODOT_CPP_ABI_DIR ${LIBGODOT_CPP_DIR}/${ANDROID_ABI})
37
+ if(NOT EXISTS "${LIBGODOT_CPP_ABI_DIR}/include/godot_cpp/variant/string_name.hpp")
38
+ message(FATAL_ERROR "LibGodot requires generated headers for ${ANDROID_ABI}. Install the selected ABI-specific godot-cpp package.")
39
+ endif()
40
+
41
+ add_library(
42
+ godot-cpp
43
+ STATIC
44
+ IMPORTED
45
+ )
46
+ set_target_properties(godot-cpp PROPERTIES IMPORTED_LOCATION ${LIBGODOT_CPP_ABI_DIR}/libgodot-cpp.a)
47
+ target_include_directories(godot-cpp INTERFACE ${LIBGODOT_CPP_ABI_DIR}/include)
48
+
49
+ file(GLOB rtngodot_SRC CONFIGURE_DEPENDS *.cpp)
50
+ file(GLOB rtngodot_cpp_SRC CONFIGURE_DEPENDS ../../../../cpp/*.cpp)
51
+ add_library(rtngodot SHARED ${rtngodot_SRC} ${rtngodot_cpp_SRC})
52
+
53
+ # Android 15+ devices may use 16 KiB memory pages. Keep this module loadable
54
+ # there instead of relying on the OS page-size compatibility mode.
55
+ target_link_options(rtngodot PRIVATE "-Wl,-z,max-page-size=16384")
56
+
57
+ target_include_directories(rtngodot PRIVATE
58
+ ${CMAKE_CURRENT_SOURCE_DIR}
59
+ "../../../../cpp"
60
+ )
61
+
62
+ target_link_libraries(
63
+ rtngodot
64
+ fbjni::fbjni
65
+ ReactAndroid::jsi
66
+ ReactAndroid::reactnative
67
+ react-native-worklets::worklets
68
+ react_codegen_RTNGodotSpec
69
+ )
70
+
71
+ target_link_libraries(rtngodot
72
+ log
73
+ godot-cpp
74
+ OpenSLES
75
+ android
76
+ z
77
+ dl
78
+ )