| 1537 | } |
| 1538 | |
| 1539 | Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, BitField<EditorExportPlatform::DebugFlags> p_flags) { |
| 1540 | ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags); |
| 1541 | |
| 1542 | const String base_dir = p_path.get_base_dir(); |
| 1543 | |
| 1544 | if (!DirAccess::exists(base_dir)) { |
| 1545 | add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), vformat(TTR("Target folder does not exist or is inaccessible: \"%s\""), base_dir)); |
| 1546 | return ERR_FILE_BAD_PATH; |
| 1547 | } |
| 1548 | |
| 1549 | EditorProgress ep("export", TTR("Exporting for macOS"), 3, true); |
| 1550 | |
| 1551 | String src_pkg_name; |
| 1552 | if (p_debug) { |
| 1553 | src_pkg_name = p_preset->get("custom_template/debug"); |
| 1554 | } else { |
| 1555 | src_pkg_name = p_preset->get("custom_template/release"); |
| 1556 | } |
| 1557 | |
| 1558 | if (src_pkg_name.is_empty()) { |
| 1559 | String err; |
| 1560 | src_pkg_name = find_export_template("macos.zip", &err); |
| 1561 | if (src_pkg_name.is_empty()) { |
| 1562 | add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Templates"), TTR("Export template not found.") + "\n" + err); |
| 1563 | return ERR_FILE_NOT_FOUND; |
| 1564 | } |
| 1565 | } |
| 1566 | |
| 1567 | Ref<FileAccess> io_fa; |
| 1568 | zlib_filefunc_def io = zipio_create_io(&io_fa); |
| 1569 | |
| 1570 | if (ep.step(TTR("Creating app bundle"), 0)) { |
| 1571 | return ERR_SKIP; |
| 1572 | } |
| 1573 | |
| 1574 | unzFile src_pkg_zip = unzOpen2(src_pkg_name.utf8().get_data(), &io); |
| 1575 | if (!src_pkg_zip) { |
| 1576 | add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Templates"), vformat(TTR("Could not find template app to export: \"%s\"."), src_pkg_name)); |
| 1577 | return ERR_FILE_NOT_FOUND; |
| 1578 | } |
| 1579 | |
| 1580 | int ret = unzGoToFirstFile(src_pkg_zip); |
| 1581 | |
| 1582 | String architecture = p_preset->get("binary_format/architecture"); |
| 1583 | String binary_to_use = "redot_macos_" + String(p_debug ? "debug" : "release") + "." + architecture; |
| 1584 | |
| 1585 | String pkg_name; |
| 1586 | if (String(get_project_setting(p_preset, "application/config/name")) != "") { |
| 1587 | pkg_name = String(get_project_setting(p_preset, "application/config/name")); |
| 1588 | } else { |
| 1589 | pkg_name = "Unnamed"; |
| 1590 | } |
| 1591 | pkg_name = OS::get_singleton()->get_safe_dir_name(pkg_name); |
| 1592 | |
| 1593 | String export_format; |
| 1594 | if (p_path.ends_with("zip")) { |
| 1595 | export_format = "zip"; |
| 1596 | } else if (p_path.ends_with("app")) { |
nothing calls this directly
no test coverage detected