Пример #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="Platform">The platform to find the compiler for</param>
        /// <param name="Compiler">The compiler to use</param>
        /// <param name="CompilerDir">The compiler directory</param>
        /// <param name="CompilerVersion">The compiler version number</param>
        /// <param name="ToolChain">The base toolchain version</param>
        /// <param name="ToolChainDir">Directory containing the toolchain</param>
        /// <param name="ToolChainVersion">Version of the toolchain</param>
        /// <param name="WindowsSdkDir">Root directory containing the Windows Sdk</param>
        /// <param name="WindowsSdkVersion">Version of the Windows Sdk</param>
        public VCEnvironment(CppPlatform Platform, WindowsCompiler Compiler, DirectoryReference CompilerDir, VersionNumber CompilerVersion, WindowsCompiler ToolChain, DirectoryReference ToolChainDir, VersionNumber ToolChainVersion, DirectoryReference WindowsSdkDir, VersionNumber WindowsSdkVersion)
        {
            this.Compiler          = Compiler;
            this.CompilerDir       = CompilerDir;
            this.CompilerVersion   = CompilerVersion;
            this.ToolChain         = ToolChain;
            this.ToolChainDir      = ToolChainDir;
            this.ToolChainVersion  = ToolChainVersion;
            this.WindowsSdkDir     = WindowsSdkDir;
            this.WindowsSdkVersion = WindowsSdkVersion;

            // Get the standard VC paths
            DirectoryReference VCToolPath32 = GetVCToolPath32(ToolChain, ToolChainDir);
            DirectoryReference VCToolPath64 = GetVCToolPath64(ToolChain, ToolChainDir);

            // Compile using 64 bit tools for 64 bit targets, and 32 for 32.
            CompilerPath = GetCompilerToolPath(Platform, Compiler, CompilerDir);

            // Regardless of the target, if we're linking on a 64 bit machine, we want to use the 64 bit linker (it's faster than the 32 bit linker and can handle large linking jobs)
            DirectoryReference DefaultLinkerDir = VCToolPath64;

            LinkerPath         = GetLinkerToolPath(Platform, Compiler, DefaultLinkerDir);
            LibraryManagerPath = GetLibraryLinkerToolPath(Platform, Compiler, DefaultLinkerDir);

            // Get the resource compiler path from the Windows SDK
            ResourceCompilerPath = GetResourceCompilerToolPath(Platform, WindowsSdkDir, WindowsSdkVersion);

            // Add both toolchain paths to the PATH environment variable. There are some support DLLs which are only added to one of the paths, but which the toolchain in the other directory
            // needs to run (eg. mspdbcore.dll).
            if (Platform == CppPlatform.Win64)
            {
                AddDirectoryToPath(VCToolPath64);
                AddDirectoryToPath(VCToolPath32);
            }
            if (Platform == CppPlatform.Win32)
            {
                AddDirectoryToPath(VCToolPath32);
                AddDirectoryToPath(VCToolPath64);
            }

            // Get all the system include paths
            SetupEnvironment(Platform);
        }
 public IOSPostBuildSyncTarget(ReadOnlyTargetRules Target, FileReference OutputPath, DirectoryReference ProjectIntermediateDirectory, List <string> UPLScripts, VersionNumber SdkVersion, Dictionary <string, DirectoryReference> FrameworkNameToSourceDir)
 {
     this.Platform                     = Target.Platform;
     this.Configuration                = Target.Configuration;
     this.ProjectFile                  = Target.ProjectFile;
     this.TargetName                   = Target.Name;
     this.TargetType                   = Target.Type;
     this.OutputPath                   = OutputPath;
     this.UPLScripts                   = UPLScripts;
     this.SdkVersion                   = SdkVersion;
     this.bCreateStubIPA               = Target.IOSPlatform.bCreateStubIPA;
     this.bSkipCrashlytics             = Target.IOSPlatform.bSkipCrashlytics;
     this.ProjectDirectory             = DirectoryReference.FromFile(Target.ProjectFile) ?? UnrealBuildTool.EngineDirectory;
     this.ProjectIntermediateDirectory = ProjectIntermediateDirectory;
     this.ImportProvision              = Target.IOSPlatform.ImportProvision;
     this.ImportCertificate            = Target.IOSPlatform.ImportCertificate;
     this.ImportCertificatePassword    = Target.IOSPlatform.ImportCertificatePassword;
     this.FrameworkNameToSourceDir     = FrameworkNameToSourceDir;
     this.bForDistribution             = Target.IOSPlatform.bForDistribution;
 }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="Compiler">The compiler version</param>
        /// <param name="Platform">The platform to find the compiler for</param>
        /// <param name="ToolChainDir">Directory containing the toolchain</param>
        /// <param name="ToolChainVersion">Version of the toolchain</param>
        /// <param name="WindowsSdkDir">Root directory containing the Windows Sdk</param>
        /// <param name="WindowsSdkVersion">Version of the Windows Sdk</param>
        public VCEnvironment(WindowsCompiler Compiler, CppPlatform Platform, DirectoryReference ToolChainDir, VersionNumber ToolChainVersion, DirectoryReference WindowsSdkDir, VersionNumber WindowsSdkVersion)
        {
            this.Compiler          = Compiler;
            this.Platform          = Platform;
            this.ToolChainDir      = ToolChainDir;
            this.ToolChainVersion  = ToolChainVersion;
            this.WindowsSdkDir     = WindowsSdkDir;
            this.WindowsSdkVersion = WindowsSdkVersion;

            DirectoryReference VCToolPath32 = GetVCToolPath32(Compiler, ToolChainDir);
            DirectoryReference VCToolPath64 = GetVCToolPath64(Compiler, ToolChainDir);

            // Compile using 64 bit tools for 64 bit targets, and 32 for 32.
            DirectoryReference CompilerDir = (Platform == CppPlatform.Win64) ? VCToolPath64 : VCToolPath32;

            // Regardless of the target, if we're linking on a 64 bit machine, we want to use the 64 bit linker (it's faster than the 32 bit linker and can handle large linking jobs)
            DirectoryReference LinkerDir = VCToolPath64;

            CompilerPath         = GetCompilerToolPath(Platform, CompilerDir);
            LinkerPath           = GetLinkerToolPath(Platform, LinkerDir);
            LibraryManagerPath   = GetLibraryLinkerToolPath(Platform, LinkerDir);
            ResourceCompilerPath = GetResourceCompilerToolPath(Platform, WindowsSdkDir, WindowsSdkVersion);

            // Make sure the base 32-bit VS tool path is in the PATH, regardless of which configuration we're using. The toolchain may need to reference support DLLs from this directory (eg. mspdb120.dll).
            string PathEnvironmentVariable = Environment.GetEnvironmentVariable("PATH") ?? "";

            if (!PathEnvironmentVariable.Split(';').Any(x => String.Compare(x, VCToolPath32.FullName, true) == 0))
            {
                PathEnvironmentVariable = VCToolPath32.FullName + ";" + PathEnvironmentVariable;
                Environment.SetEnvironmentVariable("PATH", PathEnvironmentVariable);
            }

            // Get all the system include paths
            SetupEnvironment();
        }
        /// <summary>
        /// Gets the path to the resource compiler's rc.exe for the specified platform.
        /// </summary>
        static FileReference GetResourceCompilerToolPath(CppPlatform Platform, DirectoryReference WindowsSdkDir, VersionNumber WindowsSdkVersion)
        {
            // 64 bit -- we can use the 32 bit version to target 64 bit on 32 bit OS.
            if (Platform == CppPlatform.Win64)
            {
                FileReference ResourceCompilerPath = FileReference.Combine(WindowsSdkDir, "bin", WindowsSdkVersion.ToString(), "x64", "rc.exe");
                if (FileReference.Exists(ResourceCompilerPath))
                {
                    return(ResourceCompilerPath);
                }

                ResourceCompilerPath = FileReference.Combine(WindowsSdkDir, "bin", "x64", "rc.exe");
                if (FileReference.Exists(ResourceCompilerPath))
                {
                    return(ResourceCompilerPath);
                }
            }
            else
            {
                FileReference ResourceCompilerPath = FileReference.Combine(WindowsSdkDir, "bin", WindowsSdkVersion.ToString(), "x86", "rc.exe");
                if (FileReference.Exists(ResourceCompilerPath))
                {
                    return(ResourceCompilerPath);
                }

                ResourceCompilerPath = FileReference.Combine(WindowsSdkDir, "bin", "x86", "rc.exe");
                if (FileReference.Exists(ResourceCompilerPath))
                {
                    return(ResourceCompilerPath);
                }
            }
            throw new BuildException("Unable to find path to the Windows resource compiler under {0} (version {1})", WindowsSdkDir, WindowsSdkVersion);
        }
