Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/compilerdefinitions #109

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

SimonDarksideJ
Copy link
Collaborator

Summary

Added a new document describing the pre-compiler definitions supported in MonoGame projects.

Additionally, I have reordered the TOC for more clarity:

  • Moved "Supported Platforms" up
  • Moved "Tools" under COntent Pipeline
  • Restructured the migration articles in a new "Migrating" group to reduce clutter
  • Added "Conditional Compilation

@SimonDarksideJ
Copy link
Collaborator Author

image

> ```csharp
> if(PlatformInfo.MonoGamePlatform == MonoGamePlatform.DesktopGL)
> {
> // The Client is running on the DesktopGL runtime
Copy link

Choose a reason for hiding this comment

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

Should we note that not all api's are available across all platforms? When using this Runtime method you cannot use Android or Steam API's for example, since the assembly won't be available.

For platform specific code (i.e Play Store integration etc) you really need to use #defines or include specific files in the head project.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, it is the one limitation with this only runtime method. Ideally, MG should expose some defines that can be consumed similar to other engines, but without an actual runtime component, I'm not sure it is possible.

Choose a reason for hiding this comment

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

afaik, each platform Nuget has a build Targets file. The DefineConstants MSbuild property could be added to if they are not already like

<DefineConstants>$(DefineConstants);__MONOGAME_ANDROID__<DefineConstants>

or

<DefineConstants>$(DefineConstants);__MONOGAME_DESKTOPGL__<DefineConstants>

if that is what you are thinking of?

See https://github.com/MonoGame/MonoGame/blob/249dc0dfa3d8c2182213fa03b4357d1e063cd71e/MonoGame.Framework/MonoGame.Framework.DesktopGL.targets#L4

and https://github.com/MonoGame/MonoGame/blob/249dc0dfa3d8c2182213fa03b4357d1e063cd71e/MonoGame.Framework/MonoGame.Framework.Android.targets

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@harry-cpp said something similar but the conversation didn't progress beyond that.

If those features could give us compile-time constants for MonoGame Platforms, then yes, that would be the answer (along the style naming defined in the guide)

@SimonDarksideJ SimonDarksideJ marked this pull request as draft March 2, 2024 21:24
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.

None yet

2 participants