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