diff options
author | Fredia Huya-Kouadio <fhuya@meta.com> | 2023-07-02 11:14:29 -0700 |
---|---|---|
committer | Yuri Sizov <yuris@humnom.net> | 2023-07-18 19:14:53 +0200 |
commit | d17811c8142920635faafa972cb9de58ac5b4e05 (patch) | |
tree | cb3f7879753bc9506f7390d930d1f1b23bde6027 /editor/export/editor_export_plugin.cpp | |
parent | 279732539f7ba253b42a1dc953861306efc63d60 (diff) | |
download | redot-engine-d17811c8142920635faafa972cb9de58ac5b4e05.tar.gz |
Re-architect how Android plugins are packaged and handled at export time
The previous packaging format for Godot Android plugins consisted of the plugin's `gdap` config file accompanied by binaries defined in the `gdap` file.
This format is now deprecated (starting with Godot 4.2), and instead Godot Android plugins are now packaged as `EditorExportPlugin` plugins.
The `EditorExportPlugin` class has been updated with the following methods to provide the necessary set of functionality:
- `_supports_platform`: returns true if the plugin supports the given platform
- `_get_android_dependencies`: retrieve the set of android dependencies (e.g: `org.godot.example:my-plugin:0.0.0`) provided by the plugin
- `_get_android_dependencies_maven_repos`: retrieve the urls of the maven repos for the provided android dependencies
- `_get_android_libraries`: retrieve the local paths of the android libraries (AAR files) provided by the plugin
- `_get_android_manifest_activity_element_contents`: update the contents of the `<activity>` element in the generated Android manifest
- `_get_android_manifest_application_element_contents`: update the contents of the `<application>` element in the generated Android manifest
- `_get_android_manifest_element_contents`: update the contents of the `<manifest>` element in the generated Android manifest
Diffstat (limited to 'editor/export/editor_export_plugin.cpp')
-rw-r--r-- | editor/export/editor_export_plugin.cpp | 81 |
1 files changed, 80 insertions, 1 deletions
diff --git a/editor/export/editor_export_plugin.cpp b/editor/export/editor_export_plugin.cpp index 4e2c1a9af7..6576960b9a 100644 --- a/editor/export/editor_export_plugin.cpp +++ b/editor/export/editor_export_plugin.cpp @@ -132,6 +132,27 @@ Variant EditorExportPlugin::get_option(const StringName &p_name) const { return export_preset->get(p_name); } +String EditorExportPlugin::_has_valid_export_configuration(const Ref<EditorExportPlatform> &p_export_platform, const Ref<EditorExportPreset> &p_preset) { + String warning; + if (!supports_platform(p_export_platform)) { + warning += vformat(TTR("Plugin \"%s\" is not supported on \"%s\""), get_name(), p_export_platform->get_name()); + warning += "\n"; + return warning; + } + + set_export_preset(p_preset); + List<EditorExportPlatform::ExportOption> options; + _get_export_options(p_export_platform, &options); + for (const EditorExportPlatform::ExportOption &E : options) { + String option_warning = _get_export_option_warning(p_export_platform, E.option.name); + if (!option_warning.is_empty()) { + warning += option_warning + "\n"; + } + } + + return warning; +} + void EditorExportPlugin::_export_file_script(const String &p_path, const String &p_type, const Vector<String> &p_features) { GDVIRTUAL_CALL(_export_file, p_path, p_type, p_features); } @@ -184,12 +205,54 @@ void EditorExportPlugin::_end_customize_resources() { GDVIRTUAL_CALL(_end_customize_resources); } -String EditorExportPlugin::_get_name() const { +String EditorExportPlugin::get_name() const { String ret; GDVIRTUAL_REQUIRED_CALL(_get_name, ret); return ret; } +bool EditorExportPlugin::supports_platform(const Ref<EditorExportPlatform> &p_export_platform) const { + bool ret = false; + GDVIRTUAL_CALL(_supports_platform, p_export_platform, ret); + return ret; +} + +PackedStringArray EditorExportPlugin::get_android_dependencies(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const { + PackedStringArray ret; + GDVIRTUAL_CALL(_get_android_dependencies, p_export_platform, p_debug, ret); + return ret; +} + +PackedStringArray EditorExportPlugin::get_android_dependencies_maven_repos(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const { + PackedStringArray ret; + GDVIRTUAL_CALL(_get_android_dependencies_maven_repos, p_export_platform, p_debug, ret); + return ret; +} + +PackedStringArray EditorExportPlugin::get_android_libraries(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const { + PackedStringArray ret; + GDVIRTUAL_CALL(_get_android_libraries, p_export_platform, p_debug, ret); + return ret; +} + +String EditorExportPlugin::get_android_manifest_activity_element_contents(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const { + String ret; + GDVIRTUAL_CALL(_get_android_manifest_activity_element_contents, p_export_platform, p_debug, ret); + return ret; +} + +String EditorExportPlugin::get_android_manifest_application_element_contents(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const { + String ret; + GDVIRTUAL_CALL(_get_android_manifest_application_element_contents, p_export_platform, p_debug, ret); + return ret; +} + +String EditorExportPlugin::get_android_manifest_element_contents(const Ref<EditorExportPlatform> &p_export_platform, bool p_debug) const { + String ret; + GDVIRTUAL_CALL(_get_android_manifest_element_contents, p_export_platform, p_debug, ret); + return ret; +} + PackedStringArray EditorExportPlugin::_get_export_features(const Ref<EditorExportPlatform> &p_platform, bool p_debug) const { PackedStringArray ret; GDVIRTUAL_CALL(_get_export_features, p_platform, p_debug, ret); @@ -216,6 +279,12 @@ bool EditorExportPlugin::_should_update_export_options(const Ref<EditorExportPla return ret; } +String EditorExportPlugin::_get_export_option_warning(const Ref<EditorExportPlatform> &p_export_platform, const String &p_option_name) const { + String ret; + GDVIRTUAL_CALL(_get_export_option_warning, p_export_platform, p_option_name, ret); + return ret; +} + void EditorExportPlugin::_export_file(const String &p_path, const String &p_type, const HashSet<String> &p_features) { } @@ -257,9 +326,19 @@ void EditorExportPlugin::_bind_methods() { GDVIRTUAL_BIND(_get_export_options, "platform"); GDVIRTUAL_BIND(_should_update_export_options, "platform"); + GDVIRTUAL_BIND(_get_export_option_warning, "platform", "option"); GDVIRTUAL_BIND(_get_export_features, "platform", "debug"); GDVIRTUAL_BIND(_get_name); + + GDVIRTUAL_BIND(_supports_platform, "platform"); + + GDVIRTUAL_BIND(_get_android_dependencies, "platform", "debug"); + GDVIRTUAL_BIND(_get_android_dependencies_maven_repos, "platform", "debug"); + GDVIRTUAL_BIND(_get_android_libraries, "platform", "debug"); + GDVIRTUAL_BIND(_get_android_manifest_activity_element_contents, "platform", "debug"); + GDVIRTUAL_BIND(_get_android_manifest_application_element_contents, "platform", "debug"); + GDVIRTUAL_BIND(_get_android_manifest_element_contents, "platform", "debug"); } EditorExportPlugin::EditorExportPlugin() { |