Пример #1
0
        private VCEnvironment(CPPTargetPlatform InPlatform)
        {
            Platform = InPlatform;

            // If Visual Studio is not installed, the Windows SDK path will be used, which also happens to be the same
            // directory. (It installs the toolchain into the folder where Visual Studio would have installed it to).
            BaseVSToolPath = WindowsPlatform.GetVSComnToolsPath();
            if (string.IsNullOrEmpty(BaseVSToolPath))
            {
                throw new BuildException("Visual Studio 2012, 2013 or 2015 must be installed in order to build this target.");
            }

            WindowsSDKDir          = FindWindowsSDKInstallationFolder(Platform);
            WindowsSDKExtensionDir = FindWindowsSDKExtensionInstallationFolder();
            NetFxSDKExtensionDir   = FindNetFxSDKExtensionInstallationFolder();
            WindowsSDKExtensionHeaderLibVersion = FindWindowsSDKExtensionLatestVersion(WindowsSDKExtensionDir);
            PlatformVSToolPath   = GetPlatformVSToolPath(Platform, BaseVSToolPath);
            CompilerPath         = GetCompilerToolPath(PlatformVSToolPath);
            CLExeVersion         = FindCLExeVersion(CompilerPath);
            LinkerPath           = GetLinkerToolPath(PlatformVSToolPath);
            LibraryLinkerPath    = GetLibraryLinkerToolPath(PlatformVSToolPath);
            ResourceCompilerPath = GetResourceCompilerToolPath(Platform);

            // We ensure an extra trailing slash because of a user getting an odd error where the paths seemed to get concatenated wrongly:
            //
            // C:\Programme\Microsoft Visual Studio 12.0\Common7\Tools../../VC/bin/x86_amd64/vcvarsx86_amd64.bat
            //
            // https://answers.unrealengine.com/questions/233640/unable-to-create-project-files-for-48-preview-3.html
            //
            bool   bUse64BitCompiler             = Platform == CPPTargetPlatform.Win64 || Platform == CPPTargetPlatform.UWP;
            string BaseToolPathWithTrailingSlash = BaseVSToolPath.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar;
            string VCVarsBatchFile = Path.Combine(BaseToolPathWithTrailingSlash, bUse64BitCompiler ? @"..\..\VC\bin\x86_amd64\vcvarsx86_amd64.bat" : "vsvars32.bat");

            if (Platform == CPPTargetPlatform.UWP && UWPPlatform.bBuildForStore)
            {
                Utils.SetEnvironmentVariablesFromBatchFile(VCVarsBatchFile, "store");
            }
            else
            {
                Utils.SetEnvironmentVariablesFromBatchFile(VCVarsBatchFile);
            }

            // When targeting Windows XP on Visual Studio 2012+, we need to override the Windows SDK include and lib path set
            // by the batch file environment (http://blogs.msdn.com/b/vcblog/archive/2012/10/08/10357555.aspx)
            if (WindowsPlatform.IsWindowsXPSupported())
            {
                // Lib and bin folders have a x64 subfolder for 64 bit development.
                var ConfigSuffix = (Platform == CPPTargetPlatform.Win64) ? "\\x64" : "";

                Environment.SetEnvironmentVariable("PATH", Utils.ResolveEnvironmentVariable(WindowsSDKDir + "bin" + ConfigSuffix + ";%PATH%"));
                Environment.SetEnvironmentVariable("LIB", Utils.ResolveEnvironmentVariable(WindowsSDKDir + "lib" + ConfigSuffix + ";%LIB%"));
                Environment.SetEnvironmentVariable("INCLUDE", Utils.ResolveEnvironmentVariable(WindowsSDKDir + "include;%INCLUDE%"));
            }
        }
