Skip to content

Commit

Permalink
Add support for copying executable files when precomputing data
Browse files Browse the repository at this point in the history
  • Loading branch information
adamrehn committed Dec 1, 2021
1 parent f94c631 commit 8c9c9b9
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
18 changes: 17 additions & 1 deletion conan_ue4cli/commands/precompute.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import argparse, glob, json, os, sys, tempfile
from os.path import abspath, exists, join
from ..common import ConanTools, LibraryResolver, PackageManagement, ProfileManagement, Utility
from ..common import ConanTools, ExecutableResolver, LibraryResolver, PackageManagement, ProfileManagement, Utility


# Retrieves the Unreal Engine module name for a third-party library wrapper package
Expand Down Expand Up @@ -98,6 +98,12 @@ def precompute(manager, argv):
flags['unreal_modules'].append(module)
continue

# Retrieve the list of binaries (if any) for the dependency
binaries = []
userInfo = info['deps_user_info'][dependency['name']]
if 'binaries' in userInfo:
binaries = json.loads(userInfo['binaries'])

# Eliminate any include directories or library directories that fall outside the package's root directory
pathFilter = lambda paths: list([p for p in paths if p.startswith(dependency['rootpath'])])
dependency['include_paths'] = pathFilter(dependency['include_paths'])
Expand Down Expand Up @@ -139,6 +145,16 @@ def precompute(manager, argv):
print('Copying "{}"...'.format(file))
Utility.copyFileOrDir(file, dataDir)

# Copy the binaries from each of the dependency's binary directories
resolver = ExecutableResolver(targetPlatform, dependency['bin_paths'])
for binary in binaries:
resolved = resolver.resolve(binary)
if resolved is not None:
print('Copying "{}"...'.format(resolved))
Utility.copyFileOrDir(resolved, binDir)
else:
print('Warning: failed to resolve executable file for name "{}"'.format(binary))

# Add any macro definitions to our list
flags['defines'] += dependency['defines']

Expand Down
30 changes: 30 additions & 0 deletions conan_ue4cli/common/ExecutableResolver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from os.path import exists, join

class ExecutableResolver(object):
'''
Provides functionality for resolving executable files given search paths and library names
'''

def __init__(self, platform, searchPaths):
'''
Creates a new executable resolver for the specified platform and executable search paths
'''
self.platform = platform
self.searchPaths = searchPaths

def resolve(self, executableName):
'''
Attempts to resolve the path to the executable file for the specified name
'''

# Determine the appropriate filename suffix for the target platform
suffix = '.exe' if self.platform == 'Windows' else ''

# Iterate through each of our search paths and attempt to find the executable file
for searchDir in self.searchPaths:
resolved = join(searchDir, executableName + suffix)
if exists(resolved):
return resolved

# Failed to resolve the executable file
return None
1 change: 1 addition & 0 deletions conan_ue4cli/common/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .CommandExecutor import CommandExecutor
from .ConanTools import ConanTools
from .DelegateManager import DelegateManager
from .ExecutableResolver import ExecutableResolver
from .LibraryResolver import LibraryResolver
from .PackageBuilder import PackageBuilder
from .PackageManagement import PackageManagement
Expand Down

0 comments on commit 8c9c9b9

Please sign in to comment.