| 485 | } |
| 486 | |
| 487 | Error EditorExportPlatformWeb::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, BitField<EditorExportPlatform::DebugFlags> p_flags) { |
| 488 | ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags); |
| 489 | |
| 490 | const String custom_debug = p_preset->get("custom_template/debug"); |
| 491 | const String custom_release = p_preset->get("custom_template/release"); |
| 492 | const String custom_html = p_preset->get("html/custom_html_shell"); |
| 493 | const bool export_icon = p_preset->get("html/export_icon"); |
| 494 | const bool pwa = p_preset->get("progressive_web_app/enabled"); |
| 495 | |
| 496 | const String base_dir = p_path.get_base_dir(); |
| 497 | const String base_path = p_path.get_basename(); |
| 498 | const String base_name = p_path.get_file().get_basename(); |
| 499 | |
| 500 | if (!DirAccess::exists(base_dir)) { |
| 501 | add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Target folder does not exist or is inaccessible: \"%s\""), base_dir)); |
| 502 | return ERR_FILE_BAD_PATH; |
| 503 | } |
| 504 | |
| 505 | // Find the correct template |
| 506 | String template_path = p_debug ? custom_debug : custom_release; |
| 507 | template_path = template_path.strip_edges(); |
| 508 | if (template_path.is_empty()) { |
| 509 | bool extensions = (bool)p_preset->get("variant/extensions_support"); |
| 510 | bool thread_support = (bool)p_preset->get("variant/thread_support"); |
| 511 | template_path = find_export_template(_get_template_name(extensions, thread_support, p_debug)); |
| 512 | } |
| 513 | |
| 514 | if (!template_path.is_empty() && !FileAccess::exists(template_path)) { |
| 515 | add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Templates"), vformat(TTR("Template file not found: \"%s\"."), template_path)); |
| 516 | return ERR_FILE_NOT_FOUND; |
| 517 | } |
| 518 | |
| 519 | // Export pck and shared objects |
| 520 | Vector<SharedObject> shared_objects; |
| 521 | String pck_path = base_path + ".pck"; |
| 522 | Error error = save_pack(p_preset, p_debug, pck_path, &shared_objects); |
| 523 | if (error != OK) { |
| 524 | add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not write file: \"%s\"."), pck_path)); |
| 525 | return error; |
| 526 | } |
| 527 | |
| 528 | { |
| 529 | Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); |
| 530 | for (int i = 0; i < shared_objects.size(); i++) { |
| 531 | String dst = base_dir.path_join(shared_objects[i].path.get_file()); |
| 532 | error = da->copy(shared_objects[i].path, dst); |
| 533 | if (error != OK) { |
| 534 | add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Could not write file: \"%s\"."), shared_objects[i].path.get_file())); |
| 535 | return error; |
| 536 | } |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | // Extract templates. |
| 541 | error = _extract_template(template_path, base_dir, base_name, pwa); |
| 542 | if (error) { |
| 543 | // Message is supplied by the subroutine method. |
| 544 | return error; |
nothing calls this directly
no test coverage detected