Addes ability to load build sources from file.

* If not present, the dialog asks to load build sources from a file.
* The export templates check now also verifies that build sources are installed and skips the template check.

This makes Android development easier.

(cherry picked from commit 6639cc9853)
This commit is contained in:
reduz 2021-07-15 10:12:56 -03:00 committed by Rémi Verschelde
parent 7b6b402a0c
commit ca223d71d8
No known key found for this signature in database
GPG key ID: C3336907360768E1
5 changed files with 32 additions and 7 deletions

View file

@ -643,6 +643,12 @@ bool ExportTemplateManager::can_install_android_template() {
}
Error ExportTemplateManager::install_android_template() {
const String &templates_path = EditorSettings::get_singleton()->get_templates_dir().plus_file(VERSION_FULL_CONFIG);
const String &source_zip = templates_path.plus_file("android_source.zip");
ERR_FAIL_COND_V(!FileAccess::exists(source_zip), ERR_CANT_OPEN);
return install_android_template_from_file(source_zip);
}
Error ExportTemplateManager::install_android_template_from_file(const String &p_file) {
// To support custom Android builds, we install the Java source code and buildsystem
// from android_source.zip to the project's res://android folder.
@ -675,14 +681,10 @@ Error ExportTemplateManager::install_android_template() {
// Uncompress source template.
const String &templates_path = EditorSettings::get_singleton()->get_templates_dir().plus_file(VERSION_FULL_CONFIG);
const String &source_zip = templates_path.plus_file("android_source.zip");
ERR_FAIL_COND_V(!FileAccess::exists(source_zip), ERR_CANT_OPEN);
FileAccess *src_f = nullptr;
zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
unzFile pkg = unzOpen2(source_zip.utf8().get_data(), &io);
unzFile pkg = unzOpen2(p_file.utf8().get_data(), &io);
ERR_FAIL_COND_V_MSG(!pkg, ERR_CANT_OPEN, "Android sources not in ZIP format.");
int ret = unzGoToFirstFile(pkg);