示例#1
0
    private string GetVisualStudioVersion()
#endif
    {
#if UE_4_18_OR_LATER
        WindowsCompiler Compiler = Target.WindowsPlatform.Compiler;
#else
        WindowsCompiler Compiler = WindowsPlatform.Compiler;
#endif
        string VSVersion = "vc140";


        try
        {
            if (Compiler == (WindowsCompiler)Enum.Parse(typeof(WindowsCompiler), "VisualStudio2013"))
            {
                VSVersion = "vc120";
            }
        }
        catch (Exception)
        {
        }

        try
        {
            if (Compiler == (WindowsCompiler)Enum.Parse(typeof(WindowsCompiler), "VisualStudio2015"))
            {
                VSVersion = "vc140";
            }
        }
        catch (Exception)
        {
        }

        try
        {
            if (Compiler == (WindowsCompiler)Enum.Parse(typeof(WindowsCompiler), "VisualStudio2017"))
            {
                VSVersion = "vc150";
            }
        }
        catch (Exception)
        {
        }

        return(VSVersion);
    }
示例#2
0
        /// <summary>
        /// Gets the version of the Universal CRT to use. As per VCVarsQueryRegistry.bat, this is the directory name that sorts last.
        /// </summary>
        static void FindUniversalCRT(WindowsCompiler Compiler, out string UniversalCRTDir, out string UniversalCRTVersion)
        {
            if (Compiler < WindowsCompiler.VisualStudio2015)
            {
                UniversalCRTDir     = null;
                UniversalCRTVersion = null;
                return;
            }

            string[] RootKeys =
            {
                "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots",
                "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots",
                "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows Kits\\Installed Roots",
                "HKEY_CURRENT_USER\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows Kits\\Installed Roots",
            };

            List <DirectoryInfo> IncludeDirs = new List <DirectoryInfo>();

            foreach (string RootKey in RootKeys)
            {
                string IncludeDirString = Registry.GetValue(RootKey, "KitsRoot10", null) as string;
                if (IncludeDirString != null)
                {
                    DirectoryInfo IncludeDir = new DirectoryInfo(Path.Combine(IncludeDirString, "include"));
                    if (IncludeDir.Exists)
                    {
                        IncludeDirs.AddRange(IncludeDir.EnumerateDirectories());
                    }
                }
            }

            DirectoryInfo LatestIncludeDir = IncludeDirs.OrderBy(x => x.Name).LastOrDefault(n => n.Name.All(s => (s >= '0' && s <= '9') || s == '.') && Directory.Exists(n.FullName + "\\ucrt"));

            if (LatestIncludeDir == null)
            {
                UniversalCRTDir     = null;
                UniversalCRTVersion = null;
            }
            else
            {
                UniversalCRTDir     = LatestIncludeDir.Parent.Parent.FullName;
                UniversalCRTVersion = LatestIncludeDir.Name;
            }
        }
示例#3
0
        private static string FindWindowsSDKExtensionInstallationFolder(WindowsCompiler Compiler)
        {
            string Version;

            switch (Compiler)
            {
            case WindowsCompiler.VisualStudio2017:
            case WindowsCompiler.VisualStudio2015:
                if (WindowsPlatform.bUseWindowsSDK10)
                {
                    Version = "v10.0";
                }
                else
                {
                    return(string.Empty);
                }
                break;

            default:
                return(string.Empty);
            }

            // Based on VCVarsQueryRegistry
            string FinalResult = null;

            {
                object Result = Microsoft.Win32.Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows SDKs\" + Version, "InstallationFolder", null)
                                ?? Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows SDKs\" + Version, "InstallationFolder", null);
                if (Result == null)
                {
                    Result = Microsoft.Win32.Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\" + Version, "InstallationFolder", null)
                             ?? Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\" + Version, "InstallationFolder", null);
                }
                if (Result != null)
                {
                    FinalResult = ((string)Result).TrimEnd('\\');
                }
            }
            if (FinalResult == null)
            {
                FinalResult = string.Empty;
            }

            return(FinalResult);
        }
示例#4
0
        /// <summary>
        /// Gets the path to the library linker.
        /// </summary>
        static FileReference GetLibraryLinkerToolPath(UnrealTargetPlatform Platform, WindowsCompiler Compiler, DirectoryReference DefaultLinkerDir)
        {
            // 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)
            if (Compiler == WindowsCompiler.Intel && WindowsPlatform.bAllowICLLinker)
            {
                FileReference LibPath = FileReference.Combine(DirectoryReference.GetSpecialFolder(Environment.SpecialFolder.ProgramFilesX86), "IntelSWTools", "compilers_and_libraries", "windows", "bin", Platform == UnrealTargetPlatform.Win32 ? "ia32" : "intel64", "xilib.exe");
                if (FileReference.Exists(LibPath))
                {
                    return(LibPath);
                }

                throw new BuildException("ICL was selected as the Windows compiler, but does not appear to be installed.  Could not find: " + LibPath);
            }
            else
            {
                return(FileReference.Combine(DefaultLinkerDir, "lib.exe"));
            }
        }
        /**
         * Returns VisualStudio common tools path for given compiler.
         *
         * @param Compiler Compiler for which to return tools path.
         *
         * @return Common tools path.
         */
        public static string GetVSComnToolsPath(WindowsCompiler Compiler)
        {
            int VSVersion;

            switch (Compiler)
            {
            case WindowsCompiler.VisualStudio2012:
                VSVersion = 11;
                break;

            case WindowsCompiler.VisualStudio2013:
                VSVersion = 12;
                break;

            default:
                throw new NotSupportedException("Not supported compiler.");
            }

            string[] PossibleRegPaths = new string[] {
                @"Wow6432Node\Microsoft\VisualStudio",  // Non-express VS2013 on 64-bit machine.
                @"Microsoft\VisualStudio",              // Non-express VS2013 on 32-bit machine.
                @"Wow6432Node\Microsoft\WDExpress",     // Express VS2013 on 64-bit machine.
                @"Microsoft\WDExpress"                  // Express VS2013 on 32-bit machine.
            };

            string VSPath = null;

            foreach (var PossibleRegPath in PossibleRegPaths)
            {
                VSPath = (string)Registry.GetValue(string.Format(@"HKEY_LOCAL_MACHINE\SOFTWARE\{0}\{1}.0", PossibleRegPath, VSVersion), "InstallDir", null);

                if (VSPath != null)
                {
                    break;
                }
            }

            if (VSPath == null)
            {
                return(null);
            }

            return(new DirectoryInfo(Path.Combine(VSPath, "..", "Tools")).FullName);
        }
示例#6
0
    private static string GetMsBuildExe(WindowsCompiler Version)
    {
        string VisualStudioToolchainVersion = "";

        switch (Version)
        {
        case WindowsCompiler.VisualStudio2015_DEPRECATED:
            VisualStudioToolchainVersion = "14.0";
            break;
        }
        string ProgramFilesPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
        string MSBuildPath      = Path.Combine(ProgramFilesPath, "MSBuild", VisualStudioToolchainVersion, "Bin", "MSBuild.exe");

        if (File.Exists(MSBuildPath))
        {
            return(MSBuildPath);
        }
        return(null);
    }
示例#7
0
 public static DirectoryReference GetCppCXMetadataLocation(WindowsCompiler Compiler, DirectoryReference SelectedToolChainDir)
 {
     if (Compiler == WindowsCompiler.VisualStudio2015_DEPRECATED)
     {
         return(DirectoryReference.Combine(SelectedToolChainDir, "lib", "store", "references"));
     }
     else if (Compiler >= WindowsCompiler.VisualStudio2017)
     {
         return(DirectoryReference.Combine(SelectedToolChainDir, "lib", "x86", "Store", "references"));
     }
     else if (Compiler >= WindowsCompiler.VisualStudio2019)
     {
         return(DirectoryReference.Combine(SelectedToolChainDir, "lib", "x86", "Store", "references"));
     }
     else
     {
         return(null);
     }
 }
示例#8
0
        private ToolchainInfo GenerateToolchainInfo(CppCompileEnvironment CompileEnvironment)
        {
            ToolchainInfo ToolchainInfo = new ToolchainInfo
            {
                CppStandard             = CompileEnvironment.CppStandard,
                Configuration           = CompileEnvironment.Configuration.ToString(),
                bEnableExceptions       = CompileEnvironment.bEnableExceptions,
                bOptimizeCode           = CompileEnvironment.bOptimizeCode,
                bUseInlining            = CompileEnvironment.bUseInlining,
                bUseUnity               = CompileEnvironment.bUseUnity,
                bCreateDebugInfo        = CompileEnvironment.bCreateDebugInfo,
                bIsBuildingLibrary      = CompileEnvironment.bIsBuildingLibrary,
                bUseAVX                 = CompileEnvironment.bUseAVX,
                bIsBuildingDLL          = CompileEnvironment.bIsBuildingDLL,
                bUseDebugCRT            = CompileEnvironment.bUseDebugCRT,
                bUseRTTI                = CompileEnvironment.bUseRTTI,
                bUseStaticCRT           = CompileEnvironment.bUseStaticCRT,
                PrecompiledHeaderAction = CompileEnvironment.PrecompiledHeaderAction.ToString(),
                PrecompiledHeaderFile   = CompileEnvironment.PrecompiledHeaderFile?.ToString(),
                ForceIncludeFiles       = CompileEnvironment.ForceIncludeFiles.Select(Item => Item.ToString()).ToList()
            };

            if (CurrentTarget.Platform.IsInGroup(UnrealPlatformGroup.Windows))
            {
                ToolchainInfo.Architecture = WindowsExports.GetArchitectureSubpath(CurrentTarget.Rules.WindowsPlatform.Architecture);

                WindowsCompiler WindowsPlatformCompiler = CurrentTarget.Rules.WindowsPlatform.Compiler;
                ToolchainInfo.bStrictConformanceMode = WindowsPlatformCompiler >= WindowsCompiler.VisualStudio2017 && CurrentTarget.Rules.WindowsPlatform.bStrictConformanceMode;
                ToolchainInfo.Compiler = WindowsPlatformCompiler.ToString();
            }
            else
            {
                string PlatformName  = $"{CurrentTarget.Platform}Platform";
                object Value         = typeof(ReadOnlyTargetRules).GetProperty(PlatformName)?.GetValue(CurrentTarget.Rules);
                object CompilerField = Value?.GetType().GetProperty("Compiler")?.GetValue(Value);
                if (CompilerField != null)
                {
                    ToolchainInfo.Compiler = CompilerField.ToString();
                }
            }

            return(ToolchainInfo);
        }