Пример #2
0
        private VCEnvironment(CPPTargetPlatform InPlatform)
        {
            Platform = InPlatform;

            // If Visual Studio is not installed, the Windows SDK path will be used, which also happens to be the same
            // directory. (It installs the toolchain into the folder where Visual Studio would have installed it to).
            BaseVSToolPath = WindowsPlatform.GetVSComnToolsPath();
            if (string.IsNullOrEmpty(BaseVSToolPath))
            {
                throw new BuildException("Visual Studio 2012, 2013 or 2015 must be installed in order to build this target.");
            }

            WindowsSDKDir          = FindWindowsSDKInstallationFolder(Platform);
            WindowsSDKExtensionDir = FindWindowsSDKExtensionInstallationFolder();
            NetFxSDKExtensionDir   = FindNetFxSDKExtensionInstallationFolder();
            WindowsSDKExtensionHeaderLibVersion = FindWindowsSDKExtensionLatestVersion(WindowsSDKExtensionDir);
            PlatformVSToolPath   = GetPlatformVSToolPath(Platform, BaseVSToolPath);
            CompilerPath         = GetCompilerToolPath(PlatformVSToolPath);
            CLExeVersion         = FindCLExeVersion(CompilerPath);
            LinkerPath           = GetLinkerToolPath(PlatformVSToolPath);
            LibraryLinkerPath    = GetLibraryLinkerToolPath(PlatformVSToolPath);
            ResourceCompilerPath = GetResourceCompilerToolPath(Platform);

            var VCVarsBatchFile = Path.Combine(BaseVSToolPath,
                                               (Platform == CPPTargetPlatform.Win64 || Platform == CPPTargetPlatform.UWP) ? "../../VC/bin/x86_amd64/vcvarsx86_amd64.bat" : "vsvars32.bat");

            if (Platform == CPPTargetPlatform.UWP && UWPPlatform.bBuildForStore)
            {
                Utils.SetEnvironmentVariablesFromBatchFile(VCVarsBatchFile, "store");
            }
            else
            {
                Utils.SetEnvironmentVariablesFromBatchFile(VCVarsBatchFile);
            }

            // When targeting Windows XP on Visual Studio 2012+, we need to override the Windows SDK include and lib path set
            // by the batch file environment (http://blogs.msdn.com/b/vcblog/archive/2012/10/08/10357555.aspx)
            if (WindowsPlatform.IsWindowsXPSupported())
            {
                // Lib and bin folders have a x64 subfolder for 64 bit development.
                var ConfigSuffix = (Platform == CPPTargetPlatform.Win64) ? "\\x64" : "";

                Environment.SetEnvironmentVariable("PATH", Utils.ResolveEnvironmentVariable(WindowsSDKDir + "bin" + ConfigSuffix + ";%PATH%"));
                Environment.SetEnvironmentVariable("LIB", Utils.ResolveEnvironmentVariable(WindowsSDKDir + "lib" + ConfigSuffix + ";%LIB%"));
                Environment.SetEnvironmentVariable("INCLUDE", Utils.ResolveEnvironmentVariable(WindowsSDKDir + "include;%INCLUDE%"));
            }
        }
Пример #3
0
        /**
         * Initializes environment variables required by toolchain. Different for 32 and 64 bit.
         */
        static void InitializeEnvironmentVariables(CPPTargetPlatform Platform)
        {
            if (!bAreEnvironmentVariablesAlreadyInitialized)
            {
                string VCVarsBatchFile = "";

                // Grab path to Visual Studio binaries from the system environment
                string BaseVSToolPath = WindowsPlatform.GetVSComnToolsPath(WindowsCompiler.VisualStudio2012);
                if (string.IsNullOrEmpty(BaseVSToolPath))
                {
                    BaseVSToolPath = "C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/Tools/";
                    if (Directory.Exists("C:/Program Files (x86)/Microsoft Visual Studio 11.0/Common7/Tools/") == false)
                    {
                        throw new BuildException("Visual Studio 2012 must be installed in order to build this target.");
                    }
                }

                // 64 bit tool chain.
                if (Platform == CPPTargetPlatform.WinRT_ARM)
                {
                    VCVarsBatchFile = Path.Combine(BaseVSToolPath, "../../VC/bin/x86_arm/vcvarsx86_arm.bat");
                }
                else
                {
                    VCVarsBatchFile = Path.Combine(BaseVSToolPath, "../../VC/bin/x86_amd64/vcvarsx86_amd64.bat");
                }

                // @todo: This is failing when building the Win32 target through NMake!!!!
                Utils.SetEnvironmentVariablesFromBatchFile(VCVarsBatchFile);

                if (WinRTPlatform.ShouldCompileWinRT() == true)
                {
                    string EnvVarName = Utils.ResolveEnvironmentVariable(WindowsSDKDir + "Windows Metadata" + ";%LIBPATH%");
                    Environment.SetEnvironmentVariable("LIBPATH", EnvVarName);
                }

                bAreEnvironmentVariablesAlreadyInitialized = true;
            }
        }