Пример #5
0
 public override bool GeneratePList(FileReference ProjectFile, UnrealTargetConfiguration Config, string ProjectDirectory, bool bIsUE4Game, string GameName, bool bIsClient, string ProjectName, string InEngineDir, string AppDirectory, List <string> UPLScripts, VersionNumber SdkVersion, string BundleID, bool bBuildAsFramework, out bool bSupportsPortrait, out bool bSupportsLandscape, out bool bSkipIcons)
 {
     bSupportsLandscape = bSupportsPortrait = true;
     bSkipIcons         = true;
     return(GenerateTVOSPList(ProjectDirectory, bIsUE4Game, GameName, bIsClient, ProjectName, InEngineDir, AppDirectory, null, BundleID));
 }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="Platform">The platform to find the compiler for</param>
        /// <param name="Compiler">The compiler to use</param>
        /// <param name="CompilerDir">The compiler directory</param>
        /// <param name="CompilerVersion">The compiler version number</param>
        /// <param name="Architecture">The compiler Architecture</param>
        /// <param name="ToolChain">The base toolchain version</param>
        /// <param name="ToolChainDir">Directory containing the toolchain</param>
        /// <param name="ToolChainVersion">Version of the toolchain</param>
        /// <param name="WindowsSdkDir">Root directory containing the Windows Sdk</param>
        /// <param name="WindowsSdkVersion">Version of the Windows Sdk</param>
        public VCEnvironment(UnrealTargetPlatform Platform, WindowsCompiler Compiler, DirectoryReference CompilerDir, VersionNumber CompilerVersion, WindowsArchitecture Architecture, WindowsCompiler ToolChain, DirectoryReference ToolChainDir, VersionNumber ToolChainVersion, DirectoryReference WindowsSdkDir, VersionNumber WindowsSdkVersion)
        {
            this.Compiler          = Compiler;
            this.CompilerDir       = CompilerDir;
            this.CompilerVersion   = CompilerVersion;
            this.Architecture      = Architecture;
            this.ToolChain         = ToolChain;
            this.ToolChainDir      = ToolChainDir;
            this.ToolChainVersion  = ToolChainVersion;
            this.WindowsSdkDir     = WindowsSdkDir;
            this.WindowsSdkVersion = WindowsSdkVersion;

            // Get the standard VC paths
            DirectoryReference VCToolPath = GetVCToolPath(ToolChain, ToolChainDir, Architecture);

            // Compile using 64 bit tools for 64 bit targets, and 32 for 32.
            CompilerPath = GetCompilerToolPath(Platform, Compiler, Architecture, CompilerDir);

            // Add the compiler path and directory as environment variables for the process so they may be used elsewhere.
            Environment.SetEnvironmentVariable("VC_COMPILER_PATH", CompilerPath.FullName, EnvironmentVariableTarget.Process);
            Environment.SetEnvironmentVariable("VC_COMPILER_DIR", CompilerPath.Directory.FullName, EnvironmentVariableTarget.Process);

            // Regardless of the target, if we're linking on a 64 bit machine, we want to use the 64 bit linker (it's faster than the 32 bit linker and can handle large linking jobs)
            DirectoryReference DefaultLinkerDir = VCToolPath;

            LinkerPath         = GetLinkerToolPath(Platform, Compiler, DefaultLinkerDir);
            LibraryManagerPath = GetLibraryLinkerToolPath(Platform, Compiler, DefaultLinkerDir);

            // Get the resource compiler path from the Windows SDK
            ResourceCompilerPath = GetResourceCompilerToolPath(Platform, WindowsSdkDir, WindowsSdkVersion);

            ISPCCompilerPath = GetISPCCompilerToolPath(Platform);

            // Add both toolchain paths to the PATH environment variable. There are some support DLLs which are only added to one of the paths, but which the toolchain in the other directory
            // needs to run (eg. mspdbcore.dll).
            if (Architecture == WindowsArchitecture.x64)
            {
                AddDirectoryToPath(GetVCToolPath(ToolChain, ToolChainDir, WindowsArchitecture.x64));
                AddDirectoryToPath(GetVCToolPath(ToolChain, ToolChainDir, WindowsArchitecture.x86));
            }
            else if (Architecture == WindowsArchitecture.x86)
            {
                AddDirectoryToPath(GetVCToolPath(ToolChain, ToolChainDir, WindowsArchitecture.x86));
                AddDirectoryToPath(GetVCToolPath(ToolChain, ToolChainDir, WindowsArchitecture.x64));
            }
            else if (Architecture == WindowsArchitecture.ARM64)
            {
                AddDirectoryToPath(GetVCToolPath(ToolChain, ToolChainDir, WindowsArchitecture.ARM64));
                AddDirectoryToPath(GetVCToolPath(ToolChain, ToolChainDir, WindowsArchitecture.x86));
                AddDirectoryToPath(GetVCToolPath(ToolChain, ToolChainDir, WindowsArchitecture.x64));
            }


            // Get all the system include paths
            SetupEnvironment(Platform);
        }
        /// <summary>
        /// Creates an environment with the given settings
        /// </summary>
        /// <param name="Compiler">The compiler version to use</param>
        /// <param name="Platform">The platform to target</param>
        /// <param name="Architecture">The Architecture to target</param>
        /// <param name="CompilerVersion">The specific toolchain version to use</param>
        /// <param name="WindowsSdkVersion">Version of the Windows SDK to use</param>
        /// <param name="SuppliedSdkDirectoryForVersion">If specified, this is the SDK directory to use, otherwise, attempt to look up via registry. If specified, the WindowsSdkVersion is used directly</param>
        /// <returns>New environment object with paths for the given settings</returns>
        public static VCEnvironment Create(WindowsCompiler Compiler, UnrealTargetPlatform Platform, WindowsArchitecture Architecture, string CompilerVersion, string WindowsSdkVersion, string SuppliedSdkDirectoryForVersion)
        {
            // Get the compiler version info
            VersionNumber      SelectedCompilerVersion;
            DirectoryReference SelectedCompilerDir;

            if (!WindowsPlatform.TryGetToolChainDir(Compiler, CompilerVersion, out SelectedCompilerVersion, out SelectedCompilerDir))
            {
                throw new BuildException("{0}{1} must be installed in order to build this target.", WindowsPlatform.GetCompilerName(Compiler), String.IsNullOrEmpty(CompilerVersion)? "" : String.Format(" ({0})", CompilerVersion));
            }

            // Get the toolchain info
            WindowsCompiler    ToolChain;
            VersionNumber      SelectedToolChainVersion;
            DirectoryReference SelectedToolChainDir;

            if (Compiler == WindowsCompiler.Clang || Compiler == WindowsCompiler.Intel)
            {
                if (WindowsPlatform.TryGetToolChainDir(WindowsCompiler.VisualStudio2019, null, out SelectedToolChainVersion, out SelectedToolChainDir))
                {
                    ToolChain = WindowsCompiler.VisualStudio2019;
                }
                else if (WindowsPlatform.TryGetToolChainDir(WindowsCompiler.VisualStudio2017, null, out SelectedToolChainVersion, out SelectedToolChainDir))
                {
                    ToolChain = WindowsCompiler.VisualStudio2017;
                }
                else
                {
                    throw new BuildException("{0} or {1} must be installed in order to build this target.", WindowsPlatform.GetCompilerName(WindowsCompiler.VisualStudio2019), WindowsPlatform.GetCompilerName(WindowsCompiler.VisualStudio2017));
                }
            }
            else
            {
                ToolChain = Compiler;
                SelectedToolChainVersion = SelectedCompilerVersion;
                SelectedToolChainDir     = SelectedCompilerDir;
            }

            // Get the actual Windows SDK directory
            VersionNumber      SelectedWindowsSdkVersion;
            DirectoryReference SelectedWindowsSdkDir;

            if (SuppliedSdkDirectoryForVersion != null)
            {
                SelectedWindowsSdkDir     = new DirectoryReference(SuppliedSdkDirectoryForVersion);
                SelectedWindowsSdkVersion = VersionNumber.Parse(WindowsSdkVersion);

                if (!DirectoryReference.Exists(SelectedWindowsSdkDir))
                {
                    throw new BuildException("Windows SDK{0} must be installed at {1}.", String.IsNullOrEmpty(WindowsSdkVersion) ? "" : String.Format(" ({0})", WindowsSdkVersion), SuppliedSdkDirectoryForVersion);
                }
            }
            else
            {
                if (!WindowsPlatform.TryGetWindowsSdkDir(WindowsSdkVersion, out SelectedWindowsSdkVersion, out SelectedWindowsSdkDir))
                {
                    throw new BuildException("Windows SDK{0} must be installed in order to build this target.", String.IsNullOrEmpty(WindowsSdkVersion) ? "" : String.Format(" ({0})", WindowsSdkVersion));
                }
            }

            return(new VCEnvironment(Platform, Compiler, SelectedCompilerDir, SelectedCompilerVersion, Architecture, ToolChain, SelectedToolChainDir, SelectedToolChainVersion, SelectedWindowsSdkDir, SelectedWindowsSdkVersion));
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="Platform">The platform to find the compiler for</param>
        /// <param name="Compiler">The compiler to use</param>
        /// <param name="CompilerDir">The compiler directory</param>
        /// <param name="CompilerVersion">The compiler version number</param>
        /// <param name="Architecture">The compiler Architecture</param>
        /// <param name="ToolChain">The base toolchain version</param>
        /// <param name="ToolChainDir">Directory containing the toolchain</param>
        /// <param name="ToolChainVersion">Version of the toolchain</param>
        /// <param name="WindowsSdkDir">Root directory containing the Windows Sdk</param>
        /// <param name="WindowsSdkVersion">Version of the Windows Sdk</param>
        public VCEnvironment(UnrealTargetPlatform Platform, WindowsCompiler Compiler, DirectoryReference CompilerDir, VersionNumber CompilerVersion, WindowsArchitecture Architecture, WindowsCompiler ToolChain, DirectoryReference ToolChainDir, VersionNumber ToolChainVersion, DirectoryReference WindowsSdkDir, VersionNumber WindowsSdkVersion)
        {
            this.Compiler          = Compiler;
            this.CompilerDir       = CompilerDir;
            this.CompilerVersion   = CompilerVersion;
            this.Architecture      = Architecture;
            this.ToolChain         = ToolChain;
            this.ToolChainDir      = ToolChainDir;
            this.ToolChainVersion  = ToolChainVersion;
            this.WindowsSdkDir     = WindowsSdkDir;
            this.WindowsSdkVersion = WindowsSdkVersion;

            // Get the standard VC paths
            DirectoryReference VCToolPath = GetVCToolPath(ToolChain, ToolChainDir, Architecture);

            // Compile using 64 bit tools for 64 bit targets, and 32 for 32.
            CompilerPath = GetCompilerToolPath(Platform, Compiler, Architecture, CompilerDir);

            // Regardless of the target, if we're linking on a 64 bit machine, we want to use the 64 bit linker (it's faster than the 32 bit linker and can handle large linking jobs)
            DirectoryReference DefaultLinkerDir = VCToolPath;

            LinkerPath         = GetLinkerToolPath(Platform, Compiler, DefaultLinkerDir);
            LibraryManagerPath = GetLibraryLinkerToolPath(Platform, Compiler, DefaultLinkerDir);

            // Get the resource compiler path from the Windows SDK
            ResourceCompilerPath = GetResourceCompilerToolPath(Platform, WindowsSdkDir, WindowsSdkVersion);

            // Get all the system include paths
            SetupEnvironment(Platform);
        }