示例#9
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);
        }
示例#10
0
        /// <summary>
        /// Read the Visual C++ install directory for the given version.
        /// </summary>
        /// <param name="Compiler">Version of the toolchain to look for.</param>
        /// <param name="InstallDir">On success, the directory that Visual C++ is installed to.</param>
        /// <returns>True if the directory was found, false otherwise.</returns>
        public static bool TryGetVCInstallDir(WindowsCompiler Compiler, out DirectoryReference InstallDir)
        {
            if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Win64 && BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Win32)
            {
                InstallDir = null;
                return(false);
            }

            if (Compiler == WindowsCompiler.VisualStudio2013)
            {
                return(TryReadInstallDirRegistryKey32("Microsoft\\VisualStudio\\SxS\\VC7", "12.0", out InstallDir));
            }
            else if (Compiler == WindowsCompiler.VisualStudio2015)
            {
                return(TryReadInstallDirRegistryKey32("Microsoft\\VisualStudio\\SxS\\VC7", "14.0", out InstallDir));
            }
            else if (Compiler == WindowsCompiler.VisualStudio2017)
            {
                // VS15Preview installs the compiler under the IDE directory, and does not register it as a standalone component. Check just in case this changes
                // for compat in future since it's more specific.
                if (TryReadInstallDirRegistryKey32("Microsoft\\VisualStudio\\SxS\\VC7", "15.0", out InstallDir))
                {
                    return(true);
                }

                // Otherwise just check under the VS folder...
                DirectoryReference VSInstallDir;
                if (TryGetVSInstallDir(Compiler, out VSInstallDir))
                {
                    FileReference VersionPath = FileReference.Combine(VSInstallDir, "VC", "Auxiliary", "Build", "Microsoft.VCToolsVersion.default.txt");
                    if (FileReference.Exists(VersionPath))
                    {
                        InstallDir = VersionPath.Directory.ParentDirectory.ParentDirectory;
                        return(true);
                    }
                }
                return(false);
            }
            else
            {
                throw new BuildException("Invalid compiler version ({0})", Compiler);
            }
        }
示例#11
0
        /// <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="CompilerVersion">The specific toolchain version to use</param>
        /// <param name="WindowsSdkVersion">Version of the Windows SDK to use</param>
        /// <returns>New environment object with paths for the given settings</returns>
        public static VCEnvironment Create(WindowsCompiler Compiler, UnrealTargetPlatform Platform, string CompilerVersion, string WindowsSdkVersion)
        {
            // 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)
            {
                ToolChain = WindowsCompiler.VisualStudio2017;
                if (!WindowsPlatform.TryGetToolChainDir(ToolChain, null, out SelectedToolChainVersion, out SelectedToolChainDir))
                {
                    throw new BuildException("{0}{1} must be installed in order to build this target.", WindowsPlatform.GetCompilerName(Compiler), String.IsNullOrEmpty(CompilerVersion)? "" : String.Format(" ({0})", CompilerVersion));
                }
            }
            else
            {
                ToolChain = Compiler;
                SelectedToolChainVersion = SelectedCompilerVersion;
                SelectedToolChainDir     = SelectedCompilerDir;
            }

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

            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, ToolChain, SelectedToolChainDir, SelectedToolChainVersion, SelectedWindowsSdkDir, SelectedWindowsSdkVersion));
        }
示例#12
0
 /// <summary>
 /// Modify the rules for a newly created module, where the target is a different host platform.
 /// This is not required - but allows for hiding details of a particular platform.
 /// </summary>
 /// <param name="ModuleName">The name of the module</param>
 /// <param name="Rules">The module rules</param>
 /// <param name="Target">The target being build</param>
 public override void ModifyModuleRulesForOtherPlatform(string ModuleName, ModuleRules Rules, ReadOnlyTargetRules Target)
 {
     if (Target.Platform == UnrealTargetPlatform.Win64)
     {
         if (ProjectFileGenerator.bGenerateProjectFiles)
         {
             // Use latest SDK for Intellisense purposes
             WindowsCompiler CompilerForSdkRestriction = Target.HoloLensPlatform.Compiler != WindowsCompiler.Default ? Target.HoloLensPlatform.Compiler : Target.WindowsPlatform.Compiler;
             if (CompilerForSdkRestriction != WindowsCompiler.Default)
             {
                 Version            OutWin10SDKVersion;
                 DirectoryReference OutSdkDir;
                 if (WindowsExports.TryGetWindowsSdkDir(Target.HoloLensPlatform.Win10SDKVersionString, out OutWin10SDKVersion, out OutSdkDir))
                 {
                     Rules.PublicDefinitions.Add(string.Format("WIN10_SDK_VERSION={0}", OutWin10SDKVersion.Build));
                 }
             }
         }
     }
 }
示例#13
0
        /// <summary>
        /// Read the Visual Studio install directory for the given compiler version. Note that it is possible for the compiler toolchain to be installed without
        /// Visual Studio.
        /// </summary>
        /// <param name="Compiler">Version of the toolchain to look for.</param>
        /// <param name="InstallDir">On success, the directory that Visual Studio is installed to.</param>
        /// <returns>True if the directory was found, false otherwise.</returns>
        public static bool TryGetVSInstallDir(WindowsCompiler Compiler, out DirectoryReference InstallDir)
        {
            if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Win64 && BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Win32)
            {
                InstallDir = null;
                return(false);
            }

            switch (Compiler)
            {
            case WindowsCompiler.VisualStudio2015:
                return(TryReadInstallDirRegistryKey32("Microsoft\\VisualStudio\\SxS\\VS7", "14.0", out InstallDir));

            case WindowsCompiler.VisualStudio2017:
                return(TryReadInstallDirRegistryKey32("Microsoft\\VisualStudio\\SxS\\VS7", "15.0", out InstallDir));

            default:
                throw new BuildException("Invalid compiler version ({0})", Compiler);
            }
        }
        /// <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="CompilerVersion">The specific toolchain version to use</param>
        /// <param name="WindowsSdkVersion">Version of the Windows SDK to use</param>
        /// <returns>New environment object with paths for the given settings</returns>
        public static VCEnvironment Create(WindowsCompiler Compiler, CppPlatform Platform, string CompilerVersion, string WindowsSdkVersion)
        {
            // Get the actual toolchain directory
            VersionNumber      SelectedToolChainVersion;
            DirectoryReference SelectedToolChainDir;

            if (!WindowsPlatform.TryGetVCToolChainDir(Compiler, CompilerVersion, out SelectedToolChainVersion, out SelectedToolChainDir))
            {
                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 actual Windows SDK directory
            VersionNumber      SelectedWindowsSdkVersion;
            DirectoryReference SelectedWindowsSdkDir;

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

            return(new VCEnvironment(Compiler, Platform, SelectedToolChainDir, SelectedToolChainVersion, SelectedWindowsSdkDir, SelectedWindowsSdkVersion));
        }
        /// <summary>
        /// Gets the path to the 64bit tool binaries.
        /// </summary>
        /// <param name="Compiler">The version of the compiler being used</param>
        /// <param name="VCToolChainDir">Base directory for the VC toolchain</param>
        /// <returns>Directory containing the 64-bit toolchain binaries</returns>
        static DirectoryReference GetVCToolPath64(WindowsCompiler Compiler, DirectoryReference VCToolChainDir)
        {
            if (Compiler == WindowsCompiler.VisualStudio2017)
            {
                // Use the native 64-bit compiler if present
                FileReference NativeCompilerPath = FileReference.Combine(VCToolChainDir, "bin", "HostX64", "x64", "cl.exe");
                if (FileReference.Exists(NativeCompilerPath))
                {
                    return(NativeCompilerPath.Directory);
                }

                // Otherwise try the x64-on-x86 compiler. VS Express only includes the latter.
                FileReference CrossCompilerPath = FileReference.Combine(VCToolChainDir, "bin", "HostX86", "x64", "cl.exe");
                if (FileReference.Exists(CrossCompilerPath))
                {
                    return(CrossCompilerPath.Directory);
                }

                throw new BuildException("No 64-bit compiler toolchain found in {0} or {1}", NativeCompilerPath, CrossCompilerPath);
            }
            else
            {
                // Use the native 64-bit compiler if present
                FileReference NativeCompilerPath = FileReference.Combine(VCToolChainDir, "bin", "amd64", "cl.exe");
                if (FileReference.Exists(NativeCompilerPath))
                {
                    return(NativeCompilerPath.Directory);
                }

                // Otherwise use the amd64-on-x86 compiler. VS2012 Express only includes the latter.
                FileReference CrossCompilerPath = FileReference.Combine(VCToolChainDir, "bin", "x86_amd64", "cl.exe");
                if (FileReference.Exists(CrossCompilerPath))
                {
                    return(CrossCompilerPath.Directory);
                }

                throw new BuildException("No 64-bit compiler toolchain found in {0} or {1}", NativeCompilerPath, CrossCompilerPath);
            }
        }
 /// <summary>
 /// Gets the path to the compiler.
 /// </summary>
 static FileReference GetCompilerToolPath(UnrealTargetPlatform Platform, WindowsCompiler Compiler, WindowsArchitecture Architecture, DirectoryReference CompilerDir)
 {
     if (Compiler == WindowsCompiler.Clang)
     {
         return(FileReference.Combine(CompilerDir, "bin", "clang-cl.exe"));
     }
     else if (Compiler == WindowsCompiler.Intel)
     {
         if (Platform == UnrealTargetPlatform.Win32)
         {
             return(FileReference.Combine(CompilerDir, "bin", "ia32", "icl.exe"));
         }
         else
         {
             return(FileReference.Combine(CompilerDir, "bin", "intel64", "icl.exe"));
         }
     }
     else
     {
         return(FileReference.Combine(GetVCToolPath(Compiler, CompilerDir, Architecture), "cl.exe"));
     }
 }
示例#17
0
        /// <summary>
        /// Gets the Visual C++ installation folder from the registry
        /// </summary>
        static string FindVisualCppInstallationFolder(WindowsCompiler Version)
        {
            // Get the version string
            string VisualCppVersion;

            switch (Version)
            {
            case WindowsCompiler.VisualStudio2015:
                VisualCppVersion = "14.0";
                break;

            case WindowsCompiler.VisualStudio2013:
                VisualCppVersion = "12.0";
                break;

            case WindowsCompiler.VisualStudio2012:
                VisualCppVersion = "11.0";
                break;

            default:
                throw new BuildException("Unexpected compiler version when trying to determine Visual C++ installation folder");
            }

            // Read the registry value
            object Value =
                Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VC7", VisualCppVersion, null) ??
                Registry.GetValue("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VC7", VisualCppVersion, null) ??
                Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VC7", VisualCppVersion, null) ??
                Registry.GetValue("HKEY_CURRENT_USER\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VC7", VisualCppVersion, null);

            string InstallDir = Value as string;

            if (InstallDir == null)
            {
                throw new BuildException("Visual C++ must be installed to build this target.");
            }
            return(InstallDir);
        }
        public override void GenerateGameProperties(UnrealTargetConfiguration Configuration, StringBuilder VCProjectFileContent, TargetType TargetType, DirectoryReference RootDirectory, FileReference TargetFilePath)
        {
            string          MinVersion       = string.Empty;
            string          MaxTestedVersion = string.Empty;
            ConfigHierarchy EngineIni        = ConfigCache.ReadHierarchy(ConfigHierarchyType.Engine, RootDirectory, UnrealTargetPlatform.HoloLens);

            if (EngineIni != null)
            {
                EngineIni.GetString("/Script/HoloLensPlatformEditor.HoloLensTargetSettings", "MinimumPlatformVersion", out MinVersion);
                EngineIni.GetString("/Script/HoloLensPlatformEditor.HoloLensTargetSettings", "MaximumPlatformVersionTested", out MaxTestedVersion);
            }
            if (!string.IsNullOrEmpty(MinVersion))
            {
                VCProjectFileContent.Append("		<WindowsTargetPlatformMinVersion>"+ MinVersion + "</WindowsTargetPlatformMinVersion>" + ProjectFileGenerator.NewLine);
            }
            if (!string.IsNullOrEmpty(MaxTestedVersion))
            {
                VCProjectFileContent.Append("		<WindowsTargetPlatformVersion>"+ MaxTestedVersion + "</WindowsTargetPlatformVersion>" + ProjectFileGenerator.NewLine);
            }

            WindowsCompiler    Compiler = WindowsPlatform.GetDefaultCompiler(TargetFilePath);
            DirectoryReference PlatformWinMDLocation = HoloLens.GetCppCXMetadataLocation(Compiler, "Latest");

            if (PlatformWinMDLocation == null || !FileReference.Exists(FileReference.Combine(PlatformWinMDLocation, "platform.winmd")))
            {
                throw new BuildException("Unable to find platform.winmd for {0} toolchain; '{1}' is an invalid version", WindowsPlatform.GetCompilerName(Compiler), "Latest");
            }
            string FoundationWinMDPath = HoloLens.GetLatestMetadataPathForApiContract("Windows.Foundation.FoundationContract", Compiler);
            string UniversalWinMDPath  = HoloLens.GetLatestMetadataPathForApiContract("Windows.Foundation.UniversalApiContract", Compiler);

            VCProjectFileContent.Append("		<AdditionalOptions>/ZW /ZW:nostdlib</AdditionalOptions>"+ ProjectFileGenerator.NewLine);
            VCProjectFileContent.Append("		<NMakePreprocessorDefinitions>$(NMakePreprocessorDefinitions);PLATFORM_HOLOLENS=1;HOLOLENS=1;</NMakePreprocessorDefinitions>"+ ProjectFileGenerator.NewLine);
            if (PlatformWinMDLocation != null)
            {
                VCProjectFileContent.Append("		<NMakeAssemblySearchPath>$(NMakeAssemblySearchPath);"+ PlatformWinMDLocation + "</NMakeAssemblySearchPath>" + ProjectFileGenerator.NewLine);
            }
            VCProjectFileContent.Append("		<NMakeForcedUsingAssemblies>$(NMakeForcedUsingAssemblies);"+ FoundationWinMDPath + ";" + UniversalWinMDPath + ";platform.winmd</NMakeForcedUsingAssemblies>" + ProjectFileGenerator.NewLine);
        }
示例#19
0
        /// <summary>
        /// Modify the rules for a newly created module, where the target is a different host platform.
        /// This is not required - but allows for hiding details of a particular platform.
        /// </summary>
        /// <param name="ModuleName">The name of the module</param>
        /// <param name="Rules">The module rules</param>
        /// <param name="Target">The target being build</param>
        public override void ModifyModuleRulesForOtherPlatform(string ModuleName, ModuleRules Rules, ReadOnlyTargetRules Target)
        {
            // This code has been removed because it causes a full rebuild after generating project files (since response files are overwritten with different defines).
#if false
            if (Target.Platform == UnrealTargetPlatform.Win64)
            {
                if (ProjectFileGenerator.bGenerateProjectFiles)
                {
                    // Use latest SDK for Intellisense purposes
                    WindowsCompiler CompilerForSdkRestriction = Target.HoloLensPlatform.Compiler != WindowsCompiler.Default ? Target.HoloLensPlatform.Compiler : Target.WindowsPlatform.Compiler;
                    if (CompilerForSdkRestriction != WindowsCompiler.Default)
                    {
                        Version            OutWin10SDKVersion;
                        DirectoryReference OutSdkDir;
                        if (WindowsExports.TryGetWindowsSdkDir(Target.HoloLensPlatform.Win10SDKVersionString, out OutWin10SDKVersion, out OutSdkDir))
                        {
                            Rules.PublicDefinitions.Add(string.Format("WIN10_SDK_VERSION={0}", OutWin10SDKVersion.Build));
                        }
                    }
                }
            }
#endif
        }
示例#20
0
    private bool SupportsAkAutobahn()
    {
        if (Target.Configuration == UnrealTargetConfiguration.Shipping)
        {
            return(false);
        }

        if (Target.Platform == UnrealTargetPlatform.Mac)
        {
            return(true);
        }

        if (Target.Platform == UnrealTargetPlatform.Win32 || Target.Platform == UnrealTargetPlatform.Win64)
        {
#if UE_4_18_OR_LATER
            WindowsCompiler Compiler = Target.WindowsPlatform.Compiler;
#else
            WindowsCompiler Compiler = WindowsPlatform.Compiler;
#endif
            bool CompilerSupported = true;
            try
            {
                if (Compiler == (WindowsCompiler)Enum.Parse(typeof(WindowsCompiler), "VisualStudio2017"))
                {
                    CompilerSupported = false;
                }
            }
            catch (Exception)
            {
            }

            return(CompilerSupported);
        }

        return(false);
    }
示例#21
0
    private static string GetCMakeTargetDirectoryName(TargetPlatformData TargetData, WindowsCompiler TargetWindowsCompiler)
    {
        string VisualStudioDirectoryName;

        switch (TargetWindowsCompiler)
        {
        case WindowsCompiler.VisualStudio2015_DEPRECATED:
            VisualStudioDirectoryName = "VS2015";
            break;

        default:
            throw new AutomationException(String.Format("Non-CMake or unsupported windows compiler '{0}' supplied to GetCMakeTargetDirectoryName", TargetWindowsCompiler));
        }

        if (TargetData.Platform == UnrealTargetPlatform.Win64)
        {
            // Note slashes need to be '/' as this gets string-composed in the CMake script with other paths
            return("Win64/" + VisualStudioDirectoryName);
        }
        else
        {
            return(TargetData.Platform.ToString());
        }
    }
	private static string GetCMakeTargetDirectoryName(TargetPlatformData TargetData, WindowsCompiler TargetWindowsCompiler)
	{
		string VisualStudioDirectoryName;
		switch (TargetWindowsCompiler)
		{
			case WindowsCompiler.VisualStudio2013:
				VisualStudioDirectoryName = "VS2013";
				break;
			case WindowsCompiler.VisualStudio2015:
				VisualStudioDirectoryName = "VS2015";
				break;
			default:
				throw new AutomationException(String.Format("Non-CMake or unsupported windows compiler '{0}' supplied to GetCMakeTargetDirectoryName", TargetWindowsCompiler));
		}

		switch (TargetData.Platform)
		{
			// Note slashes need to be '/' as this gets string-composed in the CMake script with other paths
			case UnrealTargetPlatform.Win32:
				return "Win32/" + VisualStudioDirectoryName;
			case UnrealTargetPlatform.Win64:
				return "Win64/" + VisualStudioDirectoryName;
			case UnrealTargetPlatform.Android:
				switch (TargetData.Architecture)
				{
					default:
					case "armv7": return "Android/ARMv7";
					case "arm64": return "Android/ARM64";
					case "x86": return "Android/x86";
					case "x64": return "Android/x64";
				}
			case UnrealTargetPlatform.HTML5:
			default:
				return TargetData.Platform.ToString();
		}
	}
	private static DirectoryReference GetPlatformLibDirectory(TargetPlatformData TargetData, WindowsCompiler TargetWindowsCompiler)
	{
		string VisualStudioName = string.Empty;
		string ArchName = string.Empty;

		if (DoesPlatformUseMSBuild(TargetData))
		{
			switch (TargetWindowsCompiler)
			{
				case WindowsCompiler.VisualStudio2013:
					VisualStudioName = "VS2013";
					break;
				case WindowsCompiler.VisualStudio2015:
					VisualStudioName = "VS2015";
					break;
				default:
					throw new AutomationException(String.Format("Unsupported visual studio compiler '{0}' supplied to GetOutputLibDirectory", TargetWindowsCompiler));
			}
		}

		switch (TargetData.Platform)
		{
			case UnrealTargetPlatform.Win32:
				ArchName = "Win32";
				break;
			case UnrealTargetPlatform.Win64:
				ArchName = "Win64";
				break;
			case UnrealTargetPlatform.XboxOne:
				ArchName = "XboxOne";
				break;
			case UnrealTargetPlatform.PS4:
				ArchName = "PS4";
				break;
			case UnrealTargetPlatform.Android:
				switch (TargetData.Architecture)
				{
					default:
					case "arm7": ArchName = "Android/ARMv7"; break;
					case "arm64": ArchName = "Android/ARM64"; break;
					case "x86": ArchName = "Android/x86"; break;
					case "x64": ArchName = "Android/x64"; break;
				}
				break;
			case UnrealTargetPlatform.Linux:
				ArchName = "Linux/" + TargetData.Architecture;
				break;
			case UnrealTargetPlatform.Mac:
				ArchName = "Mac";
				break;
			case UnrealTargetPlatform.HTML5:
				ArchName = "HTML5";
				break;
			case UnrealTargetPlatform.IOS:
				ArchName = "IOS";
				break;
			case UnrealTargetPlatform.TVOS:
				ArchName = "TVOS";
				break;
			default:
				throw new AutomationException(String.Format("Unsupported platform '{0}' supplied to GetOutputLibDirectory", TargetData.ToString()));
		}

		return UnrealBuildTool.DirectoryReference.Combine(RootOutputLibDirectory, ArchName, VisualStudioName);
	}
示例#24
0
    private static void FindOutputFiles(HashSet <FileReference> OutputFiles, TargetPlatformData TargetData, string TargetConfiguration, WindowsCompiler TargetWindowsCompiler = WindowsCompiler.VisualStudio2015_DEPRECATED)
    {
        string SearchSuffix = "";

        if (TargetConfiguration == "Debug")
        {
            SearchSuffix = "d";
        }
        if (TargetData.Platform == UnrealTargetPlatform.Win64)
        {
            SearchSuffix += "_64";
        }

        string SearchPrefix = "*" + SearchSuffix + ".";

        DirectoryReference LibDir = GetPlatformLibDirectory(TargetData, TargetWindowsCompiler);

        FindOutputFilesHelper(OutputFiles, LibDir, SearchPrefix + GetPlatformLibExtension(TargetData));

        if (TargetData.Platform == UnrealTargetPlatform.Win64)
        {
            FindOutputFilesHelper(OutputFiles, LibDir, SearchPrefix + "pdb");
        }
    }
		/// <summary>
		/// Read the Visual Studio install directory for the given compiler version. Note that it is possible for the compiler toolchain to be installed without
		/// Visual Studio.
		/// </summary>
		/// <param name="Compiler">Version of the toolchain to look for.</param>
		/// <param name="InstallDir">On success, the directory that Visual Studio is installed to.</param>
		/// <returns>True if the directory was found, false otherwise.</returns>
		public static bool TryGetVSInstallDir(WindowsCompiler Compiler, out DirectoryReference InstallDir)
		{
			if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Win64 && BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Win32)
			{
				InstallDir = null;
				return false;
			}

			switch(Compiler)
			{
				case WindowsCompiler.VisualStudio2013:
					return TryReadInstallDirRegistryKey32("Microsoft\\VisualStudio\\SxS\\VS7", "12.0", out InstallDir);
				case WindowsCompiler.VisualStudio2015:
					return TryReadInstallDirRegistryKey32("Microsoft\\VisualStudio\\SxS\\VS7", "14.0", out InstallDir);
				case WindowsCompiler.VisualStudio2017:
					return TryReadInstallDirRegistryKey32("Microsoft\\VisualStudio\\SxS\\VS7", "15.0", out InstallDir);
				default:
					throw new BuildException("Invalid compiler version ({0})", Compiler);
			}
		}
	private static void BuildMSBuildTarget(PhysXTargetLib TargetLib, TargetPlatformData TargetData, List<string> TargetConfigurations, WindowsCompiler TargetWindowsCompiler = WindowsCompiler.VisualStudio2015)
	{
		string SolutionFile = GetTargetLibSolutionFileName(TargetLib, TargetData, TargetWindowsCompiler).ToString();
		string MSDevExe = GetMsDevExe(TargetData);

		if (!FileExists(SolutionFile))
		{
			throw new AutomationException(String.Format("Unabled to build Solution {0}. Solution file not found.", SolutionFile));
		}
		if (String.IsNullOrEmpty(MSDevExe))
		{
			throw new AutomationException(String.Format("Unabled to build Solution {0}. devenv.com not found.", SolutionFile));
		}

		foreach (string BuildConfig in TargetConfigurations)
		{
			string CmdLine = String.Format("\"{0}\" /build \"{1}\"", SolutionFile, BuildConfig);
			RunAndLog(BuildCommand.CmdEnv, MSDevExe, CmdLine);
		}
	}
	private static string GetMsDevExe(WindowsCompiler Version)
	{
        DirectoryReference VSPath;
		// It's not fatal if VS2013 isn't installed for VS2015 builds (for example, so don't crash here)
		if(WindowsPlatform.TryGetVSInstallDir(Version, out VSPath))
		{
			return FileReference.Combine(VSPath, "Common7", "IDE", "Devenv.com").FullName;
		}
		return null;
	}
	private static string GetCMakeArguments(PhysXTargetLib TargetLib, TargetPlatformData TargetData, string BuildConfig = "", WindowsCompiler TargetWindowsCompiler = WindowsCompiler.VisualStudio2015)
	{
		string VisualStudioName;
		switch(TargetWindowsCompiler)
		{
			case WindowsCompiler.VisualStudio2013:
				VisualStudioName = "Visual Studio 12 2013";
				break;
			case WindowsCompiler.VisualStudio2015:
				VisualStudioName = "Visual Studio 14 2015";
				break;
			default:
				throw new AutomationException(String.Format("Non-CMake or unsupported platform '{0}' supplied to GetCMakeArguments", TargetData.ToString()));
		}

		string OutputFlags = " -DPX_OUTPUT_LIB_DIR=" + GetPlatformLibDirectory(TargetData, TargetWindowsCompiler);
		if(PlatformHasBinaries(TargetData))
		{
			OutputFlags += " -DPX_OUTPUT_DLL_DIR=" + GetPlatformBinaryDirectory(TargetData, TargetWindowsCompiler) + " -DPX_OUTPUT_EXE_DIR=" + GetPlatformBinaryDirectory(TargetData, TargetWindowsCompiler);
		}

        // Enable response files for platforms that require them.
        // Response files are used for include paths etc, to fix max command line length issues.
        switch (TargetData.Platform)
        {
            case UnrealTargetPlatform.PS4:
            case UnrealTargetPlatform.Linux:
                OutputFlags += " -DUSE_RESPONSE_FILES=1";
                break;
        }

		string CustomFlags = " -DAPEX_ENABLE_UE4=1";
		switch (TargetLib)
		{
			case PhysXTargetLib.PhysX:
				DirectoryReference PhysXCMakeFiles = DirectoryReference.Combine(PhysX34SourceRootDirectory, "Source", "compiler", "cmake");
				switch (TargetData.Platform)
				{
					case UnrealTargetPlatform.Win32:
						return DirectoryReference.Combine(PhysXCMakeFiles, "Windows").ToString() + " -G \"" + VisualStudioName + "\" -AWin32 -DTARGET_BUILD_PLATFORM=Windows" + OutputFlags;
					case UnrealTargetPlatform.Win64:
						return DirectoryReference.Combine(PhysXCMakeFiles, "Windows").ToString() + " -G \"" + VisualStudioName + "\" -Ax64 -DTARGET_BUILD_PLATFORM=Windows" + OutputFlags;
					 case UnrealTargetPlatform.PS4:
                        return DirectoryReference.Combine(PhysXCMakeFiles, "PS4").ToString() + " -G \"Unix Makefiles\" -DTARGET_BUILD_PLATFORM=PS4 -DCMAKE_BUILD_TYPE=" + BuildConfig + " -DCMAKE_TOOLCHAIN_FILE=\"" + PhysXSourceRootDirectory + "\\Externals\\CMakeModules\\PS4\\PS4Toolchain.txt\"" + OutputFlags;
                    case UnrealTargetPlatform.XboxOne:
						return DirectoryReference.Combine(PhysXCMakeFiles, "XboxOne").ToString() + " -G \"Visual Studio 14 2015\" -DTARGET_BUILD_PLATFORM=XboxOne -DCMAKE_TOOLCHAIN_FILE=\"" + PhysXSourceRootDirectory + "\\Externals\\CMakeModules\\XboxOne\\XboxOneToolchain.txt\" -DCMAKE_GENERATOR_PLATFORM=DURANGO" + OutputFlags;
					case UnrealTargetPlatform.Android:
						string NDKDirectory = Environment.GetEnvironmentVariable("NDKROOT");

						// don't register if we don't have an NDKROOT specified
						if (String.IsNullOrEmpty(NDKDirectory))
						{
							throw new BuildException("NDKROOT is not specified; cannot build Android.");
						}

						NDKDirectory = NDKDirectory.Replace("\"", "");

						string AndroidAPILevel = "android-19";
						string AndroidABI = "armeabi-v7a";
						switch (TargetData.Architecture)
						{
							case "armv7": AndroidAPILevel = "android-19"; AndroidABI = "armeabi-v7a"; break;
							case "arm64": AndroidAPILevel = "android-21"; AndroidABI = "arm64-v8a"; break;
							case "x86":   AndroidAPILevel = "android-19"; AndroidABI = "x86"; break;
							case "x64":   AndroidAPILevel = "android-21"; AndroidABI = "x86_64"; break;
						}
						return DirectoryReference.Combine(PhysXCMakeFiles, "Android").ToString() + " -G \"MinGW Makefiles\" -DTARGET_BUILD_PLATFORM=Android -DCMAKE_BUILD_TYPE=" + BuildConfig + " -DCMAKE_TOOLCHAIN_FILE=\"" + PhysXSourceRootDirectory + "\\Externals\\CMakeModules\\Android\\android.toolchain.cmake\" -DANDROID_NDK=\"" + NDKDirectory + "\" -DCMAKE_MAKE_PROGRAM=\"" + NDKDirectory + "\\prebuilt\\windows-x86_64\\bin\\make.exe\" -DANDROID_NATIVE_API_LEVEL=\"" + AndroidAPILevel + "\" -DANDROID_ABI=\"" + AndroidABI + "\" -DANDROID_STL=gnustl_shared" + OutputFlags;
					case UnrealTargetPlatform.Linux:
						return DirectoryReference.Combine(PhysXCMakeFiles, "Linux").ToString() + " -G \"Unix Makefiles\" -DTARGET_BUILD_PLATFORM=Linux -DCMAKE_BUILD_TYPE=" + BuildConfig + GetLinuxToolchainSettings(TargetData) + OutputFlags;
					case UnrealTargetPlatform.Mac:
						return DirectoryReference.Combine(PhysXCMakeFiles, "Mac").ToString() + " -G \"Xcode\" -DTARGET_BUILD_PLATFORM=Mac" + OutputFlags;
					case UnrealTargetPlatform.IOS:
						return DirectoryReference.Combine(PhysXCMakeFiles, "IOS").ToString() + " -G \"Xcode\" -DTARGET_BUILD_PLATFORM=IOS" + OutputFlags;
					case UnrealTargetPlatform.TVOS:
						return DirectoryReference.Combine(PhysXCMakeFiles, "TVOS").ToString() + " -G \"Xcode\" -DTARGET_BUILD_PLATFORM=TVOS" + OutputFlags;
					case UnrealTargetPlatform.HTML5:
						string CmakeToolchainFile = FileReference.Combine(PhysXSourceRootDirectory, "Externals", "CMakeModules", "HTML5", "Emscripten.cmake").ToString();
						return DirectoryReference.Combine(PhysXCMakeFiles, "HTML5").ToString() +
							" -G \"Unix Makefiles\" -DTARGET_BUILD_PLATFORM=HTML5" +
							" -DPXSHARED_ROOT_DIR=\"" + SharedSourceRootDirectory.ToString() + "\"" +
							" -DNVSIMD_INCLUDE_DIR=\"" + SharedSourceRootDirectory.ToString() + "/src/NvSimd\"" +
							" -DNVTOOLSEXT_INCLUDE_DIRS=\"" + PhysX34SourceRootDirectory + "/externals/nvToolsExt/include\"" +
							" -DCMAKE_BUILD_TYPE=\"Release\" -DCMAKE_TOOLCHAIN_FILE=\"" + CmakeToolchainFile + "\"" +
							OutputFlags;
					default:
						throw new AutomationException(String.Format("Non-CMake or unsupported platform '{0}' supplied to GetCMakeArguments", TargetData.ToString()));
				}
			case PhysXTargetLib.APEX:
				DirectoryReference ApexCMakeFiles = DirectoryReference.Combine(APEX14SourceRootDirectory, "compiler", "cmake");
				switch (TargetData.Platform)
				{
					case UnrealTargetPlatform.Win32:
						return DirectoryReference.Combine(ApexCMakeFiles, "Windows").ToString() + " -G \"" + VisualStudioName + "\" -AWin32 -DTARGET_BUILD_PLATFORM=Windows" + OutputFlags + CustomFlags;
					case UnrealTargetPlatform.Win64:
						return DirectoryReference.Combine(ApexCMakeFiles, "Windows").ToString() + " -G \"" + VisualStudioName + "\" -Ax64 -DTARGET_BUILD_PLATFORM=Windows" + OutputFlags + CustomFlags;
					case UnrealTargetPlatform.PS4:
                        return DirectoryReference.Combine(ApexCMakeFiles, "PS4").ToString() + " -G \"Unix Makefiles\" -DTARGET_BUILD_PLATFORM=PS4 -DCMAKE_BUILD_TYPE=" + BuildConfig + " -DCMAKE_TOOLCHAIN_FILE=\"" + PhysXSourceRootDirectory + "\\Externals\\CMakeModules\\PS4\\PS4Toolchain.txt\"" + OutputFlags + CustomFlags;
                    case UnrealTargetPlatform.XboxOne:
						return DirectoryReference.Combine(ApexCMakeFiles, "XboxOne").ToString() + " -G \"Visual Studio 14 2015\" -DTARGET_BUILD_PLATFORM=XboxOne -DCMAKE_TOOLCHAIN_FILE=\"" + PhysXSourceRootDirectory + "\\Externals\\CMakeModules\\XboxOne\\XboxOneToolchain.txt\" -DCMAKE_GENERATOR_PLATFORM=DURANGO" + OutputFlags + CustomFlags;
					case UnrealTargetPlatform.Linux:
						return DirectoryReference.Combine(ApexCMakeFiles, "Linux").ToString() + " -G \"Unix Makefiles\" -DTARGET_BUILD_PLATFORM=Linux -DCMAKE_BUILD_TYPE=" + BuildConfig + GetLinuxToolchainSettings(TargetData) + OutputFlags + CustomFlags;
					case UnrealTargetPlatform.Mac:
						return DirectoryReference.Combine(ApexCMakeFiles, "Mac").ToString() + " -G \"Xcode\" -DTARGET_BUILD_PLATFORM=Mac" + OutputFlags + CustomFlags;
					case UnrealTargetPlatform.HTML5:
						string CmakeToolchainFile = FileReference.Combine(PhysXSourceRootDirectory, "Externals", "CMakeModules", "HTML5", "Emscripten.cmake").ToString();
						return DirectoryReference.Combine(ApexCMakeFiles, "HTML5").ToString() +
							" -G \"Unix Makefiles\" -DTARGET_BUILD_PLATFORM=HTML5" +
							" -DPHYSX_ROOT_DIR=\"" + PhysX34SourceRootDirectory.ToString() + "\"" +
							" -DPXSHARED_ROOT_DIR=\"" + SharedSourceRootDirectory.ToString() + "\"" +
							" -DNVSIMD_INCLUDE_DIR=\"" + SharedSourceRootDirectory.ToString() + "/src/NvSimd\"" +
							" -DNVTOOLSEXT_INCLUDE_DIRS=\"" + PhysX34SourceRootDirectory + "/externals/nvToolsExt/include\"" +
							" -DCMAKE_BUILD_TYPE=\"Release\" -DCMAKE_TOOLCHAIN_FILE=\"" + CmakeToolchainFile + "\"" +
							OutputFlags + CustomFlags;
					 default:
						throw new AutomationException(String.Format("Non-CMake or unsupported platform '{0}' supplied to GetCMakeArguments", TargetData.ToString()));
				}
			default:
				throw new AutomationException(String.Format("Non-CMake or unsupported lib '{0}' supplied to GetCMakeArguments", TargetLib));
		}
	}
