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

Preprocessor directive defines for Xenko and platforms #462

Open
aaronfranke opened this issue May 31, 2019 · 2 comments
Open

Preprocessor directive defines for Xenko and platforms #462

aaronfranke opened this issue May 31, 2019 · 2 comments
Labels
area-Build enhancement New feature or request

Comments

@aaronfranke
Copy link
Contributor

Godot recently merged this pull request which allows end-user code to have preprocessor directives to check if the code is running in Godot or if it's on a certain platform. For example, I can do this:

#if GODOT
GD.Print("This is Godot");
#else
throw new InvalidWorkflowException("Only Godot is supported");
#endif

With this feature, it is possible to write code that can run on multiple engines, by enabling/disabling different code depending on the engine. I would like to do something like this:

#if GODOT
GD.Print("This is Godot.");
#elif XENKO
Log.Info("This is Xenko.");
#else
throw new InvalidWorkflowException("Only Godot and Xenko are supported.");
#endif

Additionally, this kind of feature could be useful for intra-Xenko uses, for example, you could have a define called XENKO_WINDOWS and use that to wrap around any Windows-specific code.

@aaronfranke aaronfranke added the enhancement New feature or request label May 31, 2019
@makotech222
Copy link
Contributor

There's nothing stopping you from doing this in the CSProj file. Using Visual Studio:

image

@aaronfranke
Copy link
Contributor Author

To expand on that, to do it manually by editing the csproj file, under each configuration, there is a <DefineConstants> tag. It should look something like this:

<DefineConstants>XENKO;</DefineConstants>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Build enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants