MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / export_project

Method export_project

platform/linuxbsd/export/export_plugin.cpp:62–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62Error EditorExportPlatformLinuxBSD::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, BitField<EditorExportPlatform::DebugFlags> p_flags) {
63 String custom_debug = p_preset->get("custom_template/debug");
64 String custom_release = p_preset->get("custom_template/release");
65 String arch = p_preset->get("binary_format/architecture");
66
67 String template_path = p_debug ? custom_debug : custom_release;
68 template_path = template_path.strip_edges();
69 if (!template_path.is_empty()) {
70 String exe_arch = _get_exe_arch(template_path);
71 if (arch != exe_arch) {
72 add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Templates"), vformat(TTR("Mismatching custom export template executable architecture: found \"%s\", expected \"%s\"."), exe_arch, arch));
73 return ERR_CANT_CREATE;
74 }
75 }
76
77 Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
78 if (da->file_exists(template_path.get_base_dir().path_join("libaccesskit." + arch + ".so"))) {
79 da->copy(template_path.get_base_dir().path_join("libaccesskit." + arch + ".so"), p_path.get_base_dir().path_join("libaccesskit." + arch + ".so"), get_chmod_flags());
80 }
81
82 bool export_as_zip = p_path.ends_with("zip");
83
84 String pkg_name;
85 if (String(get_project_setting(p_preset, "application/config/name")) != "") {
86 pkg_name = String(get_project_setting(p_preset, "application/config/name"));
87 } else {
88 pkg_name = "Unnamed";
89 }
90
91 pkg_name = OS::get_singleton()->get_safe_dir_name(pkg_name);
92
93 // Setup temp folder.
94 String path = p_path;
95 String tmp_dir_path = EditorPaths::get_singleton()->get_temp_dir().path_join(pkg_name);
96
97 Ref<DirAccess> tmp_app_dir = DirAccess::create_for_path(tmp_dir_path);
98 if (export_as_zip) {
99 if (tmp_app_dir.is_null()) {
100 add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Templates"), vformat(TTR("Could not create and open the directory: \"%s\""), tmp_dir_path));
101 return ERR_CANT_CREATE;
102 }
103 if (DirAccess::exists(tmp_dir_path)) {
104 if (tmp_app_dir->change_dir(tmp_dir_path) == OK) {
105 tmp_app_dir->erase_contents_recursive();
106 }
107 }
108 tmp_app_dir->make_dir_recursive(tmp_dir_path);
109 path = tmp_dir_path.path_join(p_path.get_file().get_basename());
110 }
111
112 // Export project.
113 Error err = EditorExportPlatformPC::export_project(p_preset, p_debug, path, p_flags);
114 if (err != OK) {
115 // Message is supplied by the subroutine method.
116 return err;
117 }
118
119 // Save console wrapper.

Callers

nothing calls this directly

Calls 15

TTRFunction · 0.85
vformatFunction · 0.85
zipio_create_ioFunction · 0.85
strip_edgesMethod · 0.80
path_joinMethod · 0.80
get_base_dirMethod · 0.80
ends_withMethod · 0.80
get_safe_dir_nameMethod · 0.80
get_basenameMethod · 0.80
createFunction · 0.50
StringClass · 0.50

Tested by

no test coverage detected