Skip to content

chore: Add PreBuildProcess for consoles#2518

Open
bitsandfoxes wants to merge 3 commits intomainfrom
chore/follow-up-switch
Open

chore: Add PreBuildProcess for consoles#2518
bitsandfoxes wants to merge 3 commits intomainfrom
chore/follow-up-switch

Conversation

@bitsandfoxes
Copy link
Contributor

Moving the stubs is a follow-up on the Switch support. Initially, I thought we'd reuse them for PlayStation and Xbox as well, but the native support on those platforms is provided via dynamic libs, degrading gracefully if not found. No need for stubs.

Instead, I've added a PreBuildProcess for each platform logging about the state of the configuration.

#skip-changelog

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


This PR will not appear in the changelog.


🤖 This preview updates automatically when you update the PR.

{
logger.LogInfo("Switch native libraries found:\n{0}",
string.Join("\n", existingFiles.Select(f => $" - {f}")));
importer.SetCompatibleWithPlatform(BuildTarget.Switch, false);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switch native support flag ignored when libraries present

Medium Severity

When all required native library files are present, the nativeSupportEnabled parameter is ignored and the stub is always disabled. This means native libraries will be linked even when the user has explicitly set SwitchNativeSupportEnabled to false. The nativeSupportEnabled check only occurs in the else branch when files are missing, but the user's preference to disable native support is not respected when files exist.

Fix in Cursor Fix in Web

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

{
logger.LogError("Failed to get PluginImporter for stub at '{0}'. Skipping stub configuration.", stubPath);
return;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switch stub path may be incorrect

High Severity

SwitchNativePluginBuildPreProcess looks up the stub at Packages/.../Plugins/Switch/sentry_native_stubs.c, but the removed code previously used Packages/.../Plugins/sentry_native_stubs.c. If the stub file wasn’t actually relocated in the package layout, AssetImporter.GetAtPath returns null and stub compatibility never gets toggled, leading to missing symbols or unintended no-op native behavior on Switch.

Fix in Cursor Fix in Web

{
"Assets/Plugins/Sentry/Switch/libsentry.a",
"Assets/Plugins/Sentry/Switch/libzstd.a",
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switch required files list incomplete

High Severity

RequiredFiles only checks for libsentry.a and libzstd.a, but Switch native support also depends on the helper functions used by SentryNativeSwitch (referenced in the stub comments as SentrySwitchHelpers.cpp). With only the archives present, the prebuild step can disable stubs and “accept” native support while the build still lacks required helper symbols.

Fix in Cursor Fix in Web

var logger = options?.DiagnosticLogger ?? new UnityLogger(new SentryUnityOptions());

ValidateNativePlugin(logger, options?.PlayStationNativeSupportEnabled ?? true);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Native support defaults enabled when unconfigured

Medium Severity

All three preprocessors pass options?.<Platform>NativeSupportEnabled ?? true, which treats missing/failed SentryScriptableObject.LoadOptions as “native support enabled.” This can emit LogError messages about missing console native binaries in projects where Sentry isn’t configured (i.e., options is null), potentially causing noisy builds or CI failures that gate on editor errors.

Additional Locations (2)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant