export_plugin.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. /**************************************************************************/
  2. /* export_plugin.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #include "export_plugin.h"
  31. #include "logo_svg.gen.h"
  32. #include "run_icon_svg.gen.h"
  33. #include "core/config/project_settings.h"
  34. #include "editor/editor_node.h"
  35. #include "editor/editor_paths.h"
  36. #include "editor/editor_scale.h"
  37. #include "editor/export/editor_export.h"
  38. #include "modules/modules_enabled.gen.h" // For svg.
  39. #ifdef MODULE_SVG_ENABLED
  40. #include "modules/svg/image_loader_svg.h"
  41. #endif
  42. Error EditorExportPlatformLinuxBSD::_export_debug_script(const Ref<EditorExportPreset> &p_preset, const String &p_app_name, const String &p_pkg_name, const String &p_path) {
  43. Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::WRITE);
  44. if (f.is_null()) {
  45. add_message(EXPORT_MESSAGE_ERROR, TTR("Debug Script Export"), vformat(TTR("Could not open file \"%s\"."), p_path));
  46. return ERR_CANT_CREATE;
  47. }
  48. f->store_line("#!/bin/sh");
  49. f->store_line("echo -ne '\\033c\\033]0;" + p_app_name + "\\a'");
  50. f->store_line("base_path=\"$(dirname \"$(realpath \"$0\")\")\"");
  51. f->store_line("\"$base_path/" + p_pkg_name + "\" \"$@\"");
  52. return OK;
  53. }
  54. Error EditorExportPlatformLinuxBSD::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
  55. bool export_as_zip = p_path.ends_with("zip");
  56. String pkg_name;
  57. if (String(GLOBAL_GET("application/config/name")) != "") {
  58. pkg_name = String(GLOBAL_GET("application/config/name"));
  59. } else {
  60. pkg_name = "Unnamed";
  61. }
  62. pkg_name = OS::get_singleton()->get_safe_dir_name(pkg_name);
  63. // Setup temp folder.
  64. String path = p_path;
  65. String tmp_dir_path = EditorPaths::get_singleton()->get_cache_dir().path_join(pkg_name);
  66. Ref<DirAccess> tmp_app_dir = DirAccess::create_for_path(tmp_dir_path);
  67. if (export_as_zip) {
  68. if (tmp_app_dir.is_null()) {
  69. return ERR_CANT_CREATE;
  70. }
  71. if (DirAccess::exists(tmp_dir_path)) {
  72. if (tmp_app_dir->change_dir(tmp_dir_path) == OK) {
  73. tmp_app_dir->erase_contents_recursive();
  74. }
  75. }
  76. tmp_app_dir->make_dir_recursive(tmp_dir_path);
  77. path = tmp_dir_path.path_join(p_path.get_file().get_basename());
  78. }
  79. // Export project.
  80. Error err = EditorExportPlatformPC::export_project(p_preset, p_debug, path, p_flags);
  81. if (err != OK) {
  82. return err;
  83. }
  84. // Save console wrapper.
  85. if (err == OK) {
  86. int con_scr = p_preset->get("debug/export_console_wrapper");
  87. if ((con_scr == 1 && p_debug) || (con_scr == 2)) {
  88. String scr_path = path.get_basename() + ".sh";
  89. err = _export_debug_script(p_preset, pkg_name, path.get_file(), scr_path);
  90. FileAccess::set_unix_permissions(scr_path, 0755);
  91. if (err != OK) {
  92. add_message(EXPORT_MESSAGE_ERROR, TTR("Debug Console Export"), TTR("Could not create console wrapper."));
  93. }
  94. }
  95. }
  96. // ZIP project.
  97. if (export_as_zip) {
  98. if (FileAccess::exists(p_path)) {
  99. OS::get_singleton()->move_to_trash(p_path);
  100. }
  101. Ref<FileAccess> io_fa_dst;
  102. zlib_filefunc_def io_dst = zipio_create_io(&io_fa_dst);
  103. zipFile zip = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io_dst);
  104. zip_folder_recursive(zip, tmp_dir_path, "", pkg_name);
  105. zipClose(zip, nullptr);
  106. if (tmp_app_dir->change_dir(tmp_dir_path) == OK) {
  107. tmp_app_dir->erase_contents_recursive();
  108. tmp_app_dir->change_dir("..");
  109. tmp_app_dir->remove(pkg_name);
  110. }
  111. }
  112. return err;
  113. }
  114. String EditorExportPlatformLinuxBSD::get_template_file_name(const String &p_target, const String &p_arch) const {
  115. return "linux_" + p_target + "." + p_arch;
  116. }
  117. List<String> EditorExportPlatformLinuxBSD::get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const {
  118. List<String> list;
  119. list.push_back(p_preset->get("binary_format/architecture"));
  120. list.push_back("zip");
  121. return list;
  122. }
  123. bool EditorExportPlatformLinuxBSD::get_export_option_visibility(const EditorExportPreset *p_preset, const String &p_option) const {
  124. if (p_preset) {
  125. // Hide SSH options.
  126. bool ssh = p_preset->get("ssh_remote_deploy/enabled");
  127. if (!ssh && p_option != "ssh_remote_deploy/enabled" && p_option.begins_with("ssh_remote_deploy/")) {
  128. return false;
  129. }
  130. }
  131. return true;
  132. }
  133. void EditorExportPlatformLinuxBSD::get_export_options(List<ExportOption> *r_options) const {
  134. EditorExportPlatformPC::get_export_options(r_options);
  135. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "binary_format/architecture", PROPERTY_HINT_ENUM, "x86_64,x86_32,arm64,arm32,rv64,ppc64,ppc32"), "x86_64"));
  136. String run_script = "#!/usr/bin/env bash\n"
  137. "export DISPLAY=:0\n"
  138. "unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"\n"
  139. "\"{temp_dir}/{exe_name}\" {cmd_args}";
  140. String cleanup_script = "#!/usr/bin/env bash\n"
  141. "kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")\n"
  142. "rm -rf \"{temp_dir}\"";
  143. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "ssh_remote_deploy/enabled"), false, true));
  144. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/host"), "user@host_ip"));
  145. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/port"), "22"));
  146. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/extra_args_ssh", PROPERTY_HINT_MULTILINE_TEXT), ""));
  147. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/extra_args_scp", PROPERTY_HINT_MULTILINE_TEXT), ""));
  148. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/run_script", PROPERTY_HINT_MULTILINE_TEXT), run_script));
  149. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/cleanup_script", PROPERTY_HINT_MULTILINE_TEXT), cleanup_script));
  150. }
  151. bool EditorExportPlatformLinuxBSD::is_elf(const String &p_path) const {
  152. Ref<FileAccess> fb = FileAccess::open(p_path, FileAccess::READ);
  153. ERR_FAIL_COND_V_MSG(fb.is_null(), false, vformat("Can't open file: \"%s\".", p_path));
  154. uint32_t magic = fb->get_32();
  155. return (magic == 0x464c457f);
  156. }
  157. bool EditorExportPlatformLinuxBSD::is_shebang(const String &p_path) const {
  158. Ref<FileAccess> fb = FileAccess::open(p_path, FileAccess::READ);
  159. ERR_FAIL_COND_V_MSG(fb.is_null(), false, vformat("Can't open file: \"%s\".", p_path));
  160. uint16_t magic = fb->get_16();
  161. return (magic == 0x2123);
  162. }
  163. bool EditorExportPlatformLinuxBSD::is_executable(const String &p_path) const {
  164. return is_elf(p_path) || is_shebang(p_path);
  165. }
  166. Error EditorExportPlatformLinuxBSD::fixup_embedded_pck(const String &p_path, int64_t p_embedded_start, int64_t p_embedded_size) {
  167. // Patch the header of the "pck" section in the ELF file so that it corresponds to the embedded data
  168. Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::READ_WRITE);
  169. if (f.is_null()) {
  170. add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), vformat(TTR("Failed to open executable file \"%s\"."), p_path));
  171. return ERR_CANT_OPEN;
  172. }
  173. // Read and check ELF magic number
  174. {
  175. uint32_t magic = f->get_32();
  176. if (magic != 0x464c457f) { // 0x7F + "ELF"
  177. add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), TTR("Executable file header corrupted."));
  178. return ERR_FILE_CORRUPT;
  179. }
  180. }
  181. // Read program architecture bits from class field
  182. int bits = f->get_8() * 32;
  183. if (bits == 32 && p_embedded_size >= 0x100000000) {
  184. add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), TTR("32-bit executables cannot have embedded data >= 4 GiB."));
  185. }
  186. // Get info about the section header table
  187. int64_t section_table_pos;
  188. int64_t section_header_size;
  189. if (bits == 32) {
  190. section_header_size = 40;
  191. f->seek(0x20);
  192. section_table_pos = f->get_32();
  193. f->seek(0x30);
  194. } else { // 64
  195. section_header_size = 64;
  196. f->seek(0x28);
  197. section_table_pos = f->get_64();
  198. f->seek(0x3c);
  199. }
  200. int num_sections = f->get_16();
  201. int string_section_idx = f->get_16();
  202. // Load the strings table
  203. uint8_t *strings;
  204. {
  205. // Jump to the strings section header
  206. f->seek(section_table_pos + string_section_idx * section_header_size);
  207. // Read strings data size and offset
  208. int64_t string_data_pos;
  209. int64_t string_data_size;
  210. if (bits == 32) {
  211. f->seek(f->get_position() + 0x10);
  212. string_data_pos = f->get_32();
  213. string_data_size = f->get_32();
  214. } else { // 64
  215. f->seek(f->get_position() + 0x18);
  216. string_data_pos = f->get_64();
  217. string_data_size = f->get_64();
  218. }
  219. // Read strings data
  220. f->seek(string_data_pos);
  221. strings = (uint8_t *)memalloc(string_data_size);
  222. if (!strings) {
  223. return ERR_OUT_OF_MEMORY;
  224. }
  225. f->get_buffer(strings, string_data_size);
  226. }
  227. // Search for the "pck" section
  228. bool found = false;
  229. for (int i = 0; i < num_sections; ++i) {
  230. int64_t section_header_pos = section_table_pos + i * section_header_size;
  231. f->seek(section_header_pos);
  232. uint32_t name_offset = f->get_32();
  233. if (strcmp((char *)strings + name_offset, "pck") == 0) {
  234. // "pck" section found, let's patch!
  235. if (bits == 32) {
  236. f->seek(section_header_pos + 0x10);
  237. f->store_32(p_embedded_start);
  238. f->store_32(p_embedded_size);
  239. } else { // 64
  240. f->seek(section_header_pos + 0x18);
  241. f->store_64(p_embedded_start);
  242. f->store_64(p_embedded_size);
  243. }
  244. found = true;
  245. break;
  246. }
  247. }
  248. memfree(strings);
  249. if (!found) {
  250. add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), TTR("Executable \"pck\" section not found."));
  251. return ERR_FILE_CORRUPT;
  252. }
  253. return OK;
  254. }
  255. Ref<Texture2D> EditorExportPlatformLinuxBSD::get_run_icon() const {
  256. return run_icon;
  257. }
  258. bool EditorExportPlatformLinuxBSD::poll_export() {
  259. Ref<EditorExportPreset> preset;
  260. for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
  261. Ref<EditorExportPreset> ep = EditorExport::get_singleton()->get_export_preset(i);
  262. if (ep->is_runnable() && ep->get_platform() == this) {
  263. preset = ep;
  264. break;
  265. }
  266. }
  267. int prev = menu_options;
  268. menu_options = (preset.is_valid() && preset->get("ssh_remote_deploy/enabled").operator bool());
  269. if (ssh_pid != 0 || !cleanup_commands.is_empty()) {
  270. if (menu_options == 0) {
  271. cleanup();
  272. } else {
  273. menu_options += 1;
  274. }
  275. }
  276. return menu_options != prev;
  277. }
  278. Ref<ImageTexture> EditorExportPlatformLinuxBSD::get_option_icon(int p_index) const {
  279. return p_index == 1 ? stop_icon : EditorExportPlatform::get_option_icon(p_index);
  280. }
  281. int EditorExportPlatformLinuxBSD::get_options_count() const {
  282. return menu_options;
  283. }
  284. String EditorExportPlatformLinuxBSD::get_option_label(int p_index) const {
  285. return (p_index) ? TTR("Stop and uninstall") : TTR("Run on remote Linux/BSD system");
  286. }
  287. String EditorExportPlatformLinuxBSD::get_option_tooltip(int p_index) const {
  288. return (p_index) ? TTR("Stop and uninstall running project from the remote system") : TTR("Run exported project on remote Linux/BSD system");
  289. }
  290. void EditorExportPlatformLinuxBSD::cleanup() {
  291. if (ssh_pid != 0 && OS::get_singleton()->is_process_running(ssh_pid)) {
  292. print_line("Terminating connection...");
  293. OS::get_singleton()->kill(ssh_pid);
  294. OS::get_singleton()->delay_usec(1000);
  295. }
  296. if (!cleanup_commands.is_empty()) {
  297. print_line("Stopping and deleting previous version...");
  298. for (const SSHCleanupCommand &cmd : cleanup_commands) {
  299. if (cmd.wait) {
  300. ssh_run_on_remote(cmd.host, cmd.port, cmd.ssh_args, cmd.cmd_args);
  301. } else {
  302. ssh_run_on_remote_no_wait(cmd.host, cmd.port, cmd.ssh_args, cmd.cmd_args);
  303. }
  304. }
  305. }
  306. ssh_pid = 0;
  307. cleanup_commands.clear();
  308. }
  309. Error EditorExportPlatformLinuxBSD::run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags) {
  310. cleanup();
  311. if (p_device) { // Stop command, cleanup only.
  312. return OK;
  313. }
  314. EditorProgress ep("run", TTR("Running..."), 5);
  315. const String dest = EditorPaths::get_singleton()->get_cache_dir().path_join("linuxbsd");
  316. Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  317. if (!da->dir_exists(dest)) {
  318. Error err = da->make_dir_recursive(dest);
  319. if (err != OK) {
  320. EditorNode::get_singleton()->show_warning(TTR("Could not create temp directory:") + "\n" + dest);
  321. return err;
  322. }
  323. }
  324. String host = p_preset->get("ssh_remote_deploy/host").operator String();
  325. String port = p_preset->get("ssh_remote_deploy/port").operator String();
  326. if (port.is_empty()) {
  327. port = "22";
  328. }
  329. Vector<String> extra_args_ssh = p_preset->get("ssh_remote_deploy/extra_args_ssh").operator String().split(" ", false);
  330. Vector<String> extra_args_scp = p_preset->get("ssh_remote_deploy/extra_args_scp").operator String().split(" ", false);
  331. const String basepath = dest.path_join("tmp_linuxbsd_export");
  332. #define CLEANUP_AND_RETURN(m_err) \
  333. { \
  334. if (da->file_exists(basepath + ".zip")) { \
  335. da->remove(basepath + ".zip"); \
  336. } \
  337. if (da->file_exists(basepath + "_start.sh")) { \
  338. da->remove(basepath + "_start.sh"); \
  339. } \
  340. if (da->file_exists(basepath + "_clean.sh")) { \
  341. da->remove(basepath + "_clean.sh"); \
  342. } \
  343. return m_err; \
  344. } \
  345. ((void)0)
  346. if (ep.step(TTR("Exporting project..."), 1)) {
  347. return ERR_SKIP;
  348. }
  349. Error err = export_project(p_preset, true, basepath + ".zip", p_debug_flags);
  350. if (err != OK) {
  351. DirAccess::remove_file_or_error(basepath + ".zip");
  352. return err;
  353. }
  354. String cmd_args;
  355. {
  356. Vector<String> cmd_args_list;
  357. gen_debug_flags(cmd_args_list, p_debug_flags);
  358. for (int i = 0; i < cmd_args_list.size(); i++) {
  359. if (i != 0) {
  360. cmd_args += " ";
  361. }
  362. cmd_args += cmd_args_list[i];
  363. }
  364. }
  365. const bool use_remote = (p_debug_flags & DEBUG_FLAG_REMOTE_DEBUG) || (p_debug_flags & DEBUG_FLAG_DUMB_CLIENT);
  366. int dbg_port = EditorSettings::get_singleton()->get("network/debug/remote_port");
  367. print_line("Creating temporary directory...");
  368. ep.step(TTR("Creating temporary directory..."), 2);
  369. String temp_dir;
  370. err = ssh_run_on_remote(host, port, extra_args_ssh, "mktemp -d", &temp_dir);
  371. if (err != OK || temp_dir.is_empty()) {
  372. CLEANUP_AND_RETURN(err);
  373. }
  374. print_line("Uploading archive...");
  375. ep.step(TTR("Uploading archive..."), 3);
  376. err = ssh_push_to_remote(host, port, extra_args_scp, basepath + ".zip", temp_dir);
  377. if (err != OK) {
  378. CLEANUP_AND_RETURN(err);
  379. }
  380. {
  381. String run_script = p_preset->get("ssh_remote_deploy/run_script");
  382. run_script = run_script.replace("{temp_dir}", temp_dir);
  383. run_script = run_script.replace("{archive_name}", basepath.get_file() + ".zip");
  384. run_script = run_script.replace("{exe_name}", basepath.get_file());
  385. run_script = run_script.replace("{cmd_args}", cmd_args);
  386. Ref<FileAccess> f = FileAccess::open(basepath + "_start.sh", FileAccess::WRITE);
  387. if (f.is_null()) {
  388. CLEANUP_AND_RETURN(err);
  389. }
  390. f->store_string(run_script);
  391. }
  392. {
  393. String clean_script = p_preset->get("ssh_remote_deploy/cleanup_script");
  394. clean_script = clean_script.replace("{temp_dir}", temp_dir);
  395. clean_script = clean_script.replace("{archive_name}", basepath.get_file() + ".zip");
  396. clean_script = clean_script.replace("{exe_name}", basepath.get_file());
  397. clean_script = clean_script.replace("{cmd_args}", cmd_args);
  398. Ref<FileAccess> f = FileAccess::open(basepath + "_clean.sh", FileAccess::WRITE);
  399. if (f.is_null()) {
  400. CLEANUP_AND_RETURN(err);
  401. }
  402. f->store_string(clean_script);
  403. }
  404. print_line("Uploading scripts...");
  405. ep.step(TTR("Uploading scripts..."), 4);
  406. err = ssh_push_to_remote(host, port, extra_args_scp, basepath + "_start.sh", temp_dir);
  407. if (err != OK) {
  408. CLEANUP_AND_RETURN(err);
  409. }
  410. err = ssh_run_on_remote(host, port, extra_args_ssh, vformat("chmod +x \"%s/%s\"", temp_dir, basepath.get_file() + "_start.sh"));
  411. if (err != OK || temp_dir.is_empty()) {
  412. CLEANUP_AND_RETURN(err);
  413. }
  414. err = ssh_push_to_remote(host, port, extra_args_scp, basepath + "_clean.sh", temp_dir);
  415. if (err != OK) {
  416. CLEANUP_AND_RETURN(err);
  417. }
  418. err = ssh_run_on_remote(host, port, extra_args_ssh, vformat("chmod +x \"%s/%s\"", temp_dir, basepath.get_file() + "_clean.sh"));
  419. if (err != OK || temp_dir.is_empty()) {
  420. CLEANUP_AND_RETURN(err);
  421. }
  422. print_line("Starting project...");
  423. ep.step(TTR("Starting project..."), 5);
  424. err = ssh_run_on_remote_no_wait(host, port, extra_args_ssh, vformat("\"%s/%s\"", temp_dir, basepath.get_file() + "_start.sh"), &ssh_pid, (use_remote) ? dbg_port : -1);
  425. if (err != OK) {
  426. CLEANUP_AND_RETURN(err);
  427. }
  428. cleanup_commands.clear();
  429. cleanup_commands.push_back(SSHCleanupCommand(host, port, extra_args_ssh, vformat("\"%s/%s\"", temp_dir, basepath.get_file() + "_clean.sh")));
  430. print_line("Project started.");
  431. CLEANUP_AND_RETURN(OK);
  432. #undef CLEANUP_AND_RETURN
  433. }
  434. EditorExportPlatformLinuxBSD::EditorExportPlatformLinuxBSD() {
  435. if (EditorNode::get_singleton()) {
  436. #ifdef MODULE_SVG_ENABLED
  437. Ref<Image> img = memnew(Image);
  438. const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE);
  439. ImageLoaderSVG img_loader;
  440. img_loader.create_image_from_string(img, _linuxbsd_logo_svg, EDSCALE, upsample, false);
  441. set_logo(ImageTexture::create_from_image(img));
  442. img_loader.create_image_from_string(img, _linuxbsd_run_icon_svg, EDSCALE, upsample, false);
  443. run_icon = ImageTexture::create_from_image(img);
  444. #endif
  445. Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme();
  446. if (theme.is_valid()) {
  447. stop_icon = theme->get_icon(SNAME("Stop"), SNAME("EditorIcons"));
  448. } else {
  449. stop_icon.instantiate();
  450. }
  451. }
  452. }