Skip to content

Commit 1fa4b6a

Browse files
ribjb55
authored andcommitted
GameActivity PATCH: rename C symbols that need export
Give C symbols that need to be exported a `_C` suffix so that they can be linked into a Rust symbol with the correct name (Since we can't directly export from C/C++ with Rust+Cargo) See: rust-lang/rfcs#2771
1 parent 1058735 commit 1fa4b6a

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

android-activity/game-activity-csrc/game-activity/GameActivity.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ static jlong initializeNativeCode_native(
538538
// read configuration for the first time
539539
readConfigurationValues(code, javaConfig);
540540

541-
GameActivity_onCreate(code, rawSavedState, rawSavedSize);
541+
GameActivity_onCreate_C(code, rawSavedState, rawSavedSize);
542542

543543
code->gameTextInput = GameTextInput_init(env, 0);
544544
GameTextInput_setEventCallback(code->gameTextInput,
@@ -1382,8 +1382,12 @@ extern "C" int GameActivity_register(JNIEnv *env) {
13821382
NELEM(g_methods));
13831383
}
13841384

1385+
// XXX: This symbol is renamed with a _C suffix and then re-exported from
1386+
// Rust because Rust/Cargo don't give us a way to directly export symbols
1387+
// from C/C++ code: https://github.com/rust-lang/rfcs/issues/2771
1388+
//
13851389
extern "C" JNIEXPORT jlong JNICALL
1386-
Java_com_google_androidgamesdk_GameActivity_initializeNativeCode(
1390+
Java_com_google_androidgamesdk_GameActivity_initializeNativeCode_C(
13871391
JNIEnv *env, jobject javaGameActivity, jstring internalDataDir,
13881392
jstring obbDir, jstring externalDataDir, jobject jAssetMgr,
13891393
jbyteArray savedState, jobject javaConfig) {

android-activity/game-activity-csrc/game-activity/GameActivity.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ typedef void GameActivity_createFunc(GameActivity* activity, void* savedState,
322322
* "android.app.func_name" string meta-data in your manifest to use a different
323323
* function.
324324
*/
325-
extern GameActivity_createFunc GameActivity_onCreate;
325+
extern GameActivity_createFunc GameActivity_onCreate_C;
326326

327327
/**
328328
* Finish the given activity. Its finish() method will be called, causing it

android-activity/game-activity-csrc/game-activity/native_app_glue/android_native_app_glue.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,9 +648,13 @@ static bool onEditorAction(GameActivity* activity, int action) {
648648
return true;
649649
}
650650

651+
// XXX: This symbol is renamed with a _C suffix and then re-exported from
652+
// Rust because Rust/Cargo don't give us a way to directly export symbols
653+
// from C/C++ code: https://github.com/rust-lang/rfcs/issues/2771
654+
//
651655
JNIEXPORT
652-
void GameActivity_onCreate(GameActivity* activity, void* savedState,
653-
size_t savedStateSize) {
656+
void GameActivity_onCreate_C(GameActivity* activity, void* savedState,
657+
size_t savedStateSize) {
654658
LOGV("Creating: %p", activity);
655659
activity->callbacks->onDestroy = onDestroy;
656660
activity->callbacks->onStart = onStart;

0 commit comments

Comments
 (0)