Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to run non-Development Editor + few minor fixes in the same code #63

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 33 additions & 9 deletions ue4cli/UnrealManagerBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +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/
baseTargets = ['Game', 'Editor']
if not self.isInstalledBuild():
baseTargets += ['Client', 'Server']
return baseTargets

def getPlatformIdentifier(self):
"""
Expand Down Expand Up @@ -117,15 +130,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
Expand Down Expand Up @@ -360,6 +377,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)
Expand All @@ -371,6 +391,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'
Expand All @@ -387,13 +411,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):
"""
Expand Down
9 changes: 5 additions & 4 deletions ue4cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand All @@ -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': {
Expand Down