Skip to content

Commit

Permalink
Fix LogHeartbeatInternal (#628)
Browse files Browse the repository at this point in the history
When Swig generating "%csmethodmodifiers" code block, instead of keeping
all preprocesser directives like "#if FIREBASE_PLATFORM_DESKTOP", it
seem to preprocess the block directly and remove codes.

In this case, Swig would consider FIREBASE_PLATFORM_DESKTOP never
defined and remove the entire block in the generated code.

This can be easily verified with
```
python scripts/build_scripts/build_zips.py --platform=macos --apis=auth
```
  • Loading branch information
chkuang-g authored Feb 13, 2023
1 parent e974dd1 commit c370f54
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions app/src/swig/app.i
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ static App *AppGetOrCreateInstance(const AppOptions *options,
return instance;
}

// Log a heartbeat only if the current platform is desktop platforms.
static void LogHeartbeatForDesktop(App* app) {
#if FIREBASE_PLATFORM_DESKTOP
// Only need to call LogHeartbeat on desktop, since native mobile SDKs
// Will handle heartbeat logging internally.
app->LogHeartbeat();
#endif // FIREBASE_PLATFORM_DESKTOP
}

// Decrease the reference count for the app. When the reference count reaches
// 0, the App will be deleted.
static void AppReleaseReference(App* app) {
Expand Down Expand Up @@ -862,11 +871,11 @@ static firebase::AppOptions* AppOptionsLoadFromJsonConfig(const char* config) {
}
// TODO(smiles): Improve error code passing from C++ to C# so that
// we don't need to parse magic strings from the error message.

if (errorMessage.IndexOf("Please verify the AAR") >= 0) {
errorMessage += "\n" + Firebase.ErrorMessages.DependencyNotFoundErrorMessage;
}

// util_android.cc)
throw new Firebase.InitializationException(initResult, errorMessage);
} catch (System.Exception exception) {
Expand Down Expand Up @@ -1318,11 +1327,7 @@ namespace callback {

%csmethodmodifiers LogHeartbeatInternal(App* app) "internal";
static void LogHeartbeatInternal(App* app) {
#if FIREBASE_PLATFORM_DESKTOP
// Only need to call LogHeartbeat on desktop, since native mobile SDKs
// Will handle heartbeat logging internally.
app->LogHeartbeat();
#endif // FIREBASE_PLATFORM_DESKTOP
firebase::LogHeartbeatForDesktop(app);
}

%csmethodmodifiers AppSetDefaultConfigPath(const char* path) "internal";
Expand Down

0 comments on commit c370f54

Please sign in to comment.