/
Manifest
/
Real_Texture
Обзор
Документация
Войти
/
Manifest
/
Real_Texture
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
ToolsForUE/2_Bulider.py
233 строки
8 KB
m.samodurov
init commit for The Invaders
17 фев 2026, 04:57
17 фев 2026, 04:57
4a668d4
Код
Авторство
О чём код?
import os import subprocess import argparse from datetime import datetime from pathlib import Path import sys import json # Конфигурационный файл CONFIG_FILE = os.path.join(os.path.dirname(__file__), "ue_builder_config.json") # Пресет DEFAULT_CONFIG = { "ue_editor_path": "", "build_configs": ["Development", "Shipping"], "platforms": ["Win64"] } def load_config(): try: with open(CONFIG_FILE, 'r') as f: return json.load(f) except (FileNotFoundError, json.JSONDecodeError): return DEFAULT_CONFIG.copy() def save_config(config): with open(CONFIG_FILE, 'w') as f: json.dump(config, f, indent=4) def find_ue_editor(): #Поиск Unreal Editor search_paths = [ os.getenv("UE_INSTALL_PATH", ""), r"C:\Program Files\Epic Games", r"E:\EpicGames\Epic Games", r"F:\EpicGames\Epic Games", r"D:\EpicGames\Epic Games" ] for base_path in filter(None, search_paths): if not os.path.exists(base_path): continue for version in ["UE_5.3", "UE_5.2", "UE_5.1"]: editor_path = Path(base_path) / version / "Engine" / "Binaries" / "Win64" / "UnrealEditor-Cmd.exe" if editor_path.exists(): return str(editor_path) return "" def select_ue_editor(): print("\nВыберите способ указания пути к Unreal Editor:") print("1. Автоматический поиск") print("2. Указать вручную") print("3. Использовать сохраненный путь") choice = input("Выбор (1-3): ") if choice == "1": path = find_ue_editor() if path: print(f"\nНайден Unreal Editor: {path}") return path else: print("\nUnreal Editor не найден") return select_ue_editor() elif choice == "2": path = input("Путь до UnrealEditor-Cmd.exe: ").strip('"') if os.path.exists(path): return path else: print("Указанный путь не существует!") return select_ue_editor() elif choice == "3": config = load_config() if config["ue_editor_path"] and os.path.exists(config["ue_editor_path"]): return config["ue_editor_path"] else: print("Сохраненный путь не существует!") return select_ue_editor() else: print("Некорректный выбор") return select_ue_editor() def get_ue_editor_path(): """Получает путь к Unreal Editor с сохранением в конфиг""" config = load_config() # Если путь уже сохранен и существует if config["ue_editor_path"] and os.path.exists(config["ue_editor_path"]): return config["ue_editor_path"] # Иначе path = select_ue_editor() if path: config["ue_editor_path"] = path save_config(config) return path def find_project_root(): script_dir = os.path.dirname(os.path.abspath(__file__)) project_root = Path(script_dir).parent uproject_files = list(project_root.glob("*.uproject")) if not uproject_files: raise FileNotFoundError(f"Не найден .uproject файл в {project_root}") return project_root, uproject_files[0] def build_project(project_path, config, platform, clean=False): try: project_name = project_path.stem output_dir = project_path.parent / "Build" / platform / config log_dir = project_path.parent / "BuildLogs" log_dir.mkdir(parents=True, exist_ok=True) output_dir.mkdir(parents=True, exist_ok=True) timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") log_file = log_dir / f"{project_name}_{platform}_{config}_{timestamp}.log" ue_editor = get_ue_editor_path() if not ue_editor: print("Не удалось определить путь к Unreal Editor!") return False cmd = [ ue_editor, str(project_path), "-BuildCookRun", f"-project={project_path}", f"-platform={platform}", f"-clientconfig={config}", f"-serverconfig={config}", "-nocompileeditor", "-nop4", "-build", "-cook", "-stage", "-pak", "-archive", f"-archivedirectory={output_dir}", "-compressed" ] if clean: cmd.append("-clean") print(f"\nСборка {project_name} ({platform}|{config})") print(f"Unreal Editor: {ue_editor}") print(f"Выходная директория: {output_dir}") print(f"Лог: {log_file}") with open(log_file, "w") as log: process = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, bufsize=1, shell=True ) for line in process.stdout: sys.stdout.write(line) log.write(line) process.wait() if process.returncode == 0: print("\nСборка успешна!") if output_dir.exists(): print(f"Результаты в: {output_dir}") return True else: print(f"\nОшибка сборки (код: {process.returncode})") return False except Exception as e: print(f"\nКритическая ошибка: {str(e)}") return False def show_main_menu(config): print("\n=== Unreal Engine Project Builder ===") print(f"1. Путь к Unreal Editor: {config['ue_editor_path']}") print("2. Запустить сборку") print("3. Полная сборка (все конфигурации)") print("4. Выход") def main(): config = load_config() try: project_root, auto_project_path = find_project_root() except Exception as e: print(f"Ошибка: {str(e)}") project_root, auto_project_path = None, None while True: show_main_menu(config) choice = input("\nВыберите действие (1-4): ") if choice == "1": new_path = select_ue_editor() if new_path: config["ue_editor_path"] = new_path save_config(config) elif choice == "2": if not project_root: print("Не удалось определить проект!") continue build_project(auto_project_path, "Development", "Win64") elif choice == "3": if not project_root: print("Не удалось определить проект!") continue print("\nЗапускаем полную сборку:") success = True for platform in config["platforms"]: for config_name in config["build_configs"]: if not build_project(auto_project_path, config_name, platform): success = False print("\n" + "="*50) print("Все сборки завершены успешно!" if success else "Ошибки при сборке!") elif choice == "4": break else: print("Некорректный выбор") if __name__ == "__main__": main()