Path: blob/master/platform/windows/export/export_plugin.cpp
20844 views
/**************************************************************************/1/* export_plugin.cpp */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#include "export_plugin.h"3132#include "logo_svg.gen.h"33#include "run_icon_svg.gen.h"34#include "template_modifier.h"3536#include "core/config/project_settings.h"37#include "core/io/dir_access.h"38#include "core/io/image_loader.h"39#include "editor/editor_node.h"40#include "editor/editor_string_names.h"41#include "editor/export/editor_export.h"42#include "editor/file_system/editor_paths.h"43#include "editor/themes/editor_scale.h"44#include "scene/resources/image_texture.h"4546#include "modules/svg/image_loader_svg.h"4748#ifdef WINDOWS_ENABLED49#include "shlobj.h"5051// Converts long path to Windows UNC format.52static String fix_path(const String &p_path) {53String path = p_path;54if (p_path.is_relative_path()) {55Char16String current_dir_name;56size_t str_len = GetCurrentDirectoryW(0, nullptr);57current_dir_name.resize_uninitialized(str_len + 1);58GetCurrentDirectoryW(current_dir_name.size(), (LPWSTR)current_dir_name.ptrw());59path = String::utf16((const char16_t *)current_dir_name.get_data()).trim_prefix(R"(\\?\)").replace_char('\\', '/').path_join(path);60}61path = path.simplify_path();62path = path.replace_char('/', '\\');63if (path.size() >= MAX_PATH && !path.is_network_share_path() && !path.begins_with(R"(\\?\)")) {64path = R"(\\?\)" + path;65}66return path;67}6869#endif7071Error EditorExportPlatformWindows::_process_icon(const Ref<EditorExportPreset> &p_preset, const String &p_src_path, const String &p_dst_path) {72static const uint8_t icon_size[] = { 16, 32, 48, 64, 128, 0 /*256*/ };7374struct IconData {75Vector<uint8_t> data;76uint8_t pal_colors = 0;77uint16_t planes = 0;78uint16_t bpp = 32;79};8081HashMap<uint8_t, IconData> images;82Error err;8384if (p_src_path.get_extension() == "ico") {85Ref<FileAccess> f = FileAccess::open(p_src_path, FileAccess::READ, &err);86if (err != OK) {87return err;88}8990// Read ICONDIR.91f->get_16(); // Reserved.92uint16_t icon_type = f->get_16(); // Image type: 1 - ICO.93uint16_t icon_count = f->get_16(); // Number of images.94ERR_FAIL_COND_V(icon_type != 1, ERR_CANT_OPEN);9596for (uint16_t i = 0; i < icon_count; i++) {97// Read ICONDIRENTRY.98uint16_t w = f->get_8(); // Width in pixels.99uint16_t h = f->get_8(); // Height in pixels.100uint8_t pal_colors = f->get_8(); // Number of colors in the palette (0 - no palette).101f->get_8(); // Reserved.102uint16_t planes = f->get_16(); // Number of color planes.103uint16_t bpp = f->get_16(); // Bits per pixel.104uint32_t img_size = f->get_32(); // Image data size in bytes.105uint32_t img_offset = f->get_32(); // Image data offset.106if (w != h) {107continue;108}109110// Read image data.111uint64_t prev_offset = f->get_position();112images[w].pal_colors = pal_colors;113images[w].planes = planes;114images[w].bpp = bpp;115images[w].data.resize(img_size);116f->seek(img_offset);117f->get_buffer(images[w].data.ptrw(), img_size);118f->seek(prev_offset);119}120} else {121Ref<Image> src_image = _load_icon_or_splash_image(p_src_path, &err);122ERR_FAIL_COND_V(err != OK || src_image.is_null() || src_image->is_empty(), ERR_CANT_OPEN);123124for (size_t i = 0; i < std_size(icon_size); ++i) {125int size = (icon_size[i] == 0) ? 256 : icon_size[i];126127Ref<Image> res_image = src_image->duplicate();128ERR_FAIL_COND_V(res_image.is_null() || res_image->is_empty(), ERR_CANT_OPEN);129res_image->resize(size, size, (Image::Interpolation)(p_preset->get("application/icon_interpolation").operator int()));130images[icon_size[i]].data = res_image->save_png_to_buffer();131}132}133134uint16_t valid_icon_count = 0;135for (size_t i = 0; i < std_size(icon_size); ++i) {136if (images.has(icon_size[i])) {137valid_icon_count++;138} else {139int size = (icon_size[i] == 0) ? 256 : icon_size[i];140add_message(EXPORT_MESSAGE_WARNING, TTR("Resources Modification"), vformat(TTR("Icon size \"%d\" is missing."), size));141}142}143ERR_FAIL_COND_V(valid_icon_count == 0, ERR_CANT_OPEN);144145Ref<FileAccess> fw = FileAccess::open(p_dst_path, FileAccess::WRITE, &err);146if (err != OK) {147return err;148}149150// Write ICONDIR.151fw->store_16(0); // Reserved.152fw->store_16(1); // Image type: 1 - ICO.153fw->store_16(valid_icon_count); // Number of images.154155// Write ICONDIRENTRY.156uint32_t img_offset = 6 + 16 * valid_icon_count;157for (size_t i = 0; i < std_size(icon_size); ++i) {158if (images.has(icon_size[i])) {159const IconData &di = images[icon_size[i]];160fw->store_8(icon_size[i]); // Width in pixels.161fw->store_8(icon_size[i]); // Height in pixels.162fw->store_8(di.pal_colors); // Number of colors in the palette (0 - no palette).163fw->store_8(0); // Reserved.164fw->store_16(di.planes); // Number of color planes.165fw->store_16(di.bpp); // Bits per pixel.166fw->store_32(di.data.size()); // Image data size in bytes.167fw->store_32(img_offset); // Image data offset.168169img_offset += di.data.size();170}171}172173// Write image data.174for (size_t i = 0; i < std_size(icon_size); ++i) {175if (images.has(icon_size[i])) {176const IconData &di = images[icon_size[i]];177fw->store_buffer(di.data.ptr(), di.data.size());178}179}180return OK;181}182183Error EditorExportPlatformWindows::sign_shared_object(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path) {184if (p_preset->get("codesign/enable")) {185return _code_sign(p_preset, p_path);186} else {187return OK;188}189}190191Error EditorExportPlatformWindows::modify_template(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, BitField<EditorExportPlatform::DebugFlags> p_flags) {192if (p_preset->get("application/modify_resources")) {193_add_data(p_preset, p_path, false);194String wrapper_path = p_path.get_basename() + ".console.exe";195if (FileAccess::exists(wrapper_path)) {196_add_data(p_preset, wrapper_path, true);197}198}199return OK;200}201202Error EditorExportPlatformWindows::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, BitField<EditorExportPlatform::DebugFlags> p_flags) {203String custom_debug = p_preset->get("custom_template/debug");204String custom_release = p_preset->get("custom_template/release");205String arch = p_preset->get("binary_format/architecture");206207String template_path = p_debug ? custom_debug : custom_release;208template_path = template_path.strip_edges();209if (template_path.is_empty()) {210template_path = find_export_template(get_template_file_name(p_debug ? "debug" : "release", arch));211} else {212String exe_arch = _get_exe_arch(template_path);213if (arch != exe_arch) {214add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Templates"), vformat(TTR("Mismatching custom export template executable architecture: found \"%s\", expected \"%s\"."), exe_arch, arch));215return ERR_CANT_CREATE;216}217}218219bool export_as_zip = p_path.ends_with("zip");220bool embedded = p_preset->get("binary_format/embed_pck");221222String pkg_name;223if (String(get_project_setting(p_preset, "application/config/name")) != "") {224pkg_name = String(get_project_setting(p_preset, "application/config/name"));225} else {226pkg_name = "Unnamed";227}228229pkg_name = OS::get_singleton()->get_safe_dir_name(pkg_name);230231// Setup temp folder.232String path = p_path;233String tmp_dir_path = EditorPaths::get_singleton()->get_temp_dir().path_join(pkg_name);234Ref<DirAccess> tmp_app_dir = DirAccess::create_for_path(tmp_dir_path);235if (export_as_zip) {236if (tmp_app_dir.is_null()) {237add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Templates"), vformat(TTR("Could not create and open the directory: \"%s\""), tmp_dir_path));238return ERR_CANT_CREATE;239}240if (DirAccess::exists(tmp_dir_path)) {241if (tmp_app_dir->change_dir(tmp_dir_path) == OK) {242tmp_app_dir->erase_contents_recursive();243}244}245tmp_app_dir->make_dir_recursive(tmp_dir_path);246path = tmp_dir_path.path_join(p_path.get_file().get_basename() + ".exe");247}248249Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);250int export_angle = p_preset->get("application/export_angle");251bool include_angle_libs = false;252if (export_angle == 0) {253include_angle_libs = (String(get_project_setting(p_preset, "rendering/gl_compatibility/driver.windows")) == "opengl3_angle") && (String(get_project_setting(p_preset, "rendering/renderer/rendering_method")) == "gl_compatibility");254} else if (export_angle == 1) {255include_angle_libs = true;256}257if (include_angle_libs) {258if (da->file_exists(template_path.get_base_dir().path_join("libEGL." + arch + ".dll"))) {259da->copy(template_path.get_base_dir().path_join("libEGL." + arch + ".dll"), path.get_base_dir().path_join("libEGL.dll"), get_chmod_flags());260}261if (da->file_exists(template_path.get_base_dir().path_join("libGLESv2." + arch + ".dll"))) {262da->copy(template_path.get_base_dir().path_join("libGLESv2." + arch + ".dll"), path.get_base_dir().path_join("libGLESv2.dll"), get_chmod_flags());263}264}265if (da->file_exists(template_path.get_base_dir().path_join("accesskit." + arch + ".dll"))) {266da->copy(template_path.get_base_dir().path_join("accesskit." + arch + ".dll"), path.get_base_dir().path_join("accesskit." + arch + ".dll"), get_chmod_flags());267}268269int export_d3d12 = p_preset->get("application/export_d3d12");270bool agility_sdk_multiarch = p_preset->get("application/d3d12_agility_sdk_multiarch");271bool include_d3d12_extra_libs = false;272if (export_d3d12 == 0) {273include_d3d12_extra_libs = (String(get_project_setting(p_preset, "rendering/rendering_device/driver.windows")) == "d3d12") && (String(get_project_setting(p_preset, "rendering/renderer/rendering_method")) != "gl_compatibility");274} else if (export_d3d12 == 1) {275include_d3d12_extra_libs = true;276}277if (include_d3d12_extra_libs) {278if (da->file_exists(template_path.get_base_dir().path_join("D3D12Core." + arch + ".dll"))) {279if (agility_sdk_multiarch) {280da->make_dir_recursive(path.get_base_dir().path_join(arch));281da->copy(template_path.get_base_dir().path_join("D3D12Core." + arch + ".dll"), path.get_base_dir().path_join(arch).path_join("D3D12Core.dll"), get_chmod_flags());282} else {283da->copy(template_path.get_base_dir().path_join("D3D12Core." + arch + ".dll"), path.get_base_dir().path_join("D3D12Core.dll"), get_chmod_flags());284}285}286if (da->file_exists(template_path.get_base_dir().path_join("d3d12SDKLayers." + arch + ".dll"))) {287if (agility_sdk_multiarch) {288da->make_dir_recursive(path.get_base_dir().path_join(arch));289da->copy(template_path.get_base_dir().path_join("d3d12SDKLayers." + arch + ".dll"), path.get_base_dir().path_join(arch).path_join("d3d12SDKLayers.dll"), get_chmod_flags());290} else {291da->copy(template_path.get_base_dir().path_join("d3d12SDKLayers." + arch + ".dll"), path.get_base_dir().path_join("d3d12SDKLayers.dll"), get_chmod_flags());292}293}294if (da->file_exists(template_path.get_base_dir().path_join("WinPixEventRuntime." + arch + ".dll"))) {295da->copy(template_path.get_base_dir().path_join("WinPixEventRuntime." + arch + ".dll"), path.get_base_dir().path_join("WinPixEventRuntime.dll"), get_chmod_flags());296}297}298299// Export project.300String pck_path = path;301if (embedded) {302pck_path = pck_path.get_basename() + ".tmp";303}304305Error err = EditorExportPlatformPC::export_project(p_preset, p_debug, pck_path, p_flags);306if (err != OK) {307// Message is supplied by the subroutine method.308return err;309}310311if (p_preset->get("codesign/enable")) {312_code_sign(p_preset, pck_path);313String wrapper_path = path.get_basename() + ".console.exe";314if (FileAccess::exists(wrapper_path)) {315_code_sign(p_preset, wrapper_path);316}317}318319if (embedded) {320Ref<DirAccess> tmp_dir = DirAccess::create_for_path(path.get_base_dir());321err = tmp_dir->rename(pck_path, path);322if (err != OK) {323add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), vformat(TTR("Failed to rename temporary file \"%s\"."), pck_path));324}325}326327// ZIP project.328if (export_as_zip) {329if (FileAccess::exists(p_path)) {330OS::get_singleton()->move_to_trash(p_path);331}332333Ref<FileAccess> io_fa_dst;334zlib_filefunc_def io_dst = zipio_create_io(&io_fa_dst);335zipFile zip = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io_dst);336337zip_folder_recursive(zip, tmp_dir_path, "", pkg_name);338339zipClose(zip, nullptr);340341if (tmp_app_dir->change_dir(tmp_dir_path) == OK) {342tmp_app_dir->erase_contents_recursive();343tmp_app_dir->change_dir("..");344tmp_app_dir->remove(pkg_name);345}346#ifdef WINDOWS_ENABLED347} else {348// Update Windows icon cache.349String w_path = fix_path(path);350SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH, (LPCWSTR)w_path.utf16().get_data(), nullptr);351352String wrapper_path = path.get_basename() + ".console.exe";353if (FileAccess::exists(wrapper_path)) {354String w_wrapper_path = fix_path(wrapper_path);355SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH, (LPCWSTR)w_wrapper_path.utf16().get_data(), nullptr);356}357358w_path = fix_path(path.get_base_dir());359SHChangeNotify(SHCNE_UPDATEITEM, SHCNF_PATH, (LPCWSTR)w_path.utf16().get_data(), nullptr);360361SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nullptr, nullptr);362#endif363}364365return err;366}367368String EditorExportPlatformWindows::get_template_file_name(const String &p_target, const String &p_arch) const {369return "windows_" + p_target + "_" + p_arch + ".exe";370}371372List<String> EditorExportPlatformWindows::get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const {373List<String> list;374list.push_back("exe");375list.push_back("zip");376return list;377}378379String EditorExportPlatformWindows::get_export_option_warning(const EditorExportPreset *p_preset, const StringName &p_name) const {380if (p_preset) {381if (p_name == "application/icon") {382String icon_path = ProjectSettings::get_singleton()->globalize_path(p_preset->get("application/icon"));383if (!icon_path.is_empty() && !FileAccess::exists(icon_path)) {384return TTR("Invalid icon path.");385}386} else if (p_name == "application/file_version") {387String file_version = p_preset->get("application/file_version");388if (!file_version.is_empty()) {389PackedStringArray version_array = file_version.split(".", false);390if (version_array.size() != 4 || !version_array[0].is_valid_int() ||391!version_array[1].is_valid_int() || !version_array[2].is_valid_int() ||392!version_array[3].is_valid_int() || file_version.contains_char('-')) {393return TTR("Invalid file version.");394}395}396} else if (p_name == "application/product_version") {397String product_version = p_preset->get("application/product_version");398if (!product_version.is_empty()) {399PackedStringArray version_array = product_version.split(".", false);400if (version_array.size() != 4 || !version_array[0].is_valid_int() ||401!version_array[1].is_valid_int() || !version_array[2].is_valid_int() ||402!version_array[3].is_valid_int() || product_version.contains_char('-')) {403return TTR("Invalid product version.");404}405}406}407}408return EditorExportPlatformPC::get_export_option_warning(p_preset, p_name);409}410411bool EditorExportPlatformWindows::get_export_option_visibility(const EditorExportPreset *p_preset, const String &p_option) const {412if (p_preset == nullptr) {413return true;414}415416// This option is not supported by "osslsigncode", used on non-Windows host.417if (!OS::get_singleton()->has_feature("windows") && p_option == "codesign/identity_type") {418return false;419}420421bool advanced_options_enabled = p_preset->are_advanced_options_enabled();422423// Hide codesign.424bool codesign = p_preset->get("codesign/enable");425if (!codesign && p_option != "codesign/enable" && p_option.begins_with("codesign/")) {426return false;427}428429// Hide resources.430bool mod_res = p_preset->get("application/modify_resources");431if (!mod_res && p_option != "application/modify_resources" && p_option != "application/export_angle" && p_option != "application/export_d3d12" && p_option != "application/d3d12_agility_sdk_multiarch" && p_option.begins_with("application/")) {432return false;433}434435// Hide SSH options.436bool ssh = p_preset->get("ssh_remote_deploy/enabled");437if (!ssh && p_option != "ssh_remote_deploy/enabled" && p_option.begins_with("ssh_remote_deploy/")) {438return false;439}440441if (p_option == "dotnet/embed_build_outputs" ||442p_option == "custom_template/debug" ||443p_option == "custom_template/release" ||444p_option == "application/d3d12_agility_sdk_multiarch" ||445p_option == "application/export_angle" ||446p_option == "application/export_d3d12" ||447p_option == "application/icon_interpolation") {448return advanced_options_enabled;449}450return true;451}452453void EditorExportPlatformWindows::get_export_options(List<ExportOption> *r_options) const {454EditorExportPlatformPC::get_export_options(r_options);455456r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "binary_format/architecture", PROPERTY_HINT_ENUM, "x86_64,x86_32,arm64"), "x86_64"));457458r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/enable"), false, true));459r_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));460r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/identity", PROPERTY_HINT_GLOBAL_FILE, "*.pfx,*.p12", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_SECRET), ""));461r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/password", PROPERTY_HINT_PASSWORD, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_SECRET), ""));462r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "codesign/timestamp"), true));463r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/timestamp_server_url"), ""));464r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "codesign/digest_algorithm", PROPERTY_HINT_ENUM, "SHA1,SHA256"), 1));465r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "codesign/description"), ""));466r_options->push_back(ExportOption(PropertyInfo(Variant::PACKED_STRING_ARRAY, "codesign/custom_options"), PackedStringArray()));467468r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "application/modify_resources"), true, true));469r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/icon", PROPERTY_HINT_FILE, "*.ico,*.png,*.webp,*.svg"), "", false, true));470r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/console_wrapper_icon", PROPERTY_HINT_FILE, "*.ico,*.png,*.webp,*.svg"), ""));471r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "application/icon_interpolation", PROPERTY_HINT_ENUM, "Nearest neighbor,Bilinear,Cubic,Trilinear,Lanczos"), 4));472r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/file_version", PROPERTY_HINT_PLACEHOLDER_TEXT, "Leave empty to use project version"), ""));473r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/product_version", PROPERTY_HINT_PLACEHOLDER_TEXT, "Leave empty to use project version"), ""));474r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/company_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Company Name"), ""));475r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/product_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game Name"), ""));476r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/file_description"), ""));477r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/copyright"), ""));478r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/trademarks"), ""));479r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "application/export_angle", PROPERTY_HINT_ENUM, "Auto,Yes,No"), 0, true));480r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "application/export_d3d12", PROPERTY_HINT_ENUM, "Auto,Yes,No"), 0, true));481r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "application/d3d12_agility_sdk_multiarch"), true, true));482483String run_script = "Expand-Archive -LiteralPath '{temp_dir}\\{archive_name}' -DestinationPath '{temp_dir}'\n"484"$action = New-ScheduledTaskAction -Execute '{temp_dir}\\{exe_name}' -Argument '{cmd_args}'\n"485"$trigger = New-ScheduledTaskTrigger -Once -At 00:00\n"486"$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries\n"487"$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings\n"488"Register-ScheduledTask godot_remote_debug -InputObject $task -Force:$true\n"489"Start-ScheduledTask -TaskName godot_remote_debug\n"490"while (Get-ScheduledTask -TaskName godot_remote_debug | ? State -eq running) { Start-Sleep -Milliseconds 100 }\n"491"Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue";492493String cleanup_script = "Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue\n"494"Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue\n"495"Remove-Item -Recurse -Force '{temp_dir}'";496497r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "ssh_remote_deploy/enabled"), false, true));498r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/host"), "user@host_ip"));499r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/port"), "22"));500501r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/extra_args_ssh", PROPERTY_HINT_MULTILINE_TEXT, "monospace,no_wrap"), ""));502r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/extra_args_scp", PROPERTY_HINT_MULTILINE_TEXT, "monospace,no_wrap"), ""));503r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/run_script", PROPERTY_HINT_MULTILINE_TEXT, "monospace,no_wrap"), run_script));504r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "ssh_remote_deploy/cleanup_script", PROPERTY_HINT_MULTILINE_TEXT, "monospace,no_wrap"), cleanup_script));505}506507Error EditorExportPlatformWindows::_add_data(const Ref<EditorExportPreset> &p_preset, const String &p_path, bool p_console_icon) {508String icon_path;509if (p_preset->get("application/icon") != "") {510icon_path = p_preset->get("application/icon");511} else if (get_project_setting(p_preset, "application/config/windows_native_icon") != "") {512icon_path = get_project_setting(p_preset, "application/config/windows_native_icon");513} else {514icon_path = get_project_setting(p_preset, "application/config/icon");515}516icon_path = ProjectSettings::get_singleton()->globalize_path(icon_path);517518if (p_console_icon) {519String console_icon_path = ProjectSettings::get_singleton()->globalize_path(p_preset->get("application/console_wrapper_icon"));520if (!console_icon_path.is_empty() && FileAccess::exists(console_icon_path)) {521icon_path = console_icon_path;522}523}524525String tmp_icon_path = EditorPaths::get_singleton()->get_temp_dir().path_join("_tmp.ico");526if (!icon_path.is_empty()) {527if (_process_icon(p_preset, icon_path, tmp_icon_path) != OK) {528add_message(EXPORT_MESSAGE_WARNING, TTR("Resources Modification"), vformat(TTR("Invalid icon file \"%s\"."), icon_path));529icon_path = String();530}531}532533TemplateModifier::modify(p_preset, p_path, tmp_icon_path);534535if (FileAccess::exists(tmp_icon_path)) {536DirAccess::remove_file_or_error(tmp_icon_path);537}538539return OK;540}541542Error EditorExportPlatformWindows::_code_sign(const Ref<EditorExportPreset> &p_preset, const String &p_path) {543List<String> args;544545#ifdef WINDOWS_ENABLED546String signtool_path = EDITOR_GET("export/windows/signtool");547if (!signtool_path.is_empty() && !FileAccess::exists(signtool_path)) {548add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), vformat(TTR("Could not find signtool executable at \"%s\"."), signtool_path));549return ERR_FILE_NOT_FOUND;550}551if (signtool_path.is_empty()) {552signtool_path = "signtool"; // try to run signtool from PATH553}554#else555String signtool_path = EDITOR_GET("export/windows/osslsigncode");556if (!signtool_path.is_empty() && !FileAccess::exists(signtool_path)) {557add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), vformat(TTR("Could not find osslsigncode executable at \"%s\"."), signtool_path));558return ERR_FILE_NOT_FOUND;559}560if (signtool_path.is_empty()) {561signtool_path = "osslsigncode"; // try to run signtool from PATH562}563#endif564565args.push_back("sign");566567//identity568#ifdef WINDOWS_ENABLED569int id_type = p_preset->get_or_env("codesign/identity_type", ENV_WIN_CODESIGN_ID_TYPE);570if (id_type == 0) { //auto select571args.push_back("/a");572} else if (id_type == 1) { //pkcs12573if (p_preset->get_or_env("codesign/identity", ENV_WIN_CODESIGN_ID) != "") {574args.push_back("/f");575args.push_back(p_preset->get_or_env("codesign/identity", ENV_WIN_CODESIGN_ID));576} else {577add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("No identity found."));578return FAILED;579}580} else if (id_type == 2) { //Windows certificate store581if (p_preset->get_or_env("codesign/identity", ENV_WIN_CODESIGN_ID) != "") {582args.push_back("/sha1");583args.push_back(p_preset->get_or_env("codesign/identity", ENV_WIN_CODESIGN_ID));584} else {585add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("No identity found."));586return FAILED;587}588} else {589add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("Invalid identity type."));590return FAILED;591}592#else593int id_type = 1;594if (p_preset->get_or_env("codesign/identity", ENV_WIN_CODESIGN_ID) != "") {595args.push_back("-pkcs12");596args.push_back(p_preset->get_or_env("codesign/identity", ENV_WIN_CODESIGN_ID));597} else {598add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("No identity found."));599return FAILED;600}601#endif602603//password604if ((id_type == 1) && (p_preset->get_or_env("codesign/password", ENV_WIN_CODESIGN_PASS) != "")) {605#ifdef WINDOWS_ENABLED606args.push_back("/p");607#else608args.push_back("-pass");609#endif610args.push_back(p_preset->get_or_env("codesign/password", ENV_WIN_CODESIGN_PASS));611}612613//timestamp614if (p_preset->get("codesign/timestamp")) {615if (p_preset->get("codesign/timestamp_server") != "") {616#ifdef WINDOWS_ENABLED617args.push_back("/tr");618args.push_back(p_preset->get("codesign/timestamp_server_url"));619args.push_back("/td");620if ((int)p_preset->get("codesign/digest_algorithm") == 0) {621args.push_back("sha1");622} else {623args.push_back("sha256");624}625#else626args.push_back("-ts");627args.push_back(p_preset->get("codesign/timestamp_server_url"));628#endif629} else {630add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("Invalid timestamp server."));631return FAILED;632}633}634635//digest636#ifdef WINDOWS_ENABLED637args.push_back("/fd");638#else639args.push_back("-h");640#endif641if ((int)p_preset->get("codesign/digest_algorithm") == 0) {642args.push_back("sha1");643} else {644args.push_back("sha256");645}646647//description648if (p_preset->get("codesign/description") != "") {649#ifdef WINDOWS_ENABLED650args.push_back("/d");651#else652args.push_back("-n");653#endif654args.push_back(p_preset->get("codesign/description"));655}656657//user options658PackedStringArray user_args = p_preset->get("codesign/custom_options");659for (int i = 0; i < user_args.size(); i++) {660String user_arg = user_args[i].strip_edges();661if (!user_arg.is_empty()) {662args.push_back(user_arg);663}664}665666#ifndef WINDOWS_ENABLED667args.push_back("-in");668#endif669args.push_back(p_path);670#ifndef WINDOWS_ENABLED671args.push_back("-out");672args.push_back(p_path + "_signed");673#endif674675String str;676Error err = OS::get_singleton()->execute(signtool_path, args, &str, nullptr, true);677if (err != OK || str.contains("not found") || str.contains("not recognized")) {678#ifdef WINDOWS_ENABLED679add_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."));680#else681add_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."));682#endif683return err;684}685686print_line("codesign (" + p_path + "): " + str);687#ifndef WINDOWS_ENABLED688if (str.contains("SignTool Error")) {689#else690if (str.contains("Failed")) {691#endif692add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), vformat(TTR("Signtool failed to sign executable: %s."), str));693return FAILED;694}695696#ifndef WINDOWS_ENABLED697Ref<DirAccess> tmp_dir = DirAccess::create_for_path(p_path.get_base_dir());698699err = tmp_dir->remove(p_path);700if (err != OK) {701add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), vformat(TTR("Failed to remove temporary file \"%s\"."), p_path));702return err;703}704705err = tmp_dir->rename(p_path + "_signed", p_path);706if (err != OK) {707add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), vformat(TTR("Failed to rename temporary file \"%s\"."), p_path + "_signed"));708return err;709}710#endif711712return OK;713}714715bool EditorExportPlatformWindows::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug) const {716String err;717bool valid = EditorExportPlatformPC::has_valid_export_configuration(p_preset, err, r_missing_templates, p_debug);718719String custom_debug = p_preset->get("custom_template/debug").operator String().strip_edges();720String custom_release = p_preset->get("custom_template/release").operator String().strip_edges();721String arch = p_preset->get("binary_format/architecture");722723if (!custom_debug.is_empty() && FileAccess::exists(custom_debug)) {724String exe_arch = _get_exe_arch(custom_debug);725if (arch != exe_arch) {726err += vformat(TTR("Mismatching custom debug export template executable architecture: found \"%s\", expected \"%s\"."), exe_arch, arch) + "\n";727}728}729if (!custom_release.is_empty() && FileAccess::exists(custom_release)) {730String exe_arch = _get_exe_arch(custom_release);731if (arch != exe_arch) {732err += vformat(TTR("Mismatching custom release export template executable architecture: found \"%s\", expected \"%s\"."), exe_arch, arch) + "\n";733}734}735736if (!err.is_empty()) {737r_error = err;738}739740return valid;741}742743bool EditorExportPlatformWindows::has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const {744String err;745bool valid = true;746747List<ExportOption> options;748get_export_options(&options);749for (const EditorExportPlatform::ExportOption &E : options) {750if (get_export_option_visibility(p_preset.ptr(), E.option.name)) {751String warn = get_export_option_warning(p_preset.ptr(), E.option.name);752if (!warn.is_empty()) {753err += warn + "\n";754if (E.required) {755valid = false;756}757}758}759}760761if (!err.is_empty()) {762r_error = err;763}764765return valid;766}767768String EditorExportPlatformWindows::_get_exe_arch(const String &p_path) const {769Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::READ);770if (f.is_null()) {771return "invalid";772}773774// Jump to the PE header and check the magic number.775{776f->seek(0x3c);777uint32_t pe_pos = f->get_32();778779f->seek(pe_pos);780uint32_t magic = f->get_32();781if (magic != 0x00004550) {782return "invalid";783}784}785786// Process header.787uint16_t machine = f->get_16();788f->close();789790switch (machine) {791case 0x014c:792return "x86_32";793case 0x8664:794return "x86_64";795case 0x01c0:796case 0x01c4:797return "arm32";798case 0xaa64:799return "arm64";800default:801return "unknown";802}803}804805Error EditorExportPlatformWindows::fixup_embedded_pck(const String &p_path, int64_t p_embedded_start, int64_t p_embedded_size) {806// Patch the header of the "pck" section in the PE file so that it corresponds to the embedded data.807808if (p_embedded_size + p_embedded_start >= 0x100000000) { // Check for total executable size.809add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), TTR("Windows executables cannot be >= 4 GiB."));810return ERR_INVALID_DATA;811}812813Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::READ_WRITE);814if (f.is_null()) {815add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), vformat(TTR("Failed to open executable file \"%s\"."), p_path));816return ERR_CANT_OPEN;817}818819// Jump to the PE header and check the magic number.820{821f->seek(0x3c);822uint32_t pe_pos = f->get_32();823824f->seek(pe_pos);825uint32_t magic = f->get_32();826if (magic != 0x00004550) {827add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), TTR("Executable file header corrupted."));828return ERR_FILE_CORRUPT;829}830}831832// Process header.833uint32_t sect_alignment = 0x1000;834uint32_t image_size = 0;835int num_sections;836837int64_t header_pos = f->get_position();838int64_t opt_header_pos = 0;839{840f->seek(header_pos + 2);841num_sections = f->get_16();842f->seek(header_pos + 16);843uint16_t opt_header_size = f->get_16();844opt_header_pos = f->get_position() + 2;845846f->seek(opt_header_pos + 32);847sect_alignment = f->get_32();848849f->seek(opt_header_pos + 56);850image_size = f->get_32();851852// Skip rest of header + optional header to go to the section headers.853f->seek(opt_header_pos + opt_header_size);854}855856// Search for the "pck" section.857858int64_t section_table_pos = f->get_position();859860int pck_old_pos = -1;861for (int i = 0; i < num_sections; i++) {862int64_t section_header_pos = section_table_pos + i * 40;863f->seek(section_header_pos);864865uint8_t section_name[9];866f->get_buffer(section_name, 8);867section_name[8] = '\0';868869if (strcmp((char *)section_name, "pck") == 0) {870pck_old_pos = i;871872// Update virtual size of previous section to avoid gaps in the virtual addresses.873f->seek(section_table_pos + (i - 1) * 40 + 8);874uint32_t virt_size = f->get_32();875f->seek(section_table_pos + (i - 1) * 40 + 8);876f->store_32(virt_size + sect_alignment);877break;878}879}880if (pck_old_pos >= 0) {881// Move section data.882uint8_t section_data[40];883for (int i = pck_old_pos; i < num_sections - 1; i++) {884f->seek(section_table_pos + (i + 1) * 40);885f->get_buffer(section_data, 40);886f->seek(section_table_pos + i * 40);887f->store_buffer(section_data, 40);888}889890// Add "pck" at the end.891f->seek(section_table_pos + (num_sections - 1) * 40);892uint8_t section_name[8] = { 'p', 'c', 'k', '\0', '\0', '\0', '\0', '\0' };893f->store_buffer(section_name, 8); // Name.894f->store_32(8); // VirtualSize, set to a little to avoid it taking memory (zero would give issues).895f->store_32(image_size); // VirtualAddress.896f->store_32(p_embedded_size); // SizeOfRawData.897f->store_32(p_embedded_start); // PointerToRawData.898f->store_32(0); // PointerToRelocations, not used.899f->store_32(0); // PointerToLinenumbers, not used.900f->store_16(0); // NumberOfRelocations.901f->store_16(0); // NumberOfLinenumbers.902f->store_32(0x40000000); // Characteristics: Read.903904// Update image virtual size.905f->seek(opt_header_pos + 56);906f->store_32(image_size + sect_alignment);907}908909f->close();910911if (pck_old_pos == -1) {912add_message(EXPORT_MESSAGE_ERROR, TTR("PCK Embedding"), TTR("Executable \"pck\" section not found."));913return ERR_FILE_CORRUPT;914}915return OK;916}917918Ref<Texture2D> EditorExportPlatformWindows::get_run_icon() const {919return run_icon;920}921922bool EditorExportPlatformWindows::poll_export() {923Ref<EditorExportPreset> preset = EditorExport::get_singleton()->get_runnable_preset_for_platform(this);924925int prev = menu_options;926menu_options = (preset.is_valid() && preset->get("ssh_remote_deploy/enabled").operator bool());927if (ssh_pid != 0 || !cleanup_commands.is_empty()) {928if (menu_options == 0) {929cleanup();930} else {931menu_options += 1;932}933}934return menu_options != prev;935}936937Ref<Texture2D> EditorExportPlatformWindows::get_option_icon(int p_index) const {938if (p_index == 1) {939return stop_icon;940} else {941return EditorExportPlatform::get_option_icon(p_index);942}943}944945int EditorExportPlatformWindows::get_options_count() const {946return menu_options;947}948949String EditorExportPlatformWindows::get_option_label(int p_index) const {950return (p_index) ? TTR("Stop and uninstall") : TTR("Run on remote Windows system");951}952953String EditorExportPlatformWindows::get_option_tooltip(int p_index) const {954return (p_index) ? TTR("Stop and uninstall running project from the remote system") : TTR("Run exported project on remote Windows system");955}956957void EditorExportPlatformWindows::cleanup() {958if (ssh_pid != 0 && OS::get_singleton()->is_process_running(ssh_pid)) {959print_line("Terminating connection...");960OS::get_singleton()->kill(ssh_pid);961OS::get_singleton()->delay_usec(1000);962}963964if (!cleanup_commands.is_empty()) {965print_line("Stopping and deleting previous version...");966for (const SSHCleanupCommand &cmd : cleanup_commands) {967if (cmd.wait) {968ssh_run_on_remote(cmd.host, cmd.port, cmd.ssh_args, cmd.cmd_args);969} else {970ssh_run_on_remote_no_wait(cmd.host, cmd.port, cmd.ssh_args, cmd.cmd_args);971}972}973}974ssh_pid = 0;975cleanup_commands.clear();976}977978Error EditorExportPlatformWindows::run(const Ref<EditorExportPreset> &p_preset, int p_device, BitField<EditorExportPlatform::DebugFlags> p_debug_flags) {979cleanup();980if (p_device) { // Stop command, cleanup only.981return OK;982}983984EditorProgress ep("run", TTR("Running..."), 5);985986const String dest = EditorPaths::get_singleton()->get_temp_dir().path_join("windows");987Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);988if (!da->dir_exists(dest)) {989Error err = da->make_dir_recursive(dest);990if (err != OK) {991EditorNode::get_singleton()->show_warning(TTR("Could not create temp directory:") + "\n" + dest);992return err;993}994}995996String host = p_preset->get("ssh_remote_deploy/host").operator String();997String port = p_preset->get("ssh_remote_deploy/port").operator String();998if (port.is_empty()) {999port = "22";1000}1001Vector<String> extra_args_ssh = p_preset->get("ssh_remote_deploy/extra_args_ssh").operator String().split(" ", false);1002Vector<String> extra_args_scp = p_preset->get("ssh_remote_deploy/extra_args_scp").operator String().split(" ", false);10031004const String basepath = dest.path_join("tmp_windows_export");10051006#define CLEANUP_AND_RETURN(m_err) \1007{ \1008if (da->file_exists(basepath + ".zip")) { \1009da->remove(basepath + ".zip"); \1010} \1011if (da->file_exists(basepath + "_start.ps1")) { \1012da->remove(basepath + "_start.ps1"); \1013} \1014if (da->file_exists(basepath + "_clean.ps1")) { \1015da->remove(basepath + "_clean.ps1"); \1016} \1017return m_err; \1018} \1019((void)0)10201021if (ep.step(TTR("Exporting project..."), 1)) {1022return ERR_SKIP;1023}1024Error err = export_project(p_preset, true, basepath + ".zip", p_debug_flags);1025if (err != OK) {1026DirAccess::remove_file_or_error(basepath + ".zip");1027return err;1028}10291030String cmd_args;1031{1032Vector<String> cmd_args_list = gen_export_flags(p_debug_flags);1033for (int i = 0; i < cmd_args_list.size(); i++) {1034if (i != 0) {1035cmd_args += " ";1036}1037cmd_args += cmd_args_list[i];1038}1039}10401041const bool use_remote = p_debug_flags.has_flag(DEBUG_FLAG_REMOTE_DEBUG) || p_debug_flags.has_flag(DEBUG_FLAG_DUMB_CLIENT);1042int dbg_port = EDITOR_GET("network/debug/remote_port");10431044print_line("Creating temporary directory...");1045ep.step(TTR("Creating temporary directory..."), 2);1046String temp_dir;1047#ifndef WINDOWS_ENABLED1048err = 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);1049#else1050err = 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);1051#endif1052if (err != OK || temp_dir.is_empty()) {1053CLEANUP_AND_RETURN(err);1054}10551056print_line("Uploading archive...");1057ep.step(TTR("Uploading archive..."), 3);1058err = ssh_push_to_remote(host, port, extra_args_scp, basepath + ".zip", temp_dir);1059if (err != OK) {1060CLEANUP_AND_RETURN(err);1061}10621063if (cmd_args.is_empty()) {1064cmd_args = " ";1065}10661067{1068String run_script = p_preset->get("ssh_remote_deploy/run_script");1069run_script = run_script.replace("{temp_dir}", temp_dir);1070run_script = run_script.replace("{archive_name}", basepath.get_file() + ".zip");1071run_script = run_script.replace("{exe_name}", basepath.get_file() + ".exe");1072run_script = run_script.replace("{cmd_args}", cmd_args);10731074Ref<FileAccess> f = FileAccess::open(basepath + "_start.ps1", FileAccess::WRITE);1075if (f.is_null()) {1076CLEANUP_AND_RETURN(err);1077}10781079f->store_string(run_script);1080}10811082{1083String clean_script = p_preset->get("ssh_remote_deploy/cleanup_script");1084clean_script = clean_script.replace("{temp_dir}", temp_dir);1085clean_script = clean_script.replace("{archive_name}", basepath.get_file() + ".zip");1086clean_script = clean_script.replace("{exe_name}", basepath.get_file() + ".exe");1087clean_script = clean_script.replace("{cmd_args}", cmd_args);10881089Ref<FileAccess> f = FileAccess::open(basepath + "_clean.ps1", FileAccess::WRITE);1090if (f.is_null()) {1091CLEANUP_AND_RETURN(err);1092}10931094f->store_string(clean_script);1095}10961097print_line("Uploading scripts...");1098ep.step(TTR("Uploading scripts..."), 4);1099err = ssh_push_to_remote(host, port, extra_args_scp, basepath + "_start.ps1", temp_dir);1100if (err != OK) {1101CLEANUP_AND_RETURN(err);1102}1103err = ssh_push_to_remote(host, port, extra_args_scp, basepath + "_clean.ps1", temp_dir);1104if (err != OK) {1105CLEANUP_AND_RETURN(err);1106}11071108print_line("Starting project...");1109ep.step(TTR("Starting project..."), 5);1110err = 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);1111if (err != OK) {1112CLEANUP_AND_RETURN(err);1113}11141115cleanup_commands.clear();1116cleanup_commands.push_back(SSHCleanupCommand(host, port, extra_args_ssh, vformat("powershell -file \"%s\\%s\"", temp_dir, basepath.get_file() + "_clean.ps1")));11171118print_line("Project started.");11191120CLEANUP_AND_RETURN(OK);1121#undef CLEANUP_AND_RETURN1122}11231124void EditorExportPlatformWindows::initialize() {1125if (EditorNode::get_singleton()) {1126Ref<Image> img = memnew(Image);1127const bool upsample = !Math::is_equal_approx(Math::round(EDSCALE), EDSCALE);11281129ImageLoaderSVG::create_image_from_string(img, _windows_logo_svg, EDSCALE, upsample, false);1130set_logo(ImageTexture::create_from_image(img));11311132ImageLoaderSVG::create_image_from_string(img, _windows_run_icon_svg, EDSCALE, upsample, false);1133run_icon = ImageTexture::create_from_image(img);11341135Ref<Theme> theme = EditorNode::get_singleton()->get_editor_theme();1136if (theme.is_valid()) {1137stop_icon = theme->get_icon(SNAME("Stop"), EditorStringName(EditorIcons));1138} else {1139stop_icon.instantiate();1140}1141}1142}114311441145