// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. using UnrealBuildTool; using System; using System.IO; using Microsoft.Win32; public class ZipUtility : ModuleRules { private string ThirdPartyPath { get { return Path.GetFullPath(Path.Combine(ModuleDirectory, "../../ThirdParty/")); } } private string SevenZppPath { get { return Path.GetFullPath(Path.Combine(ThirdPartyPath, "7zpp")); } } private string VsDirectory { get { //assume newer version default path string vsDefaultBasePath = @"C:\Program Files (x86)\Microsoft Visual Studio\2019"; if (!Directory.Exists(vsDefaultBasePath)) { //use 2017 default path vsDefaultBasePath = @"C:\Program Files (x86)\Microsoft Visual Studio\2017"; } string vsVersion = Directory.GetDirectories(vsDefaultBasePath)[0]; string vsPath = Path.Combine(vsDefaultBasePath, vsVersion); //------------------------------------------------------------------------------------ // IN CASE OF A BUILD ERROR BECAUSE OF A INCORRECT VS/ATL PATH // UNCOMMENT THE LINE BELOW AND REPLACE THE STRING WITH THE FULL PATH OF // YOUR VS INSTALLATION (INCLUDING COMMUNITY, PROFESSIONAL ETC) //------------------------------------------------------------------------------------ //vsPath = @"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"; Console.WriteLine("ZipUtility.Build.cs: Using VS path: " + vsPath); return vsPath; } } private string ATLPath { get { // Trying to find ATL path similar to: // C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.14.26428/atlmfc string atlPath = ""; try { var vsDir = VsDirectory; if (!string.IsNullOrEmpty(vsDir)) { string msvcPath = Path.Combine(vsDir, @"VC\Tools\MSVC\"); string msvcVersion = Directory.GetDirectories(msvcPath)[0]; atlPath = Path.Combine(msvcPath, msvcVersion, "atlmfc"); } } catch (Exception ex) { Console.WriteLine("ZipUtility Error: can't find VS path: " + ex.ToString()); } if (!Directory.Exists(atlPath)) { Console.WriteLine("ZipUtility Error: Couldn't find an ATLPath, fix it in ZipUtility.Build.cs"); //IF YOU GET THIS ERROR, CHECK IF THE RIGHT VS DIRECTORY IS USED ABOVE AND IF THE ATL LIB IS INSTALLED CORRECTLY } return atlPath; } } public ZipUtility(ReadOnlyTargetRules Target) : base(Target) { PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; PrivatePCHHeaderFile = "Private/ZipUtilityPrivatePCH.h"; PublicIncludePaths.AddRange( new string[] { Path.Combine(ModuleDirectory, "Public"), // ... add public include paths required here ... } ); PrivateIncludePaths.AddRange( new string[] { Path.Combine(ModuleDirectory, "Private"), Path.Combine(SevenZppPath, "Include"), Path.Combine(ATLPath, "include"), // ... add other private include paths required here ... } ); PublicDependencyModuleNames.AddRange( new string[] { "Core", "WindowsFileUtility" // ... add other public dependencies that you statically link with here ... } ); PrivateDependencyModuleNames.AddRange( new string[] { "CoreUObject", "Engine", "Slate", "SlateCore", "Projects" // ... add private dependencies that you statically link with here ... } ); DynamicallyLoadedModuleNames.AddRange( new string[] { // ... add any modules that your module loads dynamically here ... } ); LoadLib(Target); } public bool LoadLib(ReadOnlyTargetRules Target) { bool isLibrarySupported = false; if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32)) { isLibrarySupported = true; string PlatformSubPath = (Target.Platform == UnrealTargetPlatform.Win64) ? "Win64" : "Win32"; string LibrariesPath = Path.Combine(SevenZppPath, "Lib"); string DLLPath = Path.Combine(SevenZppPath, "dll"); PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, PlatformSubPath, "atls.lib")); PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, PlatformSubPath, "7zpp_u.lib")); PublicLibraryPaths.Add(Path.Combine(LibrariesPath, PlatformSubPath)); PublicDelayLoadDLLs.Add("7z.dll"); RuntimeDependencies.Add(Path.Combine(DLLPath, PlatformSubPath, "7z.dll")); } if (isLibrarySupported) { // Include path //PublicIncludePaths.Add(Path.Combine(SevenZppPath, "Include")); } return isLibrarySupported; } }