godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.17k stars 98 forks source link

Ability to setup Godot Editor for Android/iOS export from the commandline #10672

Open zynga-jpetersen opened 2 months ago

zynga-jpetersen commented 2 months ago

Describe the project you are working on

We are trying to build game projects on build servers where there have been no ux interactions with the Godot editor prior to export.

Describe the problem or limitation you are having in your project

Currently the Godot editor expects several configurations to have been set before it will export projects on android (and to a lesser extent ios).

In editor_settings-*.tres settings files the following variables need to be set: "export/android/android_sdk_path" needs to be set to the Android sdk path "export/android/java_sdk_path" needs to be set to the JAVA sdk path.

Additionally the export_templates.tpz needs to have been unzipped and copied into (on mac): /Library/Application Support/Godot/export_templates/ with the correct version number associated with that export_templates.tpz file.

Additionally if you are using the gradle build process, you need to have imported the android_source.zip.

All of these are currently only configurable in the editor through clicking the ux or launching the editor once and filling those variables into the various folders/variables after the editor settings file has been created.

This method of launching then externally setting things is of course brittle because there is no way for maintainers to know that users are doing this.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Ideally it would be possible to set the editor settings variables from the commandline or the editor could be launched several times on the commandline with various commands as arguments.

Example: godot --headless --set_editor_setting "export/android/android_sdk_path" "$ANDROID_SDK_ROOT" --set_editor_setting "export/android/java_sdk_path" "$JAVA_HOME" --install_android_gradle_source $ANDROID_GRADLE_ZIP --export-release Android $ANDROID_APK

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

I'm not certain a generic solution can exist for this problem, but I think the solution would have 2 parts.

EditorExportPlatform could have commandline arguments sent down to it and then each platform could do whatever custom setup it might need to from the commandline.

ExportTemplateManager could have a function on it to use the commandline arguments to perform: Install android source: https://github.com/godotengine/godot/blob/master/editor/export/export_template_manager.cpp#L776

Install Export Templates from file: https://github.com/godotengine/godot/blob/master/editor/export/export_template_manager.cpp#L414C29-L414C51

Separately the main program could parse --set_editor_setting pairs and apply them to the editor settings. https://github.com/godotengine/godot/blob/master/main/main.cpp#L1066

If this enhancement will not be used often, can it be worked around with a few lines of script?

Yes, just don't set the commandline arguments and continue to launch godot several times setting various things.

Is there a reason why this should be core and not an add-on in the asset library?

I'm not certain it could or should be given the various variables are already in godot, setting them externally creates the same maintenance dependency issue that exist from my scripts setting them post godot first launch.

RedMser commented 2 months ago

You can run a script via --script parameter which can set the editor settings by reading the command line. Or maybe an export plugin could be used for this as well, but I'm not sure about that...

zynga-jpetersen commented 2 months ago

I didnt spot it originally but there turns out to already be a commandline option to install the android build templates:

--install-android-build-template

https://github.com/godotengine/godot/blob/27552a2f26adcdba579cd804197de3942e8cb0ec/main/main.cpp#L3511

Added in: https://github.com/godotengine/godot/commit/988c1bf2980d1243f7502213fabd21de74b27432

Calinou commented 2 months ago

@zynga-jpetersen Which manual steps could the Godot editor automate for setting up iOS export? As I understand it, this proposal is already implemented for Android.