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

Support custom compiler arguments in dotnet build #93539

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

monxa
Copy link
Contributor

@monxa monxa commented Jun 24, 2024

Proposal to Enable Custom Compiler Arguments in dotnet build

The What

This pull request allows users to pass additional compiler arguments to the dotnet build process to enhance flexibility and potentially reduce build times.

This implementation is based on the proposal by @paulloz. It emerged after the rejection of my previous attempt to address build times, which rightly so got rejected after careful review by @raulsntos (see original proposal).

In Detail

Changes to Project Settings

  • Added new settings:
dotnet/build/custom_compiler_arguments
dotnet/build/custom_publish_arguments

Modifications to Build Process

  • BuildInfo.cs: Added a new property CustomArguments.
  • BuildManager.cs: Introduced a new method AddCustomBuildArguments(BuildInfo buildInfo, bool publish) to parse the custom arguments from ProjectSettings.
  • Applied this method in CreateBuildInfo and CreatePublishBuildInfo.
  • BuildSystem/BuildArguments: Integrated the custom arguments from BuildInfo.

Demonstration

The custom arguments are hidden by default and can be found under "Advanced settings" for Mono builds:

image

Both Build and Rebuild processes respect the custom compiler arguments:

image

@AThousandShips

This comment was marked as resolved.

@monxa monxa force-pushed the additional_compiler_arguments_mono branch 3 times, most recently from fe7c8f2 to 31107b7 Compare June 24, 2024 08:36
@AThousandShips AThousandShips changed the title Custom Compiler Arguments in dotnet build Support custom compiler arguments in dotnet build Jun 24, 2024
@monxa monxa force-pushed the additional_compiler_arguments_mono branch from 31107b7 to 59d1a68 Compare June 24, 2024 14:03
@lfshr
Copy link

lfshr commented Jul 26, 2024

One great addition here would be the ability to provide extra arguments in an export preset. It would help replace GODOT_SERVER above and allow people to compile code in their dedicated servers that should not be present in the clients.

@monxa
Copy link
Contributor Author

monxa commented Jul 30, 2024

One great addition here would be the ability to provide extra arguments in an export preset. It would help replace GODOT_SERVER above and allow people to compile code in their dedicated servers that should not be present in the clients.

Oh yes. The current state of this draft only differentiates between publish (export) and in-editor. I haven't considered export presets because

  • that's not my main use for this draft
  • the exporter might change

These are not strong arguments and if I find time and feel charity-ish, I might find a solution for export template options. In the meantime, if anyone wants to expand on this draft, please let me know!

One idea I have for working around such a user-friendly solution tho:

  • You could write an ExporterPlugin
    • Cache and overwriting the ProjectSetting variables on _export_begin
    • Restore them on _export_end.

I have done something similar for the godot-git-plugin to avoid it being exported (godotengine/godot-git-plugin#77 (comment)).

Exposes two new "advanced" project settings:
- ProjectSettings/dotnet/build/custom_build_arguments,
- ProjectSettings/dotnet/build/custom_publish_arguments
The arguments provided will be appended to dotnet build <engine args>
<user args>.
The former will be appended when building in editor, the latter on
exports.
Because the arguments are appended, they override any engine provided
arguments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dotnet: Allow passing custom build arguments
3 participants