| 201 | } |
| 202 | |
| 203 | Error EditorExportPlatformWindows::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, BitField<EditorExportPlatform::DebugFlags> p_flags) { |
| 204 | String custom_debug = p_preset->get("custom_template/debug"); |
| 205 | String custom_release = p_preset->get("custom_template/release"); |
| 206 | String arch = p_preset->get("binary_format/architecture"); |
| 207 | |
| 208 | String template_path = p_debug ? custom_debug : custom_release; |
| 209 | template_path = template_path.strip_edges(); |
| 210 | if (template_path.is_empty()) { |
| 211 | template_path = find_export_template(get_template_file_name(p_debug ? "debug" : "release", arch)); |
| 212 | } else { |
| 213 | String exe_arch = _get_exe_arch(template_path); |
| 214 | if (arch != exe_arch) { |
| 215 | add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Templates"), vformat(TTR("Mismatching custom export template executable architecture: found \"%s\", expected \"%s\"."), exe_arch, arch)); |
| 216 | return ERR_CANT_CREATE; |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | bool export_as_zip = p_path.ends_with("zip"); |
| 221 | bool embedded = p_preset->get("binary_format/embed_pck"); |
| 222 | |
| 223 | String pkg_name; |
| 224 | if (String(get_project_setting(p_preset, "application/config/name")) != "") { |
| 225 | pkg_name = String(get_project_setting(p_preset, "application/config/name")); |
| 226 | } else { |
| 227 | pkg_name = "Unnamed"; |
| 228 | } |
| 229 | |
| 230 | pkg_name = OS::get_singleton()->get_safe_dir_name(pkg_name); |
| 231 | |
| 232 | // Setup temp folder. |
| 233 | String path = p_path; |
| 234 | String tmp_dir_path = EditorPaths::get_singleton()->get_temp_dir().path_join(pkg_name); |
| 235 | Ref<DirAccess> tmp_app_dir = DirAccess::create_for_path(tmp_dir_path); |
| 236 | if (export_as_zip) { |
| 237 | if (tmp_app_dir.is_null()) { |
| 238 | add_message(EXPORT_MESSAGE_ERROR, TTR("Prepare Templates"), vformat(TTR("Could not create and open the directory: \"%s\""), tmp_dir_path)); |
| 239 | return ERR_CANT_CREATE; |
| 240 | } |
| 241 | if (DirAccess::exists(tmp_dir_path)) { |
| 242 | if (tmp_app_dir->change_dir(tmp_dir_path) == OK) { |
| 243 | tmp_app_dir->erase_contents_recursive(); |
| 244 | } |
| 245 | } |
| 246 | tmp_app_dir->make_dir_recursive(tmp_dir_path); |
| 247 | path = tmp_dir_path.path_join(p_path.get_file().get_basename() + ".exe"); |
| 248 | } |
| 249 | |
| 250 | Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); |
| 251 | int export_angle = p_preset->get("application/export_angle"); |
| 252 | bool include_angle_libs = false; |
| 253 | if (export_angle == 0) { |
| 254 | include_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"); |
| 255 | } else if (export_angle == 1) { |
| 256 | include_angle_libs = true; |
| 257 | } |
| 258 | if (include_angle_libs) { |
| 259 | if (da->file_exists(template_path.get_base_dir().path_join("libEGL." + arch + ".dll"))) { |
| 260 | da->copy(template_path.get_base_dir().path_join("libEGL." + arch + ".dll"), path.get_base_dir().path_join("libEGL.dll"), get_chmod_flags()); |
nothing calls this directly
no test coverage detected