export_plugin.cpp 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028
  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 "core/io/image_loader.h"
  35. #include "editor/editor_node.h"
  36. #include "editor/editor_paths.h"
  37. #include "editor/editor_scale.h"
  38. #include "editor/export/editor_export.h"
  39. #include "modules/modules_enabled.gen.h" // For svg.
  40. #ifdef MODULE_SVG_ENABLED
  41. #include "modules/svg/image_loader_svg.h"
  42. #endif
  43. Error EditorExportPlatformWindows::_process_icon(const Ref<EditorExportPreset> &p_preset, const String &p_src_path, const String &p_dst_path) {
  44. static const uint8_t icon_size[] = { 16, 32, 48, 64, 128, 0 /*256*/ };
  45. struct IconData {
  46. Vector<uint8_t> data;
  47. uint8_t pal_colors = 0;
  48. uint16_t planes = 0;
  49. uint16_t bpp = 32;
  50. };
  51. HashMap<uint8_t, IconData> images;
  52. Error err;
  53. if (p_src_path.get_extension() == "ico") {
  54. Ref<FileAccess> f = FileAccess::open(p_src_path, FileAccess::READ, &err);
  55. if (err != OK) {
  56. return err;
  57. }
  58. // Read ICONDIR.
  59. f->get_16(); // Reserved.
  60. uint16_t icon_type = f->get_16(); // Image type: 1 - ICO.
  61. uint16_t icon_count = f->get_16(); // Number of images.
  62. ERR_FAIL_COND_V(icon_type != 1, ERR_CANT_OPEN);
  63. for (uint16_t i = 0; i < icon_count; i++) {
  64. // Read ICONDIRENTRY.
  65. uint16_t w = f->get_8(); // Width in pixels.
  66. uint16_t h = f->get_8(); // Height in pixels.
  67. uint8_t pal_colors = f->get_8(); // Number of colors in the palette (0 - no palette).
  68. f->get_8(); // Reserved.
  69. uint16_t planes = f->get_16(); // Number of color planes.
  70. uint16_t bpp = f->get_16(); // Bits per pixel.
  71. uint32_t img_size = f->get_32(); // Image data size in bytes.
  72. uint32_t img_offset = f->get_32(); // Image data offset.
  73. if (w != h) {
  74. continue;
  75. }
  76. // Read image data.
  77. uint64_t prev_offset = f->get_position();
  78. images[w].pal_colors = pal_colors;
  79. images[w].planes = planes;
  80. images[w].bpp = bpp;
  81. images[w].data.resize(img_size);
  82. f->seek(img_offset);
  83. f->get_buffer(images[w].data.ptrw(), img_size);
  84. f->seek(prev_offset);
  85. }
  86. } else {
  87. Ref<Image> src_image;
  88. src_image.instantiate();
  89. err = ImageLoader::load_image(p_src_path, src_image);
  90. ERR_FAIL_COND_V(err != OK || src_image->is_empty(), ERR_CANT_OPEN);
  91. for (size_t i = 0; i < sizeof(icon_size) / sizeof(icon_size[0]); ++i) {
  92. int size = (icon_size[i] == 0) ? 256 : icon_size[i];
  93. Ref<Image> res_image = src_image->duplicate();
  94. ERR_FAIL_COND_V(res_image.is_null() || res_image->is_empty(), ERR_CANT_OPEN);
  95. res_image->resize(size, size, (Image::Interpolation)(p_preset->get("application/icon_interpolation").operator int()));
  96. images[icon_size[i]].data = res_image->save_png_to_buffer();
  97. }
  98. }
  99. uint16_t valid_icon_count = 0;
  100. for (size_t i = 0; i < sizeof(icon_size) / sizeof(icon_size[0]); ++i) {
  101. if (images.has(icon_size[i])) {
  102. valid_icon_count++;
  103. } else {
  104. int size = (icon_size[i] == 0) ? 256 : icon_size[i];
  105. add_message(EXPORT_MESSAGE_WARNING, TTR("Resources Modification"), vformat(TTR("Icon size \"%d\" is missing."), size));
  106. }
  107. }
  108. ERR_FAIL_COND_V(valid_icon_count == 0, ERR_CANT_OPEN);
  109. Ref<FileAccess> fw = FileAccess::open(p_dst_path, FileAccess::WRITE, &err);
  110. if (err != OK) {
  111. return err;
  112. }
  113. // Write ICONDIR.
  114. fw->store_16(0); // Reserved.
  115. fw->store_16(1); // Image type: 1 - ICO.
  116. fw->store_16(valid_icon_count); // Number of images.
  117. // Write ICONDIRENTRY.
  118. uint32_t img_offset = 6 + 16 * valid_icon_count;
  119. for (size_t i = 0; i < sizeof(icon_size) / sizeof(icon_size[0]); ++i) {
  120. if (images.has(icon_size[i])) {
  121. const IconData &di = images[icon_size[i]];
  122. fw->store_8(icon_size[i]); // Width in pixels.
  123. fw->store_8(icon_size[i]); // Height in pixels.
  124. fw->store_8(di.pal_colors); // Number of colors in the palette (0 - no palette).
  125. fw->store_8(0); // Reserved.
  126. fw->store_16(di.planes); // Number of color planes.
  127. fw->store_16(di.bpp); // Bits per pixel.
  128. fw->store_32(di.data.size()); // Image data size in bytes.
  129. fw->store_32(img_offset); // Image data offset.
  130. img_offset += di.data.size();
  131. }
  132. }
  133. // Write image data.
  134. for (size_t i = 0; i < sizeof(icon_size) / sizeof(icon_size[0]); ++i) {
  135. if (images.has(icon_size[i])) {
  136. const IconData &di = images[icon_size[i]];
  137. fw->store_buffer(di.data.ptr(), di.data.size());
  138. }
  139. }
  140. return OK;
  141. }
  142. Error EditorExportPlatformWindows::sign_shared_object(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path) {
  143. if (p_preset->get("codesign/enable")) {
  144. return _code_sign(p_preset, p_path);
  145. } else {
  146. return OK;
  147. }
  148. }
  149. Error EditorExportPlatformWindows::modify_template(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
  150. if (p_preset->get("application/modify_resources")) {
  151. _rcedit_add_data(p_preset, p_path, true);
  152. String wrapper_path = p_path.get_basename() + ".console.exe";
  153. if (FileAccess::exists(wrapper_path)) {
  154. _rcedit_add_data(p_preset, wrapper_path, false);
  155. }
  156. }
  157. return OK;
  158. }
  159. Error EditorExportPlatformWindows::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
  160. bool export_as_zip = p_path.ends_with("zip");
  161. bool embedded = p_preset->get("binary_format/embed_pck");
  162. String pkg_name;
  163. if (String(ProjectSettings::get_singleton()->get("application/config/name")) != "") {
  164. pkg_name = String(ProjectSettings::get_singleton()->get("application/config/name"));
  165. } else {
  166. pkg_name = "Unnamed";
  167. }
  168. pkg_name = OS::get_singleton()->get_safe_dir_name(pkg_name);
  169. // Setup temp folder.
  170. String path = p_path;
  171. String tmp_dir_path = EditorPaths::get_singleton()->get_cache_dir().path_join(pkg_name);
  172. Ref<DirAccess> tmp_app_dir = DirAccess::create_for_path(tmp_dir_path);
  173. if (export_as_zip) {
  174. if (tmp_app_dir.is_null()) {
  175. return ERR_CANT_CREATE;
  176. }
  177. if (DirAccess::exists(tmp_dir_path)) {
  178. if (tmp_app_dir->change_dir(tmp_dir_path) == OK) {
  179. tmp_app_dir->erase_contents_recursive();
  180. }
  181. }
  182. tmp_app_dir->make_dir_recursive(tmp_dir_path);
  183. path = tmp_dir_path.path_join(p_path.get_file().get_basename() + ".exe");
  184. }
  185. // Export project.
  186. String pck_path = path;
  187. if (embedded) {
  188. pck_path = pck_path.get_basename() + ".tmp";
  189. }
  190. Error err = EditorExportPlatformPC::export_project(p_preset, p_debug, pck_path, p_flags);
  191. if (p_preset->get("codesign/enable") && err == OK) {
  192. _code_sign(p_preset, pck_path);
  193. String wrapper_path = p_path.get_basename() + ".console.exe";
  194. if (FileAccess::exists(wrapper_path)) {
  195. _code_sign(p_preset, wrapper_path);
  196. }
  197. }
  198. if (embedded && err == OK) {
  199. Ref<DirAccess> tmp_dir = DirAccess::create_for_path(p_path.get_base_dir());
  200. err = tmp_dir->rename(pck_path, p_path);
  201. if (err != OK) {
  202. add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), vformat(TTR("Failed to rename temporary file \"%s\"."), pck_path));
  203. }
  204. }
  205. // ZIP project.
  206. if (export_as_zip) {
  207. if (FileAccess::exists(p_path)) {
  208. OS::get_singleton()->move_to_trash(p_path);
  209. }
  210. Ref<FileAccess> io_fa_dst;
  211. zlib_filefunc_def io_dst = zipio_create_io(&io_fa_dst);
  212. zipFile zip = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io_dst);
  213. zip_folder_recursive(zip, tmp_dir_path, "", pkg_name);
  214. zipClose(zip, nullptr);
  215. if (tmp_app_dir->change_dir(tmp_dir_path) == OK) {
  216. tmp_app_dir->erase_contents_recursive();
  217. tmp_app_dir->change_dir("..");
  218. tmp_app_dir->remove(pkg_name);
  219. }
  220. }
  221. return err;
  222. }
  223. String EditorExportPlatformWindows::get_template_file_name(const String &p_target, const String &p_arch) const {
  224. return "windows_" + p_target + "_" + p_arch + ".exe";
  225. }
  226. List<String> EditorExportPlatformWindows::get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const {
  227. List<String> list;
  228. list.push_back("exe");
  229. list.push_back("zip");
  230. return list;
  231. }
  232. String EditorExportPlatformWindows::get_export_option_warning(const EditorExportPreset *p_preset, const StringName &p_name) const {
  233. if (p_preset) {
  234. if (p_name == "application/icon") {
  235. String icon_path = ProjectSettings::get_singleton()->globalize_path(p_preset->get("application/icon"));
  236. if (!icon_path.is_empty() && !FileAccess::exists(icon_path)) {
  237. return TTR("Invalid icon path.");
  238. }
  239. } else if (p_name == "application/file_version") {
  240. String file_version = p_preset->get("application/file_version");
  241. if (!file_version.is_empty()) {
  242. PackedStringArray version_array = file_version.split(".", false);
  243. if (version_array.size() != 4 || !version_array[0].is_valid_int() ||
  244. !version_array[1].is_valid_int() || !version_array[2].is_valid_int() ||
  245. !version_array[3].is_valid_int() || file_version.find("-") > -1) {
  246. return TTR("Invalid file version.");
  247. }
  248. }
  249. } else if (p_name == "application/product_version") {
  250. String product_version = p_preset->get("application/product_version");
  251. if (!product_version.is_empty()) {
  252. PackedStringArray version_array = product_version.split(".", false);
  253. if (version_array.size() != 4 || !version_array[0].is_valid_int() ||
  254. !version_array[1].is_valid_int() || !version_array[2].is_valid_int() ||
  255. !version_array[3].is_valid_int() || product_version.find("-") > -1) {
  256. return TTR("Invalid product version.");
  257. }
  258. }
  259. }
  260. }
  261. return EditorExportPlatformPC::get_export_option_warning(p_preset, p_name);
  262. }
  263. bool EditorExportPlatformWindows::get_export_option_visibility(const EditorExportPreset *p_preset, const String &p_option) const {
  264. // This option is not supported by "osslsigncode", used on non-Windows host.
  265. if (!OS::get_singleton()->has_feature("windows") && p_option == "codesign/identity_type") {
  266. return false;
  267. }
  268. // Hide codesign.
  269. bool codesign = p_preset->get("codesign/enable");
  270. if (!codesign && p_option != "codesign/enable" && p_option.begins_with("codesign/")) {
  271. return false;
  272. }
  273. // Hide resources.
  274. bool mod_res = p_preset->get("application/modify_resources");
  275. if (!mod_res && p_option != "application/modify_resources" && p_option.begins_with("application/")) {
  276. return false;
  277. }
  278. // Hide SSH options.
  279. bool ssh = p_preset->get("ssh_remote_deploy/enabled");
  280. if (!ssh && p_option != "ssh_remote_deploy/enabled" && p_option.begins_with("ssh_remote_deploy/")) {
  281. return false;
  282. }
  283. return true;
  284. }
  285. void EditorExportPlatformWindows::get_export_options(List<ExportOption> *r_options) const {
  286. EditorExportPlatformPC::get_export_options(r_options);
  287. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "binary_format/architecture", PROPERTY_HINT_ENUM, "x86_64,x86_32,arm64"), "x86_64"));
  288. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/enable"), false, true));
  289. r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/identity_type", PROPERTY_HINT_ENUM, "Select automatically,Use PKCS12 file (specify *.PFX/*.P12 file),Use certificate store (specify SHA-1 hash)", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_SECRET), 0));
  290. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/identity", PROPERTY_HINT_GLOBAL_FILE, "*.pfx,*.p12", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_SECRET), ""));
  291. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/password", PROPERTY_HINT_PASSWORD, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_SECRET), ""));
  292. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/timestamp"), true));
  293. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/timestamp_server_url"), ""));
  294. r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/digest_algorithm", PROPERTY_HINT_ENUM, "SHA1,SHA256"), 1));
  295. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/description"), ""));
  296. r_options->push_back(ExportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "codesign/custom_options"), PackedStringArray()));
  297. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "application/modify_resources"), true, true));
  298. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/icon", PROPERTY_HINT_FILE, "*.ico,*.png,*.webp,*.svg"), "", false, true));
  299. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/console_wrapper_icon", PROPERTY_HINT_FILE, "*.ico,*.png,*.webp,*.svg"), ""));
  300. r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "application/icon_interpolation", PROPERTY_HINT_ENUM, "Nearest neighbor,Bilinear,Cubic,Trilinear,Lanczos"), 4));
  301. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/file_version", PROPERTY_HINT_PLACEHOLDER_TEXT, "1.0.0.0"), "", false, true));
  302. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/product_version", PROPERTY_HINT_PLACEHOLDER_TEXT, "1.0.0.0"), "", false, true));
  303. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/company_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Company Name"), ""));
  304. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/product_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game Name"), ""));
  305. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/file_description"), ""));
  306. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/copyright"), ""));
  307. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/trademarks"), ""));
  308. String run_script = "Expand-Archive -LiteralPath '{temp_dir}\\{archive_name}' -DestinationPath '{temp_dir}'\n"
  309. "$action = New-ScheduledTaskAction -Execute '{temp_dir}\\{exe_name}' -Argument '{cmd_args}'\n"
  310. "$trigger = New-ScheduledTaskTrigger -Once -At 00:00\n"
  311. "$settings = New-ScheduledTaskSettingsSet\n"
  312. "$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings\n"
  313. "Register-ScheduledTask godot_remote_debug -InputObject $task -Force:$true\n"
  314. "Start-ScheduledTask -TaskName godot_remote_debug\n"
  315. "while (Get-ScheduledTask -TaskName godot_remote_debug | ? State -eq running) { Start-Sleep -Milliseconds 100 }\n"
  316. "Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue";
  317. String cleanup_script = "Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue\n"
  318. "Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue\n"
  319. "Remove-Item -Recurse -Force '{temp_dir}'";
  320. r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "ssh_remote_deploy/enabled"), false, true));
  321. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/host"), "user@host_ip"));
  322. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/port"), "22"));
  323. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/extra_args_ssh", PROPERTY_HINT_MULTILINE_TEXT), ""));
  324. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/extra_args_scp", PROPERTY_HINT_MULTILINE_TEXT), ""));
  325. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/run_script", PROPERTY_HINT_MULTILINE_TEXT), run_script));
  326. r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/cleanup_script", PROPERTY_HINT_MULTILINE_TEXT), cleanup_script));
  327. }
  328. Error EditorExportPlatformWindows::_rcedit_add_data(const Ref<EditorExportPreset> &p_preset, const String &p_path, bool p_console_icon) {
  329. String rcedit_path = EDITOR_GET("export/windows/rcedit");
  330. if (rcedit_path != String() && !FileAccess::exists(rcedit_path)) {
  331. add_message(EXPORT_MESSAGE_WARNING, TTR("Resources Modification"), vformat(TTR("Could not find rcedit executable at \"%s\"."), rcedit_path));
  332. return ERR_FILE_NOT_FOUND;
  333. }
  334. if (rcedit_path == String()) {
  335. rcedit_path = "rcedit"; // try to run rcedit from PATH
  336. }
  337. #ifndef WINDOWS_ENABLED
  338. // On non-Windows we need WINE to run rcedit
  339. String wine_path = EDITOR_GET("export/windows/wine");
  340. if (!wine_path.is_empty() && !FileAccess::exists(wine_path)) {
  341. add_message(EXPORT_MESSAGE_WARNING, TTR("Resources Modification"), vformat(TTR("Could not find wine executable at \"%s\"."), wine_path));
  342. return ERR_FILE_NOT_FOUND;
  343. }
  344. if (wine_path.is_empty()) {
  345. wine_path = "wine"; // try to run wine from PATH
  346. }
  347. #endif
  348. String icon_path;
  349. if (p_preset->get("application/icon") != "") {
  350. icon_path = p_preset->get("application/icon");
  351. } else if (GLOBAL_GET("application/config/windows_native_icon") != "") {
  352. icon_path = GLOBAL_GET("application/config/windows_native_icon");
  353. } else {
  354. icon_path = GLOBAL_GET("application/config/icon");
  355. }
  356. icon_path = ProjectSettings::get_singleton()->globalize_path(icon_path);
  357. if (p_console_icon) {
  358. String console_icon_path = ProjectSettings::get_singleton()->globalize_path(p_preset->get("application/console_wrapper_icon"));
  359. if (!console_icon_path.is_empty() && FileAccess::exists(console_icon_path)) {
  360. icon_path = console_icon_path;
  361. }
  362. }
  363. String tmp_icon_path = EditorPaths::get_singleton()->get_cache_dir().path_join("_rcedit.ico");
  364. if (!icon_path.is_empty()) {
  365. if (_process_icon(p_preset, icon_path, tmp_icon_path) != OK) {
  366. add_message(EXPORT_MESSAGE_WARNING, TTR("Resources Modification"), vformat(TTR("Invalid icon file \"%s\"."), icon_path));
  367. icon_path = String();
  368. }
  369. }
  370. String file_verion = p_preset->get("application/file_version");
  371. String product_version = p_preset->get("application/product_version");
  372. String company_name = p_preset->get("application/company_name");
  373. String product_name = p_preset->get("application/product_name");
  374. String file_description = p_preset->get("application/file_description");
  375. String copyright = p_preset->get("application/copyright");
  376. String trademarks = p_preset->get("application/trademarks");
  377. String comments = p_preset->get("application/comments");
  378. List<String> args;
  379. args.push_back(p_path);
  380. if (!icon_path.is_empty()) {
  381. args.push_back("--set-icon");
  382. args.push_back(tmp_icon_path);
  383. }
  384. if (!file_verion.is_empty()) {
  385. args.push_back("--set-file-version");
  386. args.push_back(file_verion);
  387. }
  388. if (!product_version.is_empty()) {
  389. args.push_back("--set-product-version");
  390. args.push_back(product_version);
  391. }
  392. if (!company_name.is_empty()) {
  393. args.push_back("--set-version-string");
  394. args.push_back("CompanyName");
  395. args.push_back(company_name);
  396. }
  397. if (!product_name.is_empty()) {
  398. args.push_back("--set-version-string");
  399. args.push_back("ProductName");
  400. args.push_back(product_name);
  401. }
  402. if (!file_description.is_empty()) {
  403. args.push_back("--set-version-string");
  404. args.push_back("FileDescription");
  405. args.push_back(file_description);
  406. }
  407. if (!copyright.is_empty()) {
  408. args.push_back("--set-version-string");
  409. args.push_back("LegalCopyright");
  410. args.push_back(copyright);
  411. }
  412. if (!trademarks.is_empty()) {
  413. args.push_back("--set-version-string");
  414. args.push_back("LegalTrademarks");
  415. args.push_back(trademarks);
  416. }
  417. #ifndef WINDOWS_ENABLED
  418. // On non-Windows we need WINE to run rcedit
  419. args.push_front(rcedit_path);
  420. rcedit_path = wine_path;
  421. #endif
  422. String str;
  423. Error err = OS::get_singleton()->execute(rcedit_path, args, &str, nullptr, true);
  424. if (FileAccess::exists(tmp_icon_path)) {
  425. DirAccess::remove_file_or_error(tmp_icon_path);
  426. }
  427. if (err != OK || (str.find("not found") != -1) || (str.find("not recognized") != -1)) {
  428. add_message(EXPORT_MESSAGE_WARNING, TTR("Resources Modification"), TTR("Could not start rcedit executable. Configure rcedit path in the Editor Settings (Export > Windows > rcedit), or disable \"Application > Modify Resources\" in the export preset."));
  429. return err;
  430. }
  431. print_line("rcedit (" + p_path + "): " + str);
  432. if (str.find("Fatal error") != -1) {
  433. add_message(EXPORT_MESSAGE_WARNING, TTR("Resources Modification"), vformat(TTR("rcedit failed to modify executable: %s."), str));
  434. return FAILED;
  435. }
  436. return OK;
  437. }
  438. Error EditorExportPlatformWindows::_code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path) {
  439. List<String> args;
  440. #ifdef WINDOWS_ENABLED
  441. String signtool_path = EDITOR_GET("export/windows/signtool");
  442. if (!signtool_path.is_empty() && !FileAccess::exists(signtool_path)) {
  443. add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), vformat(TTR("Could not find signtool executable at \"%s\"."), signtool_path));
  444. return ERR_FILE_NOT_FOUND;
  445. }
  446. if (signtool_path.is_empty()) {
  447. signtool_path = "signtool"; // try to run signtool from PATH
  448. }
  449. #else
  450. String signtool_path = EDITOR_GET("export/windows/osslsigncode");
  451. if (!signtool_path.is_empty() && !FileAccess::exists(signtool_path)) {
  452. add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), vformat(TTR("Could not find osslsigncode executable at \"%s\"."), signtool_path));
  453. return ERR_FILE_NOT_FOUND;
  454. }
  455. if (signtool_path.is_empty()) {
  456. signtool_path = "osslsigncode"; // try to run signtool from PATH
  457. }
  458. #endif
  459. args.push_back("sign");
  460. //identity
  461. #ifdef WINDOWS_ENABLED
  462. int id_type = p_preset->get_or_env("codesign/identity_type", ENV_WIN_CODESIGN_ID_TYPE);
  463. if (id_type == 0) { //auto select
  464. args.push_back("/a");
  465. } else if (id_type == 1) { //pkcs12
  466. if (p_preset->get_or_env("codesign/identity", ENV_WIN_CODESIGN_ID) != "") {
  467. args.push_back("/f");
  468. args.push_back(p_preset->get_or_env("codesign/identity", ENV_WIN_CODESIGN_ID));
  469. } else {
  470. add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("No identity found."));
  471. return FAILED;
  472. }
  473. } else if (id_type == 2) { //Windows certificate store
  474. if (p_preset->get_or_env("codesign/identity", ENV_WIN_CODESIGN_ID) != "") {
  475. args.push_back("/sha1");
  476. args.push_back(p_preset->get_or_env("codesign/identity", ENV_WIN_CODESIGN_ID));
  477. } else {
  478. add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("No identity found."));
  479. return FAILED;
  480. }
  481. } else {
  482. add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("Invalid identity type."));
  483. return FAILED;
  484. }
  485. #else
  486. int id_type = 1;
  487. if (p_preset->get_or_env("codesign/identity", ENV_WIN_CODESIGN_ID) != "") {
  488. args.push_back("-pkcs12");
  489. args.push_back(p_preset->get_or_env("codesign/identity", ENV_WIN_CODESIGN_ID));
  490. } else {
  491. add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("No identity found."));
  492. return FAILED;
  493. }
  494. #endif
  495. //password
  496. if ((id_type == 1) && (p_preset->get_or_env("codesign/password", ENV_WIN_CODESIGN_PASS) != "")) {
  497. #ifdef WINDOWS_ENABLED
  498. args.push_back("/p");
  499. #else
  500. args.push_back("-pass");
  501. #endif
  502. args.push_back(p_preset->get_or_env("codesign/password", ENV_WIN_CODESIGN_PASS));
  503. }
  504. //timestamp
  505. if (p_preset->get("codesign/timestamp")) {
  506. if (p_preset->get("codesign/timestamp_server") != "") {
  507. #ifdef WINDOWS_ENABLED
  508. args.push_back("/tr");
  509. args.push_back(p_preset->get("codesign/timestamp_server_url"));
  510. args.push_back("/td");
  511. if ((int)p_preset->get("codesign/digest_algorithm") == 0) {
  512. args.push_back("sha1");
  513. } else {
  514. args.push_back("sha256");
  515. }
  516. #else
  517. args.push_back("-ts");
  518. args.push_back(p_preset->get("codesign/timestamp_server_url"));
  519. #endif
  520. } else {
  521. add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("Invalid timestamp server."));
  522. return FAILED;
  523. }
  524. }
  525. //digest
  526. #ifdef WINDOWS_ENABLED
  527. args.push_back("/fd");
  528. #else
  529. args.push_back("-h");
  530. #endif
  531. if ((int)p_preset->get("codesign/digest_algorithm") == 0) {
  532. args.push_back("sha1");
  533. } else {
  534. args.push_back("sha256");
  535. }
  536. //description
  537. if (p_preset->get("codesign/description") != "") {
  538. #ifdef WINDOWS_ENABLED
  539. args.push_back("/d");
  540. #else
  541. args.push_back("-n");
  542. #endif
  543. args.push_back(p_preset->get("codesign/description"));
  544. }
  545. //user options
  546. PackedStringArray user_args = p_preset->get("codesign/custom_options");
  547. for (int i = 0; i < user_args.size(); i++) {
  548. String user_arg = user_args[i].strip_edges();
  549. if (!user_arg.is_empty()) {
  550. args.push_back(user_arg);
  551. }
  552. }
  553. #ifndef WINDOWS_ENABLED
  554. args.push_back("-in");
  555. #endif
  556. args.push_back(p_path);
  557. #ifndef WINDOWS_ENABLED
  558. args.push_back("-out");
  559. args.push_back(p_path + "_signed");
  560. #endif
  561. String str;
  562. Error err = OS::get_singleton()->execute(signtool_path, args, &str, nullptr, true);
  563. if (err != OK || (str.find("not found") != -1) || (str.find("not recognized") != -1)) {
  564. #ifdef WINDOWS_ENABLED
  565. add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("Could not start signtool executable. Configure signtool path in the Editor Settings (Export > Windows > signtool), or disable \"Codesign\" in the export preset."));
  566. #else
  567. add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("Could not start osslsigncode executable. Configure signtool path in the Editor Settings (Export > Windows > osslsigncode), or disable \"Codesign\" in the export preset."));
  568. #endif
  569. return err;
  570. }
  571. print_line("codesign (" + p_path + "): " + str);
  572. #ifndef WINDOWS_ENABLED
  573. if (str.find("SignTool Error") != -1) {
  574. #else
  575. if (str.find("Failed") != -1) {
  576. #endif
  577. add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), vformat(TTR("Signtool failed to sign executable: %s."), str));
  578. return FAILED;
  579. }
  580. #ifndef WINDOWS_ENABLED
  581. Ref<DirAccess> tmp_dir = DirAccess::create_for_path(p_path.get_base_dir());
  582. err = tmp_dir->remove(p_path);
  583. if (err != OK) {
  584. add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), vformat(TTR("Failed to remove temporary file \"%s\"."), p_path));
  585. return err;
  586. }
  587. err = tmp_dir->rename(p_path + "_signed", p_path);
  588. if (err != OK) {
  589. add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), vformat(TTR("Failed to rename temporary file \"%s\"."), p_path + "_signed"));
  590. return err;
  591. }
  592. #endif
  593. return OK;
  594. }
  595. bool EditorExportPlatformWindows::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug) const {
  596. String err = "";
  597. bool valid = EditorExportPlatformPC::has_valid_export_configuration(p_preset, err, r_missing_templates, p_debug);
  598. String rcedit_path = EDITOR_GET("export/windows/rcedit");
  599. if (p_preset->get("application/modify_resources") && rcedit_path.is_empty()) {
  600. err += TTR("The rcedit tool must be configured in the Editor Settings (Export > Windows > rcedit) to change the icon or app information data.") + "\n";
  601. }
  602. if (!err.is_empty()) {
  603. r_error = err;
  604. }
  605. return valid;
  606. }
  607. bool EditorExportPlatformWindows::has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const {
  608. String err = "";
  609. bool valid = true;
  610. List<ExportOption> options;
  611. get_export_options(&options);
  612. for (const EditorExportPlatform::ExportOption &E : options) {
  613. if (get_export_option_visibility(p_preset.ptr(), E.option.name)) {
  614. String warn = get_export_option_warning(p_preset.ptr(), E.option.name);
  615. if (!warn.is_empty()) {
  616. err += warn + "\n";
  617. if (E.required) {
  618. valid = false;
  619. }
  620. }
  621. }
  622. }
  623. if (!err.is_empty()) {
  624. r_error = err;
  625. }
  626. return valid;
  627. }
  628. Error EditorExportPlatformWindows::fixup_embedded_pck(const String &p_path, int64_t p_embedded_start, int64_t p_embedded_size) {
  629. // Patch the header of the "pck" section in the PE file so that it corresponds to the embedded data
  630. if (p_embedded_size + p_embedded_start >= 0x100000000) { // Check for total executable size
  631. add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), TTR("Windows executables cannot be >= 4 GiB."));
  632. return ERR_INVALID_DATA;
  633. }
  634. Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::READ_WRITE);
  635. if (f.is_null()) {
  636. add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), vformat(TTR("Failed to open executable file \"%s\"."), p_path));
  637. return ERR_CANT_OPEN;
  638. }
  639. // Jump to the PE header and check the magic number
  640. {
  641. f->seek(0x3c);
  642. uint32_t pe_pos = f->get_32();
  643. f->seek(pe_pos);
  644. uint32_t magic = f->get_32();
  645. if (magic != 0x00004550) {
  646. add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), TTR("Executable file header corrupted."));
  647. return ERR_FILE_CORRUPT;
  648. }
  649. }
  650. // Process header
  651. int num_sections;
  652. {
  653. int64_t header_pos = f->get_position();
  654. f->seek(header_pos + 2);
  655. num_sections = f->get_16();
  656. f->seek(header_pos + 16);
  657. uint16_t opt_header_size = f->get_16();
  658. // Skip rest of header + optional header to go to the section headers
  659. f->seek(f->get_position() + 2 + opt_header_size);
  660. }
  661. // Search for the "pck" section
  662. int64_t section_table_pos = f->get_position();
  663. bool found = false;
  664. for (int i = 0; i < num_sections; ++i) {
  665. int64_t section_header_pos = section_table_pos + i * 40;
  666. f->seek(section_header_pos);
  667. uint8_t section_name[9];
  668. f->get_buffer(section_name, 8);
  669. section_name[8] = '\0';
  670. if (strcmp((char *)section_name, "pck") == 0) {
  671. // "pck" section found, let's patch!
  672. // Set virtual size to a little to avoid it taking memory (zero would give issues)
  673. f->seek(section_header_pos + 8);
  674. f->store_32(8);
  675. f->seek(section_header_pos + 16);
  676. f->store_32(p_embedded_size);
  677. f->seek(section_header_pos + 20);
  678. f->store_32(p_embedded_start);
  679. found = true;
  680. break;
  681. }
  682. }
  683. if (!found) {
  684. add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), TTR("Executable \"pck\" section not found."));
  685. return ERR_FILE_CORRUPT;
  686. }
  687. return OK;
  688. }
  689. Ref<Texture2D> EditorExportPlatformWindows::get_run_icon() const {
  690. return run_icon;
  691. }
  692. bool EditorExportPlatformWindows::poll_export() {
  693. Ref<EditorExportPreset> preset;
  694. for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
  695. Ref<EditorExportPreset> ep = EditorExport::get_singleton()->get_export_preset(i);
  696. if (ep->is_runnable() && ep->get_platform() == this) {
  697. preset = ep;
  698. break;
  699. }
  700. }
  701. int prev = menu_options;
  702. menu_options = (preset.is_valid() && preset->get("ssh_remote_deploy/enabled").operator bool());
  703. if (ssh_pid != 0 || !cleanup_commands.is_empty()) {
  704. if (menu_options == 0) {
  705. cleanup();
  706. } else {
  707. menu_options += 1;
  708. }
  709. }
  710. return menu_options != prev;
  711. }
  712. Ref<ImageTexture> EditorExportPlatformWindows::get_option_icon(int p_index) const {
  713. return p_index == 1 ? stop_icon : EditorExportPlatform::get_option_icon(p_index);
  714. }
  715. int EditorExportPlatformWindows::get_options_count() const {
  716. return menu_options;
  717. }
  718. String EditorExportPlatformWindows::get_option_label(int p_index) const {
  719. return (p_index) ? TTR("Stop and uninstall") : TTR("Run on remote Windows system");
  720. }
  721. String EditorExportPlatformWindows::get_option_tooltip(int p_index) const {
  722. return (p_index) ? TTR("Stop and uninstall running project from the remote system") : TTR("Run exported project on remote Windows system");
  723. }
  724. void EditorExportPlatformWindows::cleanup() {
  725. if (ssh_pid != 0 && OS::get_singleton()->is_process_running(ssh_pid)) {
  726. print_line("Terminating connection...");
  727. OS::get_singleton()->kill(ssh_pid);
  728. OS::get_singleton()->delay_usec(1000);
  729. }
  730. if (!cleanup_commands.is_empty()) {
  731. print_line("Stopping and deleting previous version...");
  732. for (const SSHCleanupCommand &cmd : cleanup_commands) {
  733. if (cmd.wait) {
  734. ssh_run_on_remote(cmd.host, cmd.port, cmd.ssh_args, cmd.cmd_args);
  735. } else {
  736. ssh_run_on_remote_no_wait(cmd.host, cmd.port, cmd.ssh_args, cmd.cmd_args);
  737. }
  738. }
  739. }
  740. ssh_pid = 0;
  741. cleanup_commands.clear();
  742. }
  743. Error EditorExportPlatformWindows::run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags) {
  744. cleanup();
  745. if (p_device) { // Stop command, cleanup only.
  746. return OK;
  747. }
  748. EditorProgress ep("run", TTR("Running..."), 5);
  749. const String dest = EditorPaths::get_singleton()->get_cache_dir().path_join("windows");
  750. Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
  751. if (!da->dir_exists(dest)) {
  752. Error err = da->make_dir_recursive(dest);
  753. if (err != OK) {
  754. EditorNode::get_singleton()->show_warning(TTR("Could not create temp directory:") + "\n" + dest);
  755. return err;
  756. }
  757. }
  758. String host = p_preset->get("ssh_remote_deploy/host").operator String();
  759. String port = p_preset->get("ssh_remote_deploy/port").operator String();
  760. if (port.is_empty()) {
  761. port = "22";
  762. }
  763. Vector<String> extra_args_ssh = p_preset->get("ssh_remote_deploy/extra_args_ssh").operator String().split(" ", false);
  764. Vector<String> extra_args_scp = p_preset->get("ssh_remote_deploy/extra_args_scp").operator String().split(" ", false);
  765. const String basepath = dest.path_join("tmp_windows_export");
  766. #define CLEANUP_AND_RETURN(m_err) \
  767. { \
  768. if (da->file_exists(basepath + ".zip")) { \
  769. da->remove(basepath + ".zip"); \
  770. } \
  771. if (da->file_exists(basepath + "_start.ps1")) { \
  772. da->remove(basepath + "_start.ps1"); \
  773. } \
  774. if (da->file_exists(basepath + "_clean.ps1")) { \
  775. da->remove(basepath + "_clean.ps1"); \
  776. } \
  777. return m_err; \
  778. } \
  779. ((void)0)
  780. if (ep.step(TTR("Exporting project..."), 1)) {
  781. return ERR_SKIP;
  782. }
  783. Error err = export_project(p_preset, true, basepath + ".zip", p_debug_flags);
  784. if (err != OK) {
  785. DirAccess::remove_file_or_error(basepath + ".zip");
  786. return err;
  787. }
  788. String cmd_args;
  789. {
  790. Vector<String> cmd_args_list;
  791. gen_debug_flags(cmd_args_list, p_debug_flags);
  792. for (int i = 0; i < cmd_args_list.size(); i++) {
  793. if (i != 0) {
  794. cmd_args += " ";
  795. }
  796. cmd_args += cmd_args_list[i];
  797. }
  798. }
  799. const bool use_remote = (p_debug_flags & DEBUG_FLAG_REMOTE_DEBUG) || (p_debug_flags & DEBUG_FLAG_DUMB_CLIENT);
  800. int dbg_port = EditorSettings::get_singleton()->get("network/debug/remote_port");
  801. print_line("Creating temporary directory...");
  802. ep.step(TTR("Creating temporary directory..."), 2);
  803. String temp_dir;
  804. #ifndef WINDOWS_ENABLED
  805. err = ssh_run_on_remote(host, port, extra_args_ssh, "powershell -command \\\"\\$tmp = Join-Path \\$Env:Temp \\$(New-Guid); New-Item -Type Directory -Path \\$tmp | Out-Null; Write-Output \\$tmp\\\"", &temp_dir);
  806. #else
  807. err = ssh_run_on_remote(host, port, extra_args_ssh, "powershell -command \"$tmp = Join-Path $Env:Temp $(New-Guid); New-Item -Type Directory -Path $tmp ^| Out-Null; Write-Output $tmp\"", &temp_dir);
  808. #endif
  809. if (err != OK || temp_dir.is_empty()) {
  810. CLEANUP_AND_RETURN(err);
  811. }
  812. print_line("Uploading archive...");
  813. ep.step(TTR("Uploading archive..."), 3);
  814. err = ssh_push_to_remote(host, port, extra_args_scp, basepath + ".zip", temp_dir);
  815. if (err != OK) {
  816. CLEANUP_AND_RETURN(err);
  817. }
  818. if (cmd_args.is_empty()) {
  819. cmd_args = " ";
  820. }
  821. {
  822. String run_script = p_preset->get("ssh_remote_deploy/run_script");
  823. run_script = run_script.replace("{temp_dir}", temp_dir);
  824. run_script = run_script.replace("{archive_name}", basepath.get_file() + ".zip");
  825. run_script = run_script.replace("{exe_name}", basepath.get_file() + ".exe");
  826. run_script = run_script.replace("{cmd_args}", cmd_args);
  827. Ref<FileAccess> f = FileAccess::open(basepath + "_start.ps1", FileAccess::WRITE);
  828. if (f.is_null()) {
  829. CLEANUP_AND_RETURN(err);
  830. }
  831. f->store_string(run_script);
  832. }
  833. {
  834. String clean_script = p_preset->get("ssh_remote_deploy/cleanup_script");
  835. clean_script = clean_script.replace("{temp_dir}", temp_dir);
  836. clean_script = clean_script.replace("{archive_name}", basepath.get_file() + ".zip");
  837. clean_script = clean_script.replace("{exe_name}", basepath.get_file() + ".exe");
  838. clean_script = clean_script.replace("{cmd_args}", cmd_args);
  839. Ref<FileAccess> f = FileAccess::open(basepath + "_clean.ps1", FileAccess::WRITE);
  840. if (f.is_null()) {
  841. CLEANUP_AND_RETURN(err);
  842. }
  843. f->store_string(clean_script);
  844. }
  845. print_line("Uploading scripts...");
  846. ep.step(TTR("Uploading scripts..."), 4);
  847. err = ssh_push_to_remote(host, port, extra_args_scp, basepath + "_start.ps1", temp_dir);
  848. if (err != OK) {
  849. CLEANUP_AND_RETURN(err);
  850. }
  851. err = ssh_push_to_remote(host, port, extra_args_scp, basepath + "_clean.ps1", temp_dir);
  852. if (err != OK) {
  853. CLEANUP_AND_RETURN(err);
  854. }
  855. print_line("Starting project...");
  856. ep.step(TTR("Starting project..."), 5);
  857. err = ssh_run_on_remote_no_wait(host, port, extra_args_ssh, vformat("powershell -file \"%s\\%s\"", temp_dir, basepath.get_file() + "_start.ps1"), &ssh_pid, (use_remote) ? dbg_port : -1);
  858. if (err != OK) {
  859. CLEANUP_AND_RETURN(err);
  860. }
  861. cleanup_commands.clear();
  862. cleanup_commands.push_back(SSHCleanupCommand(host, port, extra_args_ssh, vformat("powershell -file \"%s\\%s\"", temp_dir, basepath.get_file() + "_clean.ps1")));
  863. print_line("Project started.");
  864. CLEANUP_AND_RETURN(OK);
  865. #undef CLEANUP_AND_RETURN
  866. }
  867. EditorExportPlatformWindows::EditorExportPlatformWindows() {
  868. if (EditorNode::get_singleton()) {
  869. #ifdef MODULE_SVG_ENABLED
  870. Ref<Image> img = memnew(Image);
  871. const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE);
  872. ImageLoaderSVG::create_image_from_string(img, _windows_logo_svg, EDSCALE, upsample, false);
  873. set_logo(ImageTexture::create_from_image(img));
  874. ImageLoaderSVG::create_image_from_string(img, _windows_run_icon_svg, EDSCALE, upsample, false);
  875. run_icon = ImageTexture::create_from_image(img);
  876. #endif
  877. Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme();
  878. if (theme.is_valid()) {
  879. stop_icon = theme->get_icon(SNAME("Stop"), SNAME("EditorIcons"));
  880. } else {
  881. stop_icon.instantiate();
  882. }
  883. }
  884. }