def cmd_deploy(args): if not os.path.isfile(args.project_file): error_project_not_found(args) project = cryproject.load(args.project_file) if project is None: error_project_json_decode(args) project_dir = os.path.dirname(args.project_file) engine_id = cryproject.engine_id(project) engines = cryregistry.load_engines() engine_data = engines.get(engine_id) engine_file = engine_data['uri'] engine_dir = os.path.dirname(engine_file) deployment_dir = os.path.join(project_dir, 'Build') rc_path = os.path.join(engine_dir, "Tools/rc/rc.exe") source_asset_dir = os.path.join(project_dir, cryproject.asset_dir(project)) target_asset_dir = os.path.normcase( os.path.join(deployment_dir, cryproject.asset_dir(project))) if not os.path.exists(target_asset_dir): os.makedirs(target_asset_dir) # Copy plugin list copy_file(project_dir, deployment_dir, "cryplugin.csv") # Copy game binaries copy_file_formats_in_dir(os.path.join(project_dir, "bin"), os.path.join(deployment_dir, "bin"), ['*.dll', '*.exe']) # Start copying assets copy_file_formats_in_dir(source_asset_dir, target_asset_dir, ['*.xml', '*.pak', '*.cgf', '*.mtl', '*.cfg']) # Convert textures in assets dir subprocess.check_call([ rc_path, "*.tif", "/p=PC", "/sourceroot=" + source_asset_dir, "/targetroot=" + target_asset_dir, "refresh" ]) # Convert animations in assets dir subprocess.check_call([ rc_path, "*.i_caf", "/animConfigFolder=Animations", "/p=PC", "/sourceroot=" + source_asset_dir, "/targetroot=" + target_asset_dir, "refresh" ]) # Copy engine directory source_engine_assets_dir = os.path.join(engine_dir, "Engine") target_engine_assets_dir = os.path.join(deployment_dir, "Engine") copy_file_formats_in_dir( source_engine_assets_dir, target_engine_assets_dir, [ '*.cfg', '*.xml', '*.txt', '*.thread_config', '*.ttf', '*.dds', '*.mtl', '*.abc', '*.cbc', '*.cgf', '*.pfxp', '*.lut', '*.dat', '*.ext', '*.cfi', '*.cfx' ]) # Convert textures in engine dir subprocess.check_call([ rc_path, "*.tif", "/p=PC", "/sourceroot=" + source_engine_assets_dir, "/targetroot=" + target_engine_assets_dir, "refresh" ]) # Copy engine binaries copy_file_formats_in_dir(os.path.join(engine_dir, "bin"), os.path.join(deployment_dir, "bin"), ['*.dll', '*.exe', '*.py', '*.pyc']) # Create system cfg system_cfg_file = open(os.path.join(deployment_dir, "system.cfg"), "w") system_cfg_file.write("sys_game_folder=" + cryproject.asset_dir(project) + "\n") system_cfg_file.write("sys_dll_game=\"\"\n") system_cfg_file.close()
def find(engine_id, plugin_guid): engine_registry = cryregistry.load_engines() engine = engine_registry.get(engine_id, {}) plugin = engine.get('plugins', {}).get(plugin_guid, {}) return plugin.get('uri')
def copy_project_plugins( project, project_path, export_path, config_path, config_type, include_symbols): """ Copies all .dll files that belong to the plugins of the project. """ plugins = project.plugins_list() for plugin in plugins: guid = plugin.get("guid") path = plugin.get("path") plugin_type = plugin.get("type") platforms = plugin.get("platforms") if guid: if platforms: current_platform = CONFIGURATION_PLATFORM_LOOKUP[config_type] if current_platform not in platforms: continue engine_registry = cryregistry.load_engines() engine = engine_registry[project.engine_id()] installed_plugins = engine.get('plugins', {}) _plugin = cryplugin.CryPlugin() try: _plugin.load(installed_plugins[guid]['uri']) except Exception: print("Unable to read plugin file %s" % (guid)) sys.excepthook(*sys.exc_info()) continue for it in _plugin.binaries(config_path): src_file = it dst_file = os.path.join( export_path, config_path, os.path.basename(it)) if os.path.isfile(src_file): os.makedirs(os.path.dirname(dst_file), exist_ok=True) shutil.copyfile(src_file, dst_file) else: if not path: continue # Skip engine plugins. They are copied elsewhere. if not path.endswith(".dll"): continue if platforms: current_platform = CONFIGURATION_PLATFORM_LOOKUP[config_type] platform_included = current_platform in platforms if not platform_included: continue src_file = os.path.join(project_path, path) dst_file = os.path.join(export_path, path) if plugin_type == "EPluginType::Native": # Try to apply the selected engine configuration to the # plugin as well. This prevents mixing release with profile # configurations for example. This does assume plugins # follow the same naming-rules as the engine does, # as defined in DEFAULT_CONFIGURATIONS. adjusted_src_file = os.path.join( project_path, config_path, os.path.basename(path)) if os.path.isfile(adjusted_src_file): src_file = adjusted_src_file if os.path.isfile(src_file): os.makedirs(os.path.dirname(dst_file), exist_ok=True) shutil.copyfile(src_file, dst_file) # Copy debug symbols if include_symbols: src_file = "{}.pdb".format(os.path.splitext(src_file)[0]) if os.path.isfile(src_file): dst_file = "{}.pdb".format( os.path.splitext(dst_file)[0]) shutil.copyfile(src_file, dst_file) else: print("Failed to copy plugin file '{}' from {}!".format( path, src_file)) # Also copy the assembly generated from C# assets asset_assembly = os.path.join("bin", "CRYENGINE.CSharp.dll") src_file = os.path.join(project_path, asset_assembly) if os.path.isfile(src_file): dst_file = os.path.join(export_path, asset_assembly) os.makedirs(os.path.dirname(dst_file), exist_ok=True) shutil.copyfile(src_file, dst_file) if include_symbols: src_file = "{}.pdb".format(os.path.splitext(src_file)[0]) if os.path.isfile(src_file): dst_file = "{}.pdb".format(os.path.splitext(dst_file)[0]) shutil.copyfile(src_file, dst_file) else: src_file = "{}.dll.mdb".format(os.path.splitext(src_file)[0]) if os.path.isfile(src_file): dst_file = "{}.dll.mdb".format( os.path.splitext(dst_file)[0]) shutil.copyfile(src_file, dst_file)
def cmd_run(args): if not os.path.isfile(args.project_file): error_project_not_found(args) project = cryproject.load(args.project_file) if project is None: error_project_json_decode(args) engine_id = cryproject.engine_id(project) engine_registry = cryregistry.load_engines() engine_path = cryregistry.engine_path(engine_registry, engine_id) if engine_path is None: error_engine_path_not_found(args, engine_id) #--- if getattr(sys, 'frozen', False): subcmd = [ os.path.join(engine_path, 'Tools', 'CryVersionSelector', 'cryrun.exe') ] else: subcmd = [ python3_path(), os.path.join(engine_path, 'Tools', 'CryVersionSelector', 'cryrun.py') ] if not os.path.isfile(subcmd[-1]): error_engine_tool_not_found(subcmd[-1]) subcmd.extend(sys.argv[1:]) (temp_fd, temp_path) = tempfile.mkstemp(suffix='.out', prefix=args.command + '_', text=True) temp_file = os.fdopen(temp_fd, 'w') print_subprocess(subcmd) p = subprocess.Popen(subcmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) for line in p.stdout: temp_file.write(line) sys.stdout.write(line) returncode = p.wait() temp_file.close() if not args.silent and returncode != 0: title = command_title(args) text = p.stderr.read().strip() if not text: text = SUBPROCESS_NO_STDERR result = MessageBox(None, text, title, win32con.MB_OKCANCEL | win32con.MB_ICONERROR) if result == win32con.IDOK: subprocess.call(('notepad.exe', temp_path)) os.remove(temp_path) sys.exit(returncode)
def cmd_run_project(args, sys_argv=sys.argv[1:]): """ Runs the command on the project, by invoking it on the cryrun.exe that is used by the engine the project is registered to. """ if not os.path.isfile(args.project_file): error_project_not_found(args) project = cryproject.load(args.project_file) if project is None: error_project_json_decode(args) engine_id = cryproject.engine_id(project) engine_path = "" # Start by checking for the ability to specifying use of the local engine if engine_id is '.': engine_path = os.path.dirname(args.project_file) else: # Now check the registry engine_registry = cryregistry.load_engines() engine_path = cryregistry.engine_path(engine_registry, engine_id) if engine_path is None: error_engine_path_not_found(args, engine_id) if getattr(sys, 'frozen', False): subcmd = [ os.path.join(engine_path, 'Tools', 'CryVersionSelector', 'cryrun.exe') ] else: subcmd = [ get_python_path(), os.path.join(engine_path, 'Tools', 'CryVersionSelector', 'cryrun.py') ] if not os.path.isfile(subcmd[-1]): error_engine_tool_not_found(args, subcmd[-1]) subcmd.extend(sys_argv) print_subprocess(subcmd) process = subprocess.Popen(subcmd, stderr=subprocess.PIPE) returncode = process.wait() if not args.silent and returncode != 0: title = command_title(args) text = process.stderr.read().strip().decode() if not text: text = SUBPROCESS_NO_STDERR if HAS_WIN_MODULES: result = MESSAGEBOX(None, text, title, win32con.MB_OKCANCEL | win32con.MB_ICONERROR) if result == win32con.IDOK: input() # Keeps the window from closing else: sys.stderr.write(text) if returncode != 0: sys.exit(returncode)