From 6d2dae454097951e818b0c7f6d6cb31119f296d8 Mon Sep 17 00:00:00 2001 From: sleeptightAnsiC <91839286+sleeptightAnsiC@users.noreply.github.com> Date: Fri, 15 Mar 2024 15:01:46 +0100 Subject: [PATCH 1/2] Fix: allow to run non-Development Editor fix for https://github.com/adamrehn/ue4cli/issues/56 --- ue4cli/UnrealManagerBase.py | 34 ++++++++++++++++++++++++++-------- ue4cli/cli.py | 9 +++++---- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/ue4cli/UnrealManagerBase.py b/ue4cli/UnrealManagerBase.py index 763557f..41102b1 100644 --- a/ue4cli/UnrealManagerBase.py +++ b/ue4cli/UnrealManagerBase.py @@ -24,6 +24,13 @@ def validBuildConfigurations(self): """ return ['Debug', 'DebugGame', 'Development', 'Shipping', 'Test'] + def validBuildTargets(self): + """ + Returns the list of valid build targets supported by UnrealBuildTool + """ + # FIXME: Missing support for 'Program' build target: https://docs.unrealengine.com/5.3/en-US/unreal-engine-build-tool-target-reference/ + return ['Game', 'Editor', 'Client', 'Server'] + def getPlatformIdentifier(self): """ Returns the platform identifier for the current platform, as used by UnrealBuildTool @@ -117,15 +124,19 @@ def isInstalledBuild(self): sentinelFile = os.path.join(self.getEngineRoot(), 'Engine', 'Build', 'InstalledBuild.txt') return os.path.exists(sentinelFile) - def getEditorBinary(self, cmdVersion=False): + def getEditorBinary(self, cmdVersion=False, configuration='Development'): """ Determines the location of the UE4Editor/UnrealEditor binary """ - if self._getEngineVersionDetails()['MajorVersion'] >= 5: - return os.path.join(self.getEngineRoot(), 'Engine', 'Binaries', self.getPlatformIdentifier(), 'UnrealEditor' + self._editorPathSuffix(cmdVersion)) - else: - return os.path.join(self.getEngineRoot(), 'Engine', 'Binaries', self.getPlatformIdentifier(), 'UE4Editor' + self._editorPathSuffix(cmdVersion)) - + supportedConfigurations = ['Debug', 'DebugGame', 'Development'] + if configuration not in supportedConfigurations: + raise UnrealManagerException("Editor supports only following configurations: " + str(supportedConfigurations)) + platformIdentifier = self.getPlatformIdentifier() + coreName = 'UnrealEditor' if self._getEngineVersionDetails()['MajorVersion'] >= 5 else 'UE4Editor' + if configuration != 'Development': + coreName += '-' + platformIdentifier + '-' + configuration + return os.path.join(self.getEngineRoot(), 'Engine', 'Binaries', platformIdentifier, coreName + self._editorPathSuffix(cmdVersion)) + def getBuildScript(self): """ Determines the location of the script file to perform builds @@ -360,6 +371,9 @@ def buildDescriptor(self, dir=os.getcwd(), configuration='Development', target=' # Verify that the specified build configuration is valid if configuration not in self.validBuildConfigurations(): raise UnrealManagerException('invalid build configuration "' + configuration + '"') + # Verify that the specified build target is valid + if target not in self.validBuildTargets(): + raise UnrealManagerException('invalid build target "' + target + '"') # Check if the user specified the `-notools` flag to opt out of building Engine tools when working with source builds unstripped = list(args) @@ -371,6 +385,10 @@ def buildDescriptor(self, dir=os.getcwd(), configuration='Development', target=' Utility.printStderr('Ensuring ShaderCompileWorker is built before building project Editor modules...') self.buildTarget('ShaderCompileWorker', 'Development', [], suppressOutput) + # Game target does NOT use any postfix + if target == 'Game': + target = '' + # Generate the arguments to pass to UBT if self._getEngineVersionDetails()['MajorVersion'] >= 5: target = self.getDescriptorName(descriptor) + target if self.isProject(descriptor) else 'UnrealEditor' @@ -387,13 +405,13 @@ def buildTarget(self, target, configuration='Development', args=[], suppressOutp """ self._runUnrealBuildTool(target, self.getPlatformIdentifier(), configuration, args, capture=suppressOutput) - def runEditor(self, dir=os.getcwd(), debug=False, args=[]): + def runEditor(self, dir=os.getcwd(), debug=False, args=[], configuration='Development'): """ Runs the editor for the Unreal project in the specified directory (or without a project if dir is None) """ projectFile = self.getProjectDescriptor(dir) if dir is not None else '' extraFlags = ['-debug'] + args if debug == True else args - Utility.run([self.getEditorBinary(True), projectFile] + extraFlags + ['-stdout', '-FullStdOutLogOutput'], raiseOnError=True) + Utility.run([self.getEditorBinary(True, configuration), projectFile] + extraFlags + ['-stdout', '-FullStdOutLogOutput'], raiseOnError=True) def runUAT(self, args): """ diff --git a/ue4cli/cli.py b/ue4cli/cli.py index d5f51e3..cb0e215 100644 --- a/ue4cli/cli.py +++ b/ue4cli/cli.py @@ -45,8 +45,8 @@ 'editor': { 'description': 'Run the editor without an Unreal project (useful for creating new projects)', - 'action': lambda m, args: m.runEditor(None, False, args), - 'args': '[EXTRA ARGS]' + 'action': lambda m, args: m.runEditor(None, False, args, args.pop(0) if (len(args) > 0) else 'Development'), + 'args': '[CONFIGURATION] [EXTRA ARGS]' }, 'build-target': { @@ -60,9 +60,10 @@ 'action': lambda m, args: m.runEditor( os.getcwd(), True if '--debug' in args else False, - list([arg for arg in args if arg != '--debug']) + list([arg for arg in args if arg != '--debug']), + args.pop(0) if (len(args) > 0 and args[0].startswith('-') == False) else 'Development', ), - 'args': '[--debug] [EXTRA ARGS]' + 'args': '[CONFIGURATION] [--debug] [EXTRA ARGS]' }, 'gen': { From afbebc00392218d90096efccb83bc6160ffcb319 Mon Sep 17 00:00:00 2001 From: sleeptightAnsiC <91839286+sleeptightAnsiC@users.noreply.github.com> Date: Fri, 15 Mar 2024 16:06:43 +0100 Subject: [PATCH 2/2] fix: validBuildConfigurations/Targets check if Unreal is installed via EpicLauncher and return different results based on it. This was created based on table from https://docs.unrealengine.com/5.3/en-US/build-configurations-reference-for-unreal-engine/ --- ue4cli/UnrealManagerBase.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ue4cli/UnrealManagerBase.py b/ue4cli/UnrealManagerBase.py index 41102b1..5b71c53 100644 --- a/ue4cli/UnrealManagerBase.py +++ b/ue4cli/UnrealManagerBase.py @@ -22,14 +22,20 @@ def validBuildConfigurations(self): """ Returns the list of valid build configurations supported by UnrealBuildTool """ - return ['Debug', 'DebugGame', 'Development', 'Shipping', 'Test'] + baseConfigurations = ['DebugGame', 'Development', 'Shipping'] + if not self.isInstalledBuild(): + baseConfigurations += ['Debug', 'Test'] + return baseConfigurations def validBuildTargets(self): """ Returns the list of valid build targets supported by UnrealBuildTool """ # FIXME: Missing support for 'Program' build target: https://docs.unrealengine.com/5.3/en-US/unreal-engine-build-tool-target-reference/ - return ['Game', 'Editor', 'Client', 'Server'] + baseTargets = ['Game', 'Editor'] + if not self.isInstalledBuild(): + baseTargets += ['Client', 'Server'] + return baseTargets def getPlatformIdentifier(self): """