Skip to content

Commit

Permalink
Avoid duplicating known-safe UE4-bundled deps when precomputing data
Browse files Browse the repository at this point in the history
  • Loading branch information
adamrehn committed Aug 11, 2020
1 parent 1652287 commit eb646e9
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 5 deletions.
29 changes: 28 additions & 1 deletion conan_ue4cli/commands/precompute.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
from os.path import abspath, exists, join
from ..common import ConanTools, LibraryResolver, ProfileManagement, Utility


# Retrieves the Unreal Engine module name for a third-party library wrapper package
def getUnrealModule(package):

# Verify that the specified package is a wrapper package
if package['version'] != 'ue4' or package['description'] != 'GENERATED WRAPPER FOR: {}'.format(package['name']):
return None

# For wrapper packages, the package name is the Unreal Engine module name
return package['name']


def precompute(manager, argv):

# Our supported command-line arguments
Expand Down Expand Up @@ -60,16 +72,31 @@ def precompute(manager, argv):
# Keep track of any additional aggregated flags, including system libraries and macro definitions
flags = {
'defines': [],
'system_libs': []
'system_libs': [],
'unreal_modules': []
}

# The list of Unreal Engine modules that are safe to link to when using an Installed Build of the Engine
# TODO: determine these programmatically instead of simply hardcoding a list of known safe modules
UNREAL_MODULE_WHITELIST = [
'libcurl',
'UElibPNG',
'zlib'
]

# Aggregate the data for each of our dependencies
for dependency in info['dependencies']:

# Don't precompute data for the toolchain wrapper under Linux
if dependency['name'] == 'toolchain-wrapper':
continue

# If the dependency is an Unreal-bundled library that we can safely use in Installed Builds, link to its module directly
module = getUnrealModule(dependency)
if module is not None and module in UNREAL_MODULE_WHITELIST:
flags['unreal_modules'].append(module)
continue

# 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
5 changes: 4 additions & 1 deletion conan_ue4cli/data/boilerplate_templates/v1/Template.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@ private bool ProcessPrecomputedData(ReadOnlyTargetRules target, string engineVer
PublicAdditionalLibraries.Add(lib);
}

//Attempt to parse the JSON file containing any additional flags and system libraries
//Attempt to parse the JSON file containing any additional flags, modules and system libraries
JsonObject flags = JsonObject.Read(new FileReference(flagsFile));

//Link against any Unreal Engine modules for bundled third-party libraries
PrivateDependencyModuleNames.AddRange(flags.GetStringArrayField("unreal_modules"));

//Add any preprocessor definitions specified by the JSON file
PublicDefinitions.AddRange(flags.GetStringArrayField("defines"));

Expand Down
5 changes: 4 additions & 1 deletion conan_ue4cli/data/boilerplate_templates/v2/Template.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,12 @@ private bool ProcessPrecomputedData(ReadOnlyTargetRules target, string engineVer
PublicAdditionalLibraries.Add(lib);
}

//Attempt to parse the JSON file containing any additional flags and system libraries
//Attempt to parse the JSON file containing any additional flags, modules and system libraries
JsonObject flags = JsonObject.Read(new FileReference(flagsFile));

//Link against any Unreal Engine modules for bundled third-party libraries
PrivateDependencyModuleNames.AddRange(flags.GetStringArrayField("unreal_modules"));

//Add any preprocessor definitions specified by the JSON file
PublicDefinitions.AddRange(flags.GetStringArrayField("defines"));

Expand Down
5 changes: 4 additions & 1 deletion conan_ue4cli/data/boilerplate_templates/v3/Template.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,12 @@ private bool ProcessPrecomputedData(ReadOnlyTargetRules target, string engineVer
PublicAdditionalLibraries.Add(lib);
}

//Attempt to parse the JSON file containing any additional flags and system libraries
//Attempt to parse the JSON file containing any additional flags, modules and system libraries
JsonObject flags = JsonObject.Read(new FileReference(flagsFile));

//Link against any Unreal Engine modules for bundled third-party libraries
PrivateDependencyModuleNames.AddRange(flags.GetStringArrayField("unreal_modules"));

//Add any preprocessor definitions specified by the JSON file
PublicDefinitions.AddRange(flags.GetStringArrayField("defines"));

Expand Down
3 changes: 2 additions & 1 deletion conan_ue4cli/data/wrapper_template/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
class ${LIBNAME}Conan(ConanFile):
name = "${LIBNAME}"
version = "ue4"
description = "GENERATED WRAPPER FOR: ${LIBNAME}"
homepage = "https://github.com/adamrehn/conan-ue4cli"
author = "Adam Rehn (adam@adamrehn.com)"
license = "MIT"
url = "https://github.com/adamrehn/conan-ue4cli/tree/master/conan_ue4cli/data/wrapper_template"

settings = "os", "compiler", "build_type", "arch"
requires = ("ue4lib/ue4@adamrehn/profile")

Expand Down

0 comments on commit eb646e9

Please sign in to comment.