示例#29
0
        /// <summary>
        /// Sets the Visual C++ INCLUDE environment variable
        /// </summary>
        static List <string> GetVisualCppIncludePaths(WindowsCompiler Compiler, DirectoryReference VisualCppDir, DirectoryReference VisualCppToolchainDir, string UniversalCRTDir, string UniversalCRTVersion, string NetFXSDKDir, string WindowsSDKDir, string WindowsSDKLibVersion, bool bSupportWindowsXP)
        {
            List <string> IncludePaths = new List <string>();

            // Add the standard Visual C++ include paths
            if (Compiler == WindowsCompiler.VisualStudio2017)
            {
                DirectoryReference StdIncludeDir = DirectoryReference.Combine(VisualCppToolchainDir, "INCLUDE");
                if (StdIncludeDir.Exists())
                {
                    IncludePaths.Add(StdIncludeDir.FullName);
                }
                DirectoryReference AtlMfcIncludeDir = DirectoryReference.Combine(VisualCppToolchainDir, "ATLMFC", "INCLUDE");
                if (AtlMfcIncludeDir.Exists())
                {
                    IncludePaths.Add(AtlMfcIncludeDir.FullName);
                }
            }
            else
            {
                DirectoryReference StdIncludeDir = DirectoryReference.Combine(VisualCppDir, "INCLUDE");
                if (StdIncludeDir.Exists())
                {
                    IncludePaths.Add(StdIncludeDir.FullName);
                }
                DirectoryReference AtlMfcIncludeDir = DirectoryReference.Combine(VisualCppDir, "ATLMFC", "INCLUDE");
                if (AtlMfcIncludeDir.Exists())
                {
                    IncludePaths.Add(AtlMfcIncludeDir.FullName);
                }
            }

            // Add the universal CRT paths
            if (!String.IsNullOrEmpty(UniversalCRTDir) && !String.IsNullOrEmpty(UniversalCRTVersion))
            {
                IncludePaths.Add(Path.Combine(UniversalCRTDir, "include", UniversalCRTVersion, "ucrt"));
            }

            // Add the NETFXSDK include path
            if (!String.IsNullOrEmpty(NetFXSDKDir))
            {
                IncludePaths.Add(Path.Combine(NetFXSDKDir, "include", "um"));                 // 2015
            }

            // Add the Windows SDK paths
            if (bSupportWindowsXP)
            {
                IncludePaths.Add(Path.Combine(WindowsSDKDir, "include"));
            }
            else if (Compiler >= WindowsCompiler.VisualStudio2015 && WindowsPlatform.bUseWindowsSDK10)
            {
                IncludePaths.Add(Path.Combine(WindowsSDKDir, "include", WindowsSDKLibVersion, "shared"));
                IncludePaths.Add(Path.Combine(WindowsSDKDir, "include", WindowsSDKLibVersion, "um"));
                IncludePaths.Add(Path.Combine(WindowsSDKDir, "include", WindowsSDKLibVersion, "winrt"));
            }
            else
            {
                IncludePaths.Add(Path.Combine(WindowsSDKDir, "include", "shared"));
                IncludePaths.Add(Path.Combine(WindowsSDKDir, "include", "um"));
                IncludePaths.Add(Path.Combine(WindowsSDKDir, "include", "winrt"));
            }

            // Add the existing include paths
            string ExistingIncludePaths = Environment.GetEnvironmentVariable("INCLUDE");

            if (ExistingIncludePaths != null)
            {
                IncludePaths.AddRange(ExistingIncludePaths.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
            }

            // Set the environment variable
            return(IncludePaths);
        }
示例#30
0
        private VCEnvironment(CPPTargetPlatform InPlatform, WindowsCompiler InCompiler, bool bSupportWindowsXP)
        {
            Platform = InPlatform;
            Compiler = InCompiler;

            // Get the Visual Studio install directory
            WindowsPlatform.TryGetVSInstallDir(Compiler, out VSInstallDir);

            // Get the Visual C++ compiler install directory.
            if (!WindowsPlatform.TryGetVCInstallDir(Compiler, out VCInstallDir))
            {
                throw new BuildException(WindowsPlatform.GetCompilerName(Compiler) + " must be installed in order to build this target.");
            }

            // Figure out the default toolchain directory. VS15 separates this out into separate directories, with platforms as subdirectories under that.
            DirectoryReference VCToolChainDir = null;

            if (Compiler == WindowsCompiler.VisualStudio2017)
            {
                string Version = File.ReadAllText(FileReference.Combine(VCInstallDir, "Auxiliary", "Build", "Microsoft.VCToolsVersion.default.txt").FullName).Trim();
                VCToolChainDir = DirectoryReference.Combine(VCInstallDir, "Tools", "MSVC", Version);
            }

            WindowsSDKDir          = FindWindowsSDKInstallationFolder(Platform, Compiler, bSupportWindowsXP);
            WindowsSDKLibVersion   = FindWindowsSDKLibVersion(WindowsSDKDir, bSupportWindowsXP);
            WindowsSDKExtensionDir = bSupportWindowsXP ? "" : FindWindowsSDKExtensionInstallationFolder(Compiler);
            NetFxSDKExtensionDir   = bSupportWindowsXP ? "" : FindNetFxSDKExtensionInstallationFolder(Compiler);
            WindowsSDKExtensionHeaderLibVersion = bSupportWindowsXP ? new Version(0, 0, 0, 0) : FindWindowsSDKExtensionLatestVersion(WindowsSDKExtensionDir);
            UniversalCRTDir     = bSupportWindowsXP ? "" : FindUniversalCRTInstallationFolder(Compiler);
            UniversalCRTVersion = bSupportWindowsXP ? "0.0.0.0" : FindUniversalCRTVersion(UniversalCRTDir);

            VCToolPath32 = GetVCToolPath32(Compiler, VCInstallDir, VCToolChainDir);
            VCToolPath64 = GetVCToolPath64(Compiler, VCInstallDir, VCToolChainDir);

            // Compile using 64 bit tools for 64 bit targets, and 32 for 32.
            DirectoryReference CompilerDir = (Platform == CPPTargetPlatform.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(InPlatform, CompilerDir);
            CLExeVersion         = FindCLExeVersion(CompilerPath.FullName);
            LinkerPath           = GetLinkerToolPath(InPlatform, LinkerDir);
            LibraryManagerPath   = GetLibraryLinkerToolPath(InPlatform, LinkerDir);
            ResourceCompilerPath = new FileReference(GetResourceCompilerToolPath(Platform, bSupportWindowsXP));

            // 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);
            }

            // Setup the INCLUDE environment variable
            List <string> IncludePaths = GetVisualCppIncludePaths(Compiler, VCInstallDir, VCToolChainDir, UniversalCRTDir, UniversalCRTVersion, NetFxSDKExtensionDir, WindowsSDKDir, WindowsSDKLibVersion, bSupportWindowsXP);

            if (InitialIncludePaths != null)
            {
                IncludePaths.Add(InitialIncludePaths);
            }
            Environment.SetEnvironmentVariable("INCLUDE", String.Join(";", IncludePaths));

            // Setup the LIB environment variable
            List <string> LibraryPaths = GetVisualCppLibraryPaths(Compiler, VCInstallDir, VCToolChainDir, UniversalCRTDir, UniversalCRTVersion, NetFxSDKExtensionDir, WindowsSDKDir, WindowsSDKLibVersion, Platform, bSupportWindowsXP);

            if (InitialLibraryPaths != null)
            {
                LibraryPaths.Add(InitialLibraryPaths);
            }
            Environment.SetEnvironmentVariable("LIB", String.Join(";", LibraryPaths));
        }
		public static bool HasVSInstalled(WindowsCompiler Toolchain)
		{
			string VSVersion = "";
			switch (Toolchain)
			{
				case WindowsCompiler.VisualStudio2013:
					VSVersion = "12.0";
					break;
				case WindowsCompiler.VisualStudio2015:
					VSVersion = "14.0";
					break;
				case WindowsCompiler.VisualStudio2017:
					VSVersion = "15.0";
					break;
				default:
					throw new NotSupportedException("Not supported compiler.");
			}

			RegistryKey BaseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
			object InstalledFlag = BaseKey.GetValue(string.Format(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevDiv\vs\Servicing\{0}\devenv\Install", VSVersion));
			if (InstalledFlag != null && InstalledFlag.ToString() == "1")
			{
				return true;
			}
			return false;
		}
示例#32
0
 public PVSToolChain(CppPlatform InCppPlatform, WindowsCompiler InCompiler) : base(InCppPlatform)
 {
     this.Compiler = InCompiler;
 }
示例#33
0
    private void CopyLibsToFinalDestination(TargetPlatformData TargetData, List <string> TargetConfigurations, WindowsCompiler TargetWindowsCompiler = WindowsCompiler.VisualStudio2015_DEPRECATED)
    {
        foreach (string TargetConfiguration in TargetConfigurations)
        {
            DirectoryReference OutputLibPath = GetPlatformLibDirectory(TargetData, TargetWindowsCompiler);
            string             OutputLibName = "";
            if (TargetData.Platform == UnrealTargetPlatform.Linux || TargetData.Platform == UnrealTargetPlatform.Mac)
            {
                OutputLibName = "lib";
            }

            OutputLibName += "hlslcc";

            if (TargetConfiguration == "Debug")
            {
                OutputLibName += "d";
            }

            if (TargetData.Platform == UnrealTargetPlatform.Win64)
            {
                OutputLibName += "_64";
            }

            OutputLibName += "." + GetPlatformLibExtension(TargetData);

            DirectoryReference ProjectDirectory = GetProjectDirectory(TargetData, TargetWindowsCompiler);
            string             SourceFileName   = "";
            if (TargetData.Platform == UnrealTargetPlatform.Win64)
            {
                SourceFileName = "hlslcc.lib";
            }
            else if (TargetData.Platform == UnrealTargetPlatform.Linux || TargetData.Platform == UnrealTargetPlatform.Mac)
            {
                SourceFileName = "libhlslcc.a";
            }

            FileReference SourceFile = FileReference.Combine(ProjectDirectory, TargetConfiguration, SourceFileName);
            FileReference DestFile   = FileReference.Combine(OutputLibPath, OutputLibName);
            FileReference.Copy(SourceFile, DestFile);

            if (TargetData.Platform == UnrealTargetPlatform.Win64)
            {
                FileReference PdbSourceFile = SourceFile.ChangeExtension("pdb");
                FileReference PdbDestFile   = DestFile.ChangeExtension("pdb");
                FileReference.Copy(PdbSourceFile, PdbDestFile);
            }
        }
    }
    private static void FindOutputFiles(HashSet<FileReference> OutputFiles, PhysXTargetLib TargetLib, TargetPlatformData TargetData, string TargetConfiguration, WindowsCompiler TargetWindowsCompiler = WindowsCompiler.VisualStudio2015)
	{
        string SearchPrefix = "*" + GetConfigurationSuffix(TargetConfiguration).ToUpper() + "*.";
        string DebugExtension = PlatformUsesDebugDatabase(TargetData) ? GetPlatformDebugDatabaseExtension(TargetData) : "";

        if (PlatformHasBinaries(TargetData))
		{
			DirectoryReference BinaryDir = GetPlatformBinaryDirectory(TargetData, TargetWindowsCompiler);
            FindOutputFilesHelper(OutputFiles, BinaryDir, SearchPrefix + GetPlatformBinaryExtension(TargetData), TargetLib);

			if (PlatformUsesDebugDatabase(TargetData))
			{
                FindOutputFilesHelper(OutputFiles, BinaryDir, SearchPrefix + DebugExtension, TargetLib);
			}
		}

		DirectoryReference LibDir = GetPlatformLibDirectory(TargetData, TargetWindowsCompiler);
        FindOutputFilesHelper(OutputFiles, LibDir, SearchPrefix + GetPlatformLibExtension(TargetData), TargetLib);

		if (PlatformUsesDebugDatabase(TargetData))
		{
            FindOutputFilesHelper(OutputFiles, LibDir, SearchPrefix + DebugExtension, TargetLib);
		}
	}
	private static UnrealBuildTool.DirectoryReference GetProjectDirectory(PhysXTargetLib TargetLib, TargetPlatformData TargetData, WindowsCompiler TargetWindowsCompiler = WindowsCompiler.VisualStudio2015)
	{
		UnrealBuildTool.DirectoryReference Directory = new UnrealBuildTool.DirectoryReference(GetTargetLibRootDirectory(TargetLib).ToString());

		switch(TargetLib)
		{
			case PhysXTargetLib.PhysX:
				Directory = UnrealBuildTool.DirectoryReference.Combine(Directory, "Source");
				break;
			case PhysXTargetLib.APEX:
				// APEX has its 'compiler' directory in a different location off the root of APEX
				break;
		}

		return UnrealBuildTool.DirectoryReference.Combine(Directory, "compiler", GetCMakeTargetDirectoryName(TargetData, TargetWindowsCompiler));
	}
示例#36
0
        /// <summary>
        /// Sets the Visual C++ LIB environment variable
        /// </summary>
        static List <string> GetVisualCppLibraryPaths(WindowsCompiler Compiler, DirectoryReference VisualCppDir, DirectoryReference VisualCppToolchainDir, string UniversalCRTDir, string UniversalCRTVersion, string NetFXSDKDir, string WindowsSDKDir, string WindowsSDKLibVersion, CPPTargetPlatform Platform, bool bSupportWindowsXP)
        {
            List <string> LibraryPaths = new List <string>();

            // Add the standard Visual C++ library paths
            if (Compiler == WindowsCompiler.VisualStudio2017)
            {
                if (Platform == CPPTargetPlatform.Win32)
                {
                    DirectoryReference StdLibraryDir = DirectoryReference.Combine(VisualCppToolchainDir, "lib", "x86");
                    if (StdLibraryDir.Exists())
                    {
                        LibraryPaths.Add(StdLibraryDir.FullName);
                    }
                }
                else
                {
                    DirectoryReference StdLibraryDir = DirectoryReference.Combine(VisualCppToolchainDir, "lib", "x64");
                    if (StdLibraryDir.Exists())
                    {
                        LibraryPaths.Add(StdLibraryDir.FullName);
                    }
                }
            }
            else
            {
                if (Platform == CPPTargetPlatform.Win32)
                {
                    DirectoryReference StdLibraryDir = DirectoryReference.Combine(VisualCppDir, "LIB");
                    if (StdLibraryDir.Exists())
                    {
                        LibraryPaths.Add(StdLibraryDir.FullName);
                    }
                    DirectoryReference AtlMfcLibraryDir = DirectoryReference.Combine(VisualCppDir, "ATLMFC", "LIB");
                    if (AtlMfcLibraryDir.Exists())
                    {
                        LibraryPaths.Add(AtlMfcLibraryDir.FullName);
                    }
                }
                else
                {
                    DirectoryReference StdLibraryDir = DirectoryReference.Combine(VisualCppDir, "LIB", "amd64");
                    if (StdLibraryDir.Exists())
                    {
                        LibraryPaths.Add(StdLibraryDir.FullName);
                    }
                    DirectoryReference AtlMfcLibraryDir = DirectoryReference.Combine(VisualCppDir, "ATLMFC", "LIB", "amd64");
                    if (AtlMfcLibraryDir.Exists())
                    {
                        LibraryPaths.Add(AtlMfcLibraryDir.FullName);
                    }
                }
            }

            // Add the Universal CRT
            if (!String.IsNullOrEmpty(UniversalCRTDir) && !String.IsNullOrEmpty(UniversalCRTVersion))
            {
                if (Platform == CPPTargetPlatform.Win32)
                {
                    LibraryPaths.Add(Path.Combine(UniversalCRTDir, "lib", UniversalCRTVersion, "ucrt", "x86"));
                }
                else
                {
                    LibraryPaths.Add(Path.Combine(UniversalCRTDir, "lib", UniversalCRTVersion, "ucrt", "x64"));
                }
            }

            // Add the NETFXSDK include path
            if (!String.IsNullOrEmpty(NetFXSDKDir))
            {
                if (Platform == CPPTargetPlatform.Win32)
                {
                    LibraryPaths.Add(Path.Combine(NetFXSDKDir, "lib", "um", "x86"));
                }
                else
                {
                    LibraryPaths.Add(Path.Combine(NetFXSDKDir, "lib", "um", "x64"));
                }
            }

            // Add the standard Windows SDK paths
            if (Platform == CPPTargetPlatform.Win32)
            {
                if (bSupportWindowsXP)
                {
                    LibraryPaths.Add(Path.Combine(WindowsSDKDir, "Lib"));
                }
                else
                {
                    LibraryPaths.Add(Path.Combine(WindowsSDKDir, "lib", WindowsSDKLibVersion, "um", "x86"));
                }
            }
            else
            {
                if (bSupportWindowsXP)
                {
                    LibraryPaths.Add(Path.Combine(WindowsSDKDir, "Lib", "x64"));
                }
                else
                {
                    LibraryPaths.Add(Path.Combine(WindowsSDKDir, "lib", WindowsSDKLibVersion, "um", "x64"));
                }
            }

            // Add the existing library paths
            string ExistingLibraryPaths = Environment.GetEnvironmentVariable("LIB");

            if (ExistingLibraryPaths != null)
            {
                LibraryPaths.AddRange(ExistingLibraryPaths.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
            }

            return(LibraryPaths);
        }
	private static UnrealBuildTool.FileReference GetTargetLibSolutionFileName(PhysXTargetLib TargetLib, TargetPlatformData TargetData, WindowsCompiler TargetWindowsCompiler)
	{
		UnrealBuildTool.DirectoryReference Directory = GetProjectDirectory(TargetLib, TargetData, TargetWindowsCompiler);
		return UnrealBuildTool.FileReference.Combine(Directory, GetTargetLibSolutionName(TargetLib));
	}
		/// <summary>
		/// Read the Visual C++ install directory for the given version.
		/// </summary>
		/// <param name="Compiler">Version of the toolchain to look for.</param>
		/// <param name="InstallDir">On success, the directory that Visual C++ is installed to.</param>
		/// <returns>True if the directory was found, false otherwise.</returns>
		public static bool TryGetVCInstallDir(WindowsCompiler Compiler, out DirectoryReference InstallDir)
		{
			if (BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Win64 && BuildHostPlatform.Current.Platform != UnrealTargetPlatform.Win32)
			{
				InstallDir = null;
				return false;
			}

			if(Compiler == WindowsCompiler.VisualStudio2013)
			{
				return TryReadInstallDirRegistryKey32("Microsoft\\VisualStudio\\SxS\\VC7", "12.0", out InstallDir);
			}
			else if(Compiler == WindowsCompiler.VisualStudio2015)
			{
				return TryReadInstallDirRegistryKey32("Microsoft\\VisualStudio\\SxS\\VC7", "14.0", out InstallDir);
			}
			else if(Compiler == WindowsCompiler.VisualStudio2017)
			{
				// VS15Preview installs the compiler under the IDE directory, and does not register it as a standalone component. Check just in case this changes 
				// for compat in future since it's more specific.
				if(TryReadInstallDirRegistryKey32("Microsoft\\VisualStudio\\SxS\\VC7", "15.0", out InstallDir))
				{
					return true;
				}

				// Otherwise just check under the VS folder...
				DirectoryReference VSInstallDir;
				if(TryGetVSInstallDir(Compiler, out VSInstallDir))
				{
					FileReference CompilerPath = FileReference.Combine(VSInstallDir, "Common7", "IDE", "VC", "bin", "cl.exe");
					if(CompilerPath.Exists())
					{
						InstallDir = CompilerPath.Directory.ParentDirectory;
						return true;
					}
				}
				return false;
			}
			else
			{
				throw new BuildException("Invalid compiler version ({0})", Compiler);
			}
		}
	private static string GetMsBuildExe(WindowsCompiler Version)
	{
		string VisualStudioToolchainVersion = "";
		switch (Version)
		{
			case WindowsCompiler.VisualStudio2013:
				VisualStudioToolchainVersion = "12.0";
				break;
			case WindowsCompiler.VisualStudio2015:
				VisualStudioToolchainVersion = "14.0";
				break;
		}
		string ProgramFilesPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
		string MSBuildPath = Path.Combine(ProgramFilesPath, "MSBuild", VisualStudioToolchainVersion, "Bin", "MSBuild.exe");
		if (File.Exists(MSBuildPath))
		{
			return MSBuildPath;
		}
		return null;
	}
示例#40
0
        /**
         * Returns VisualStudio common tools path for given compiler.
         * 
         * @param Compiler Compiler for which to return tools path.
         * 
         * @return Common tools path.
         */
        public static string GetVSComnToolsPath(WindowsCompiler Compiler)
        {
            int VSVersion;

			switch(Compiler)
			{
				case WindowsCompiler.VisualStudio2012:
					VSVersion = 11;
					break;
				case WindowsCompiler.VisualStudio2013:
					VSVersion = 12;
					break;
				case WindowsCompiler.VisualStudio2015:
					VSVersion = 14;
					break;
				default:
					throw new NotSupportedException("Not supported compiler.");
			}

            string[] PossibleRegPaths = new string[] {
                @"Wow6432Node\Microsoft\VisualStudio",	// Non-express VS2013 on 64-bit machine.
                @"Microsoft\VisualStudio",				// Non-express VS2013 on 32-bit machine.
                @"Wow6432Node\Microsoft\WDExpress",		// Express VS2013 on 64-bit machine.
                @"Microsoft\WDExpress"					// Express VS2013 on 32-bit machine.
            };

            string VSPath = null;

            foreach(var PossibleRegPath in PossibleRegPaths)
            {
                VSPath = (string) Registry.GetValue(string.Format(@"HKEY_LOCAL_MACHINE\SOFTWARE\{0}\{1}.0", PossibleRegPath, VSVersion), "InstallDir", null);

                if(VSPath != null)
                {
                    break;
                }
            }

            if(VSPath == null)
            {
                return null;
            }

            return new DirectoryInfo(Path.Combine(VSPath, "..", "Tools")).FullName;
        }
	private static void BuildXboxTarget(PhysXTargetLib TargetLib, TargetPlatformData TargetData, List<string> TargetConfigurations, WindowsCompiler TargetWindowsCompiler = WindowsCompiler.VisualStudio2015)
	{
		if (TargetData.Platform != UnrealTargetPlatform.XboxOne)
		{
			return;
		}

		string SolutionFile = GetTargetLibSolutionFileName(TargetLib, TargetData, TargetWindowsCompiler).ToString();
		string MSBuildExe = GetMsBuildExe(TargetData);

		if (!FileExists(SolutionFile))
		{
			throw new AutomationException(String.Format("Unabled to build Solution {0}. Solution file not found.", SolutionFile));
		}
		if (String.IsNullOrEmpty(MSBuildExe))
		{
			throw new AutomationException(String.Format("Unabled to build Solution {0}. msbuild.exe not found.", SolutionFile));
		}

		string AdditionalProperties = "";
		string AutoSDKPropsPath = Environment.GetEnvironmentVariable("XboxOneAutoSDKProp");
		if (AutoSDKPropsPath != null && AutoSDKPropsPath.Length > 0)
		{
			AdditionalProperties += String.Format(";CustomBeforeMicrosoftCommonProps={0}", AutoSDKPropsPath);
		}
		string XboxCMakeModulesPath = Path.Combine(PhysXSourceRootDirectory.FullName, "Externals", "CMakeModules", "XboxOne", "Microsoft.Cpp.Durango.user.props");
		if (File.Exists(XboxCMakeModulesPath))
		{
			AdditionalProperties += String.Format(";ForceImportBeforeCppTargets={0}", XboxCMakeModulesPath);
		}

		foreach (string BuildConfig in TargetConfigurations)
		{
			string CmdLine = String.Format("\"{0}\" /t:build /p:Configuration={1};Platform=Durango{2}", SolutionFile, BuildConfig, AdditionalProperties);
			RunAndLog(BuildCommand.CmdEnv, MSBuildExe, CmdLine);
		}
	}
	private static DirectoryReference GetPlatformBinaryDirectory(TargetPlatformData TargetData, WindowsCompiler TargetWindowsCompiler)
	{
		string VisualStudioName = string.Empty;
		string ArchName = string.Empty;

		if (DoesPlatformUseMSBuild(TargetData))
		{
			switch (TargetWindowsCompiler)
			{
				case WindowsCompiler.VisualStudio2013:
					VisualStudioName = "VS2013";
					break;
				case WindowsCompiler.VisualStudio2015:
					VisualStudioName = "VS2015";
					break;
				default:
					throw new AutomationException(String.Format("Unsupported visual studio compiler '{0}' supplied to GetOutputBinaryDirectory", TargetWindowsCompiler));
			}
		}

		switch (TargetData.Platform)
		{
			case UnrealTargetPlatform.Win32:
				ArchName = "Win32";
				break;
			case UnrealTargetPlatform.Win64:
				ArchName = "Win64";
				break;
			case UnrealTargetPlatform.Mac:
				ArchName = "Mac";
				break;
			default:
				throw new AutomationException(String.Format("Unsupported platform '{0}' supplied to GetOutputBinaryDirectory", TargetData.ToString()));
		}

		return UnrealBuildTool.DirectoryReference.Combine(RootOutputBinaryDirectory, ArchName, VisualStudioName);
	}
示例#43
0
 /// <summary>
 /// Tries to get the directory for an installed Visual Studio version
 /// </summary>
 /// <param name="Compiler">The compiler version</param>
 /// <param name="InstallDir">Receives the install directory on success</param>
 /// <returns>True if successful</returns>
 public static bool TryGetVSInstallDir(WindowsCompiler Compiler, out DirectoryReference InstallDir)
 {
     return(WindowsPlatform.TryGetVSInstallDir(Compiler, out InstallDir));
 }
示例#44
0
    private static DirectoryReference GetPlatformLibDirectory(TargetPlatformData TargetData, WindowsCompiler TargetWindowsCompiler)
    {
        string VisualStudioName = string.Empty;
        string ArchName         = string.Empty;

        if (DoesPlatformUseMSBuild(TargetData))
        {
            switch (TargetWindowsCompiler)
            {
            case WindowsCompiler.VisualStudio2015_DEPRECATED:
                VisualStudioName = "VS2015";
                break;

            default:
                throw new AutomationException(String.Format("Unsupported visual studio compiler '{0}' supplied to GetOutputLibDirectory", TargetWindowsCompiler));
            }
        }

        if (TargetData.Platform == UnrealTargetPlatform.Win64)
        {
            ArchName = "Win64";
        }
        else if (TargetData.Platform == UnrealTargetPlatform.Linux)
        {
            ArchName = "Linux/" + TargetData.Architecture;
        }
        else if (TargetData.Platform == UnrealTargetPlatform.Mac)
        {
            ArchName = "Mac";
        }
        else
        {
            throw new AutomationException(String.Format("Unsupported platform '{0}' supplied to GetOutputLibDirectory", TargetData.ToString()));
        }

        return(DirectoryReference.Combine(RootOutputLibDirectory, ArchName, VisualStudioName));
    }
示例#45
0
        /// <returns>The path to Windows SDK directory for the specified version.</returns>
        private static string FindWindowsSDKInstallationFolder(CPPTargetPlatform InPlatform, WindowsCompiler InCompiler, bool bSupportWindowsXP)
        {
            // When targeting Windows XP on Visual Studio 2012+, we need to point at the older Windows SDK 7.1A that comes
            // installed with Visual Studio 2012 Update 1. (http://blogs.msdn.com/b/vcblog/archive/2012/10/08/10357555.aspx)
            string Version;

            if (bSupportWindowsXP)
            {
                Version = "v7.1A";
            }
            else
            {
                switch (InCompiler)
                {
                case WindowsCompiler.VisualStudio2017:
                case WindowsCompiler.VisualStudio2015:
                    if (WindowsPlatform.bUseWindowsSDK10)
                    {
                        Version = "v10.0";
                    }
                    else
                    {
                        Version = "v8.1";
                    }
                    break;

                case WindowsCompiler.VisualStudio2013:
                    Version = "v8.1";
                    break;

                default:
                    throw new BuildException("Unexpected compiler setting when trying to determine Windows SDK folder");
                }
            }

            // Based on VCVarsQueryRegistry
            string FinalResult = null;

            foreach (string IndividualVersion in Version.Split('|'))
            {
                object Result = Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Microsoft SDKs\Windows\" + IndividualVersion, "InstallationFolder", null)
                                ?? Microsoft.Win32.Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\" + IndividualVersion, "InstallationFolder", null)
                                ?? Microsoft.Win32.Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\" + IndividualVersion, "InstallationFolder", null);

                if (Result != null)
                {
                    FinalResult = (string)Result;
                    break;
                }
            }
            if (FinalResult == null)
            {
                throw new BuildException("Windows SDK {0} must be installed in order to build this target.", Version);
            }

            return(FinalResult);
        }
		/// <summary>
		/// Returns the human-readable name of the given compiler
		/// </summary>
		/// <param name="Compiler">The compiler value</param>
		/// <returns>Name of the compiler</returns>
		public static string GetCompilerName(WindowsCompiler Compiler)
		{
			switch(Compiler)
			{
				case WindowsCompiler.VisualStudio2013:
					return "Visual Studio 2013";
				case WindowsCompiler.VisualStudio2015:
					return "Visual Studio 2015";
				case WindowsCompiler.VisualStudio2017:
					return "Visual Studio \"15\"";
				default:
					return Compiler.ToString();
			}
		}