diff --git a/game-activity/csrc/game-activity/GameActivity.cpp b/game-activity/csrc/game-activity/GameActivity.cpp index a872422..d240f18 100644 --- a/game-activity/csrc/game-activity/GameActivity.cpp +++ b/game-activity/csrc/game-activity/GameActivity.cpp @@ -1295,9 +1295,13 @@ extern "C" int GameActivity_register(JNIEnv *env) { NELEM(g_methods)); } +// XXX: This symbol is renamed with a _C suffix and then re-exported from +// Rust because Rust/Cargo don't give us a way to directly export symbols +// from C/C++ code: https://github.com/rust-lang/rfcs/issues/2771 +// // Register this method so that GameActiviy_register does not need to be called // manually. -extern "C" jlong Java_com_google_androidgamesdk_GameActivity_loadNativeCode( +extern "C" jlong Java_com_google_androidgamesdk_GameActivity_loadNativeCode_C( JNIEnv *env, jobject javaGameActivity, jstring path, jstring funcName, jstring internalDataDir, jstring obbDir, jstring externalDataDir, jobject jAssetMgr, jbyteArray savedState) { diff --git a/game-activity/csrc/game-activity/native_app_glue/android_native_app_glue.c b/game-activity/csrc/game-activity/native_app_glue/android_native_app_glue.c index f1b385f..7ae073d 100644 --- a/game-activity/csrc/game-activity/native_app_glue/android_native_app_glue.c +++ b/game-activity/csrc/game-activity/native_app_glue/android_native_app_glue.c @@ -205,7 +205,7 @@ static void* android_app_entry(void* param) { pthread_cond_broadcast(&android_app->cond); pthread_mutex_unlock(&android_app->mutex); - android_main(android_app); + _rust_glue_entry(android_app); android_app_destroy(android_app); return NULL; @@ -542,7 +542,7 @@ static void onWindowInsetsChanged(GameActivity* activity) { } JNIEXPORT -void GameActivity_onCreate(GameActivity* activity, void* savedState, +void GameActivity_onCreate_C(GameActivity* activity, void* savedState, size_t savedStateSize) { LOGV("Creating: %p", activity); activity->callbacks->onDestroy = onDestroy; diff --git a/game-activity/csrc/game-activity/native_app_glue/android_native_app_glue.h b/game-activity/csrc/game-activity/native_app_glue/android_native_app_glue.h index 9dfe3a5..4f19c8d 100644 --- a/game-activity/csrc/game-activity/native_app_glue/android_native_app_glue.h +++ b/game-activity/csrc/game-activity/native_app_glue/android_native_app_glue.h @@ -452,10 +452,10 @@ void android_app_clear_motion_events(struct android_input_buffer* inputBuffer); void android_app_clear_key_events(struct android_input_buffer* inputBuffer); /** - * This is the function that application code must implement, representing - * the main entry to the app. + * This is a springboard into the Rust glue layer that wraps calling the + * main entry for the app itself. */ -extern void android_main(struct android_app* app); +extern void _rust_glue_entry(struct android_app* app); /** * Set the filter to use when processing key events. @@ -479,6 +479,9 @@ void android_app_set_key_event_filter(struct android_app* app, void android_app_set_motion_event_filter(struct android_app* app, android_motion_event_filter filter); + +void GameActivity_onCreate_C(GameActivity* activity, void* savedState, + size_t savedStateSize); #ifdef __cplusplus } #endif