Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/platform/linuxbsd/export/export_plugin.cpp
10278 views
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
31
#include "export_plugin.h"
32
33
#include "logo_svg.gen.h"
34
#include "run_icon_svg.gen.h"
35
36
#include "core/config/project_settings.h"
37
#include "editor/editor_node.h"
38
#include "editor/editor_string_names.h"
39
#include "editor/export/editor_export.h"
40
#include "editor/file_system/editor_paths.h"
41
#include "editor/themes/editor_scale.h"
42
43
#include "modules/svg/image_loader_svg.h"
44
45
Error EditorExportPlatformLinuxBSD::_export_debug_script(const Ref<EditorExportPreset> &p_preset, const String &p_app_name, const String &p_pkg_name, const String &p_path) {
46
Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::WRITE);
47
if (f.is_null()) {
48
add_message(EXPORT_MESSAGE_ERROR, TTR("Debug Script Export"), vformat(TTR("Could not open file \"%s\"."), p_path));
49
return ERR_CANT_CREATE;
50
}
51
52
f->store_line("#!/bin/sh");
53
f->store_line("printf '\\033c\\033]0;%s\\a' " + p_app_name);
54
f->store_line("base_path=\"$(dirname \"$(realpath \"$0\")\")\"");
55
f->store_line("\"$base_path/" + p_pkg_name + "\" \"$@\"");
56
57
return OK;
58
}
59
60
Error EditorExportPlatformLinuxBSD::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, BitField<EditorExportPlatform::DebugFlags> p_flags) {
61
String custom_debug = p_preset->get("custom_template/debug");
62
String custom_release = p_preset->get("custom_template/release");
63
String arch = p_preset->get("binary_format/architecture");
64
65
String template_path = p_debug ? custom_debug : custom_release;
66
template_path = template_path.strip_edges();
67
if (!template_path.is_empty()) {
68
String exe_arch = _get_exe_arch(template_path);
69
if (arch != exe_arch) {
70
add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Templates"), vformat(TTR("Mismatching custom export template executable architecture: found \"%s\", expected \"%s\"."), exe_arch, arch));
71
return ERR_CANT_CREATE;
72
}
73
}
74
75
Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
76
if (da->file_exists(template_path.get_base_dir().path_join("libaccesskit." + arch + ".so"))) {
77
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());
78
}
79
80
bool export_as_zip = p_path.ends_with("zip");
81
82
String pkg_name;
83
if (String(get_project_setting(p_preset, "application/config/name")) != "") {
84
pkg_name = String(get_project_setting(p_preset, "application/config/name"));
85
} else {
86
pkg_name = "Unnamed";
87
}
88
89
pkg_name = OS::get_singleton()->get_safe_dir_name(pkg_name);
90
91
// Setup temp folder.
92
String path = p_path;
93
String tmp_dir_path = EditorPaths::get_singleton()->get_temp_dir().path_join(pkg_name);
94
95
Ref<DirAccess> tmp_app_dir = DirAccess::create_for_path(tmp_dir_path);
96
if (export_as_zip) {
97
if (tmp_app_dir.is_null()) {
98
add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Templates"), vformat(TTR("Could not create and open the directory: \"%s\""), tmp_dir_path));
99
return ERR_CANT_CREATE;
100
}
101
if (DirAccess::exists(tmp_dir_path)) {
102
if (tmp_app_dir->change_dir(tmp_dir_path) == OK) {
103
tmp_app_dir->erase_contents_recursive();
104
}
105
}
106
tmp_app_dir->make_dir_recursive(tmp_dir_path);
107
path = tmp_dir_path.path_join(p_path.get_file().get_basename());
108
}
109
110
// Export project.
111
Error err = EditorExportPlatformPC::export_project(p_preset, p_debug, path, p_flags);
112
if (err != OK) {
113
// Message is supplied by the subroutine method.
114
return err;
115
}
116
117
// Save console wrapper.
118
int con_scr = p_preset->get("debug/export_console_wrapper");
119
if ((con_scr == 1 && p_debug) || (con_scr == 2)) {
120
String scr_path = path.get_basename() + ".sh";
121
err = _export_debug_script(p_preset, pkg_name, path.get_file(), scr_path);
122
FileAccess::set_unix_permissions(scr_path, 0755);
123
if (err != OK) {
124
add_message(EXPORT_MESSAGE_ERROR, TTR("Debug Console Export"), TTR("Could not create console wrapper."));
125
}
126
}
127
128
// ZIP project.
129
if (export_as_zip) {
130
if (FileAccess::exists(p_path)) {
131
OS::get_singleton()->move_to_trash(p_path);
132
}
133
134
Ref<FileAccess> io_fa_dst;
135
zlib_filefunc_def io_dst = zipio_create_io(&io_fa_dst);
136
zipFile zip = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io_dst);
137
138
zip_folder_recursive(zip, tmp_dir_path, "", pkg_name);
139
140
zipClose(zip, nullptr);
141
142
if (tmp_app_dir->change_dir(tmp_dir_path) == OK) {
143
tmp_app_dir->erase_contents_recursive();
144
tmp_app_dir->change_dir("..");
145
tmp_app_dir->remove(pkg_name);
146
}
147
}
148
149
return err;
150
}
151
152
String EditorExportPlatformLinuxBSD::get_template_file_name(const String &p_target, const String &p_arch) const {
153
return "linux_" + p_target + "." + p_arch;
154
}
155
156
List<String> EditorExportPlatformLinuxBSD::get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const {
157
List<String> list;
158
list.push_back(p_preset->get("binary_format/architecture"));
159
list.push_back("zip");
160
161
return list;
162
}
163
164
bool EditorExportPlatformLinuxBSD::get_export_option_visibility(const EditorExportPreset *p_preset, const String &p_option) const {
165
if (p_preset == nullptr) {
166
return true;
167
}
168
169
bool advanced_options_enabled = p_preset->are_advanced_options_enabled();
170
171
// Hide SSH options.
172
bool ssh = p_preset->get("ssh_remote_deploy/enabled");
173
if (!ssh && p_option != "ssh_remote_deploy/enabled" && p_option.begins_with("ssh_remote_deploy/")) {
174
return false;
175
}
176
if (p_option == "dotnet/embed_build_outputs" ||
177
p_option == "custom_template/debug" ||
178
p_option == "custom_template/release") {
179
return advanced_options_enabled;
180
}
181
return true;
182
}
183
184
void EditorExportPlatformLinuxBSD::get_export_options(List<ExportOption> *r_options) const {
185
EditorExportPlatformPC::get_export_options(r_options);
186
187
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "binary_format/architecture", PROPERTY_HINT_ENUM, "x86_64,x86_32,arm64,arm32,rv64,ppc64,loongarch64"), "x86_64"));
188
189
String run_script = "#!/usr/bin/env bash\n"
190
"export DISPLAY=:0\n"
191
"unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"\n"
192
"\"{temp_dir}/{exe_name}\" {cmd_args}";
193
194
String cleanup_script = "#!/usr/bin/env bash\n"
195
"kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")\n"
196
"rm -rf \"{temp_dir}\"";
197
198
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "ssh_remote_deploy/enabled"), false, true));
199
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/host"), "user@host_ip"));
200
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/port"), "22"));
201
202
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/extra_args_ssh", PROPERTY_HINT_MULTILINE_TEXT), ""));
203
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/extra_args_scp", PROPERTY_HINT_MULTILINE_TEXT), ""));
204
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/run_script", PROPERTY_HINT_MULTILINE_TEXT), run_script));
205
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/cleanup_script", PROPERTY_HINT_MULTILINE_TEXT), cleanup_script));
206
}
207
208
bool EditorExportPlatformLinuxBSD::is_elf(const String &p_path) const {
209
Ref<FileAccess> fb = FileAccess::open(p_path, FileAccess::READ);
210
ERR_FAIL_COND_V_MSG(fb.is_null(), false, vformat("Can't open file: \"%s\".", p_path));
211
uint32_t magic = fb->get_32();
212
return (magic == 0x464c457f);
213
}
214
215
bool EditorExportPlatformLinuxBSD::is_shebang(const String &p_path) const {
216
Ref<FileAccess> fb = FileAccess::open(p_path, FileAccess::READ);
217
ERR_FAIL_COND_V_MSG(fb.is_null(), false, vformat("Can't open file: \"%s\".", p_path));
218
uint16_t magic = fb->get_16();
219
return (magic == 0x2123);
220
}
221
222
bool EditorExportPlatformLinuxBSD::is_executable(const String &p_path) const {
223
return is_elf(p_path) || is_shebang(p_path);
224
}
225
226
bool EditorExportPlatformLinuxBSD::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug) const {
227
String err;
228
bool valid = EditorExportPlatformPC::has_valid_export_configuration(p_preset, err, r_missing_templates, p_debug);
229
230
String custom_debug = p_preset->get("custom_template/debug").operator String().strip_edges();
231
String custom_release = p_preset->get("custom_template/release").operator String().strip_edges();
232
String arch = p_preset->get("binary_format/architecture");
233
234
if (!custom_debug.is_empty() && FileAccess::exists(custom_debug)) {
235
String exe_arch = _get_exe_arch(custom_debug);
236
if (arch != exe_arch) {
237
err += vformat(TTR("Mismatching custom debug export template executable architecture: found \"%s\", expected \"%s\"."), exe_arch, arch) + "\n";
238
}
239
}
240
if (!custom_release.is_empty() && FileAccess::exists(custom_release)) {
241
String exe_arch = _get_exe_arch(custom_release);
242
if (arch != exe_arch) {
243
err += vformat(TTR("Mismatching custom release export template executable architecture: found \"%s\", expected \"%s\"."), exe_arch, arch) + "\n";
244
}
245
}
246
247
if (!err.is_empty()) {
248
r_error = err;
249
}
250
251
return valid;
252
}
253
254
String EditorExportPlatformLinuxBSD::_get_exe_arch(const String &p_path) const {
255
Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::READ);
256
if (f.is_null()) {
257
return "invalid";
258
}
259
260
// Read and check ELF magic number.
261
{
262
uint32_t magic = f->get_32();
263
if (magic != 0x464c457f) { // 0x7F + "ELF"
264
return "invalid";
265
}
266
}
267
268
// Process header.
269
int64_t header_pos = f->get_position();
270
f->seek(header_pos + 14);
271
uint16_t machine = f->get_16();
272
f->close();
273
274
switch (machine) {
275
case 0x0003:
276
return "x86_32";
277
case 0x003e:
278
return "x86_64";
279
case 0x0015:
280
return "ppc64";
281
case 0x0028:
282
return "arm32";
283
case 0x00b7:
284
return "arm64";
285
case 0x00f3:
286
return "rv64";
287
case 0x0102:
288
return "loongarch64";
289
default:
290
return "unknown";
291
}
292
}
293
294
Error EditorExportPlatformLinuxBSD::fixup_embedded_pck(const String &p_path, int64_t p_embedded_start, int64_t p_embedded_size) {
295
// Patch the header of the "pck" section in the ELF file so that it corresponds to the embedded data.
296
297
Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::READ_WRITE);
298
if (f.is_null()) {
299
add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), vformat(TTR("Failed to open executable file \"%s\"."), p_path));
300
return ERR_CANT_OPEN;
301
}
302
303
// Read and check ELF magic number.
304
{
305
uint32_t magic = f->get_32();
306
if (magic != 0x464c457f) { // 0x7F + "ELF"
307
add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), TTR("Executable file header corrupted."));
308
return ERR_FILE_CORRUPT;
309
}
310
}
311
312
// Read program architecture bits from class field.
313
314
int bits = f->get_8() * 32;
315
316
if (bits == 32 && p_embedded_size >= 0x100000000) {
317
add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), TTR("32-bit executables cannot have embedded data >= 4 GiB."));
318
}
319
320
// Get info about the section header table.
321
322
int64_t section_table_pos;
323
int64_t section_header_size;
324
if (bits == 32) {
325
section_header_size = 40;
326
f->seek(0x20);
327
section_table_pos = f->get_32();
328
f->seek(0x30);
329
} else { // 64
330
section_header_size = 64;
331
f->seek(0x28);
332
section_table_pos = f->get_64();
333
f->seek(0x3c);
334
}
335
int num_sections = f->get_16();
336
int string_section_idx = f->get_16();
337
338
// Load the strings table.
339
uint8_t *strings;
340
{
341
// Jump to the strings section header.
342
f->seek(section_table_pos + string_section_idx * section_header_size);
343
344
// Read strings data size and offset.
345
int64_t string_data_pos;
346
int64_t string_data_size;
347
if (bits == 32) {
348
f->seek(f->get_position() + 0x10);
349
string_data_pos = f->get_32();
350
string_data_size = f->get_32();
351
} else { // 64
352
f->seek(f->get_position() + 0x18);
353
string_data_pos = f->get_64();
354
string_data_size = f->get_64();
355
}
356
357
// Read strings data.
358
f->seek(string_data_pos);
359
strings = (uint8_t *)memalloc(string_data_size);
360
if (!strings) {
361
return ERR_OUT_OF_MEMORY;
362
}
363
f->get_buffer(strings, string_data_size);
364
}
365
366
// Search for the "pck" section.
367
368
bool found = false;
369
for (int i = 0; i < num_sections; ++i) {
370
int64_t section_header_pos = section_table_pos + i * section_header_size;
371
f->seek(section_header_pos);
372
373
uint32_t name_offset = f->get_32();
374
if (strcmp((char *)strings + name_offset, "pck") == 0) {
375
// "pck" section found, let's patch!
376
377
if (bits == 32) {
378
f->seek(section_header_pos + 0x10);
379
f->store_32(p_embedded_start);
380
f->store_32(p_embedded_size);
381
} else { // 64
382
f->seek(section_header_pos + 0x18);
383
f->store_64(p_embedded_start);
384
f->store_64(p_embedded_size);
385
}
386
387
found = true;
388
break;
389
}
390
}
391
392
memfree(strings);
393
394
if (!found) {
395
add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), TTR("Executable \"pck\" section not found."));
396
return ERR_FILE_CORRUPT;
397
}
398
return OK;
399
}
400
401
Ref<Texture2D> EditorExportPlatformLinuxBSD::get_run_icon() const {
402
return run_icon;
403
}
404
405
bool EditorExportPlatformLinuxBSD::poll_export() {
406
Ref<EditorExportPreset> preset;
407
408
for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
409
Ref<EditorExportPreset> ep = EditorExport::get_singleton()->get_export_preset(i);
410
if (ep->is_runnable() && ep->get_platform() == this) {
411
preset = ep;
412
break;
413
}
414
}
415
416
int prev = menu_options;
417
menu_options = (preset.is_valid() && preset->get("ssh_remote_deploy/enabled").operator bool());
418
if (ssh_pid != 0 || !cleanup_commands.is_empty()) {
419
if (menu_options == 0) {
420
cleanup();
421
} else {
422
menu_options += 1;
423
}
424
}
425
return menu_options != prev;
426
}
427
428
Ref<Texture2D> EditorExportPlatformLinuxBSD::get_option_icon(int p_index) const {
429
if (p_index == 1) {
430
return stop_icon;
431
} else {
432
return EditorExportPlatform::get_option_icon(p_index);
433
}
434
}
435
436
int EditorExportPlatformLinuxBSD::get_options_count() const {
437
return menu_options;
438
}
439
440
String EditorExportPlatformLinuxBSD::get_option_label(int p_index) const {
441
return (p_index) ? TTR("Stop and uninstall") : TTR("Run on remote Linux/BSD system");
442
}
443
444
String EditorExportPlatformLinuxBSD::get_option_tooltip(int p_index) const {
445
return (p_index) ? TTR("Stop and uninstall running project from the remote system") : TTR("Run exported project on remote Linux/BSD system");
446
}
447
448
void EditorExportPlatformLinuxBSD::cleanup() {
449
if (ssh_pid != 0 && OS::get_singleton()->is_process_running(ssh_pid)) {
450
print_line("Terminating connection...");
451
OS::get_singleton()->kill(ssh_pid);
452
OS::get_singleton()->delay_usec(1000);
453
}
454
455
if (!cleanup_commands.is_empty()) {
456
print_line("Stopping and deleting previous version...");
457
for (const SSHCleanupCommand &cmd : cleanup_commands) {
458
if (cmd.wait) {
459
ssh_run_on_remote(cmd.host, cmd.port, cmd.ssh_args, cmd.cmd_args);
460
} else {
461
ssh_run_on_remote_no_wait(cmd.host, cmd.port, cmd.ssh_args, cmd.cmd_args);
462
}
463
}
464
}
465
ssh_pid = 0;
466
cleanup_commands.clear();
467
}
468
469
Error EditorExportPlatformLinuxBSD::run(const Ref<EditorExportPreset> &p_preset, int p_device, BitField<EditorExportPlatform::DebugFlags> p_debug_flags) {
470
cleanup();
471
if (p_device) { // Stop command, cleanup only.
472
return OK;
473
}
474
475
EditorProgress ep("run", TTR("Running..."), 5);
476
477
const String dest = EditorPaths::get_singleton()->get_temp_dir().path_join("linuxbsd");
478
Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
479
if (!da->dir_exists(dest)) {
480
Error err = da->make_dir_recursive(dest);
481
if (err != OK) {
482
EditorNode::get_singleton()->show_warning(TTR("Could not create temp directory:") + "\n" + dest);
483
return err;
484
}
485
}
486
487
String host = p_preset->get("ssh_remote_deploy/host").operator String();
488
String port = p_preset->get("ssh_remote_deploy/port").operator String();
489
if (port.is_empty()) {
490
port = "22";
491
}
492
Vector<String> extra_args_ssh = p_preset->get("ssh_remote_deploy/extra_args_ssh").operator String().split(" ", false);
493
Vector<String> extra_args_scp = p_preset->get("ssh_remote_deploy/extra_args_scp").operator String().split(" ", false);
494
495
const String basepath = dest.path_join("tmp_linuxbsd_export");
496
497
#define CLEANUP_AND_RETURN(m_err) \
498
{ \
499
if (da->file_exists(basepath + ".zip")) { \
500
da->remove(basepath + ".zip"); \
501
} \
502
if (da->file_exists(basepath + "_start.sh")) { \
503
da->remove(basepath + "_start.sh"); \
504
} \
505
if (da->file_exists(basepath + "_clean.sh")) { \
506
da->remove(basepath + "_clean.sh"); \
507
} \
508
return m_err; \
509
} \
510
((void)0)
511
512
if (ep.step(TTR("Exporting project..."), 1)) {
513
return ERR_SKIP;
514
}
515
Error err = export_project(p_preset, true, basepath + ".zip", p_debug_flags);
516
if (err != OK) {
517
DirAccess::remove_file_or_error(basepath + ".zip");
518
return err;
519
}
520
521
String cmd_args;
522
{
523
Vector<String> cmd_args_list = gen_export_flags(p_debug_flags);
524
for (int i = 0; i < cmd_args_list.size(); i++) {
525
if (i != 0) {
526
cmd_args += " ";
527
}
528
cmd_args += cmd_args_list[i];
529
}
530
}
531
532
const bool use_remote = p_debug_flags.has_flag(DEBUG_FLAG_REMOTE_DEBUG) || p_debug_flags.has_flag(DEBUG_FLAG_DUMB_CLIENT);
533
int dbg_port = EDITOR_GET("network/debug/remote_port");
534
535
print_line("Creating temporary directory...");
536
ep.step(TTR("Creating temporary directory..."), 2);
537
String temp_dir;
538
err = ssh_run_on_remote(host, port, extra_args_ssh, "mktemp -d", &temp_dir);
539
if (err != OK || temp_dir.is_empty()) {
540
CLEANUP_AND_RETURN(err);
541
}
542
543
print_line("Uploading archive...");
544
ep.step(TTR("Uploading archive..."), 3);
545
err = ssh_push_to_remote(host, port, extra_args_scp, basepath + ".zip", temp_dir);
546
if (err != OK) {
547
CLEANUP_AND_RETURN(err);
548
}
549
550
{
551
String run_script = p_preset->get("ssh_remote_deploy/run_script");
552
run_script = run_script.replace("{temp_dir}", temp_dir);
553
run_script = run_script.replace("{archive_name}", basepath.get_file() + ".zip");
554
run_script = run_script.replace("{exe_name}", basepath.get_file());
555
run_script = run_script.replace("{cmd_args}", cmd_args);
556
557
Ref<FileAccess> f = FileAccess::open(basepath + "_start.sh", FileAccess::WRITE);
558
if (f.is_null()) {
559
CLEANUP_AND_RETURN(err);
560
}
561
562
f->store_string(run_script);
563
}
564
565
{
566
String clean_script = p_preset->get("ssh_remote_deploy/cleanup_script");
567
clean_script = clean_script.replace("{temp_dir}", temp_dir);
568
clean_script = clean_script.replace("{archive_name}", basepath.get_file() + ".zip");
569
clean_script = clean_script.replace("{exe_name}", basepath.get_file());
570
clean_script = clean_script.replace("{cmd_args}", cmd_args);
571
572
Ref<FileAccess> f = FileAccess::open(basepath + "_clean.sh", FileAccess::WRITE);
573
if (f.is_null()) {
574
CLEANUP_AND_RETURN(err);
575
}
576
577
f->store_string(clean_script);
578
}
579
580
print_line("Uploading scripts...");
581
ep.step(TTR("Uploading scripts..."), 4);
582
err = ssh_push_to_remote(host, port, extra_args_scp, basepath + "_start.sh", temp_dir);
583
if (err != OK) {
584
CLEANUP_AND_RETURN(err);
585
}
586
err = ssh_run_on_remote(host, port, extra_args_ssh, vformat("chmod +x \"%s/%s\"", temp_dir, basepath.get_file() + "_start.sh"));
587
if (err != OK || temp_dir.is_empty()) {
588
CLEANUP_AND_RETURN(err);
589
}
590
err = ssh_push_to_remote(host, port, extra_args_scp, basepath + "_clean.sh", temp_dir);
591
if (err != OK) {
592
CLEANUP_AND_RETURN(err);
593
}
594
err = ssh_run_on_remote(host, port, extra_args_ssh, vformat("chmod +x \"%s/%s\"", temp_dir, basepath.get_file() + "_clean.sh"));
595
if (err != OK || temp_dir.is_empty()) {
596
CLEANUP_AND_RETURN(err);
597
}
598
599
print_line("Starting project...");
600
ep.step(TTR("Starting project..."), 5);
601
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);
602
if (err != OK) {
603
CLEANUP_AND_RETURN(err);
604
}
605
606
cleanup_commands.clear();
607
cleanup_commands.push_back(SSHCleanupCommand(host, port, extra_args_ssh, vformat("\"%s/%s\"", temp_dir, basepath.get_file() + "_clean.sh")));
608
609
print_line("Project started.");
610
611
CLEANUP_AND_RETURN(OK);
612
#undef CLEANUP_AND_RETURN
613
}
614
615
EditorExportPlatformLinuxBSD::EditorExportPlatformLinuxBSD() {
616
if (EditorNode::get_singleton()) {
617
Ref<Image> img = memnew(Image);
618
const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE);
619
620
ImageLoaderSVG::create_image_from_string(img, _linuxbsd_logo_svg, EDSCALE, upsample, false);
621
set_logo(ImageTexture::create_from_image(img));
622
623
ImageLoaderSVG::create_image_from_string(img, _linuxbsd_run_icon_svg, EDSCALE, upsample, false);
624
run_icon = ImageTexture::create_from_image(img);
625
626
Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme();
627
if (theme.is_valid()) {
628
stop_icon = theme->get_icon(SNAME("Stop"), EditorStringName(EditorIcons));
629
} else {
630
stop_icon.instantiate();
631
}
632
}
633
}
634
635