Beispiel #1
0
        public static string GetWindowsResourceCompiler(this DevEnv visualVersion, Platform platform)
        {
            KitsRootEnum kitsRoot = KitsRootPaths.GetUseKitsRootForDevEnv(visualVersion);

            string targetPlatform = (platform == Platform.win64) ? "x64" : "x86";

            switch (kitsRoot)
            {
            case KitsRootEnum.KitsRoot:
                return(Path.Combine(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot), "bin", targetPlatform, "rc.exe"));

            case KitsRootEnum.KitsRoot81:
                return(Path.Combine(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81), "bin", targetPlatform, "rc.exe"));

            case KitsRootEnum.KitsRoot10:
            {
                string kitsRootPath;
                if (KitsRootPaths.GetWindowsTargetPlatformVersionForDevEnv(visualVersion) <= Options.Vc.General.WindowsTargetPlatformVersion.v10_0_10240_0)
                {
                    kitsRootPath = KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81);
                }
                else
                {
                    kitsRootPath = KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot10);
                }
                return(Path.Combine(kitsRootPath, "bin", targetPlatform, "rc.exe"));
            }

            default:
                throw new NotImplementedException("No WindowsResourceCompiler associated with " + kitsRoot);
            }
        }
Beispiel #2
0
        public static string GetWindowsExecutablePath(this DevEnv visualVersion, Platform platform)
        {
            KitsRootEnum kitsRoot = KitsRootPaths.GetUseKitsRootForDevEnv(visualVersion);

            string targetPlatform = (platform == Platform.win64) ? "x64" : "x86";

            var paths = new List <string>();

            paths.Add(visualVersion.GetVisualStudioBinPath(platform));

            switch (kitsRoot)
            {
            case KitsRootEnum.KitsRoot:
                paths.Add(Path.Combine(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot), "bin", targetPlatform));
                break;

            case KitsRootEnum.KitsRoot81:
                paths.Add(Path.Combine(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81), "bin", targetPlatform));
                break;

            case KitsRootEnum.KitsRoot10:
                paths.Add(Path.Combine(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot10), "bin", targetPlatform));
                if (KitsRootPaths.GetWindowsTargetPlatformVersionForDevEnv(visualVersion) <= Options.Vc.General.WindowsTargetPlatformVersion.v10_0_10240_0)
                {
                    paths.Add(Path.Combine(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81), "bin", targetPlatform));
                }
                break;

            default:
                throw new NotImplementedException("No GetWindowsExecutablePath associated with " + kitsRoot);
            }

            paths.Add("$(PATH)");
            return(string.Join(";", paths));
        }
Beispiel #3
0
        public static string GetWindowsIncludePath(this DevEnv visualVersion)
        {
            string visualStudioDir     = Util.EnsureTrailingSeparator(visualVersion.GetVisualStudioVCRootPath());
            string visualStudioInclude = string.Format(@"{0}include;{0}atlmfc\include", visualStudioDir);

            KitsRootEnum useKitsRoot = KitsRootPaths.GetUseKitsRootForDevEnv(visualVersion);

            switch (useKitsRoot)
            {
            case KitsRootEnum.KitsRoot:
            {
                string kitsRoot = Util.EnsureTrailingSeparator(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot));
                return(String.Format(@"{0};{1}Include\shared;{1}Include\um;{1}Include\WinRT;", visualStudioInclude, kitsRoot));
            }

            case KitsRootEnum.KitsRoot81:
            {
                string kitsRoot = Util.EnsureTrailingSeparator(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81));
                return(String.Format(@"{0};{1}Include\shared;{1}Include\um;{1}Include\WinRT;", visualStudioInclude, kitsRoot));
            }

            case KitsRootEnum.KitsRoot10:
            {
                string kitsRoot10 = Util.EnsureTrailingSeparator(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot10));
                Options.Vc.General.WindowsTargetPlatformVersion windowsTargetPlatformVersion = KitsRootPaths.GetWindowsTargetPlatformVersionForDevEnv(visualVersion);
                string platformVersion = windowsTargetPlatformVersion.ToVersionString();
                var    paths           = new List <string> {
                    $@"{visualStudioInclude}",
                    $@"{kitsRoot10}Include\{platformVersion}\um",             // $(UM_IncludePath)
                    $@"{kitsRoot10}Include\{platformVersion}\shared",         // $(KIT_SHARED_IncludePath)
                    $@"{kitsRoot10}Include\{platformVersion}\winrt",          // $(WinRT_IncludePath)
                    $@"{kitsRoot10}Include\{platformVersion}\ucrt",           // $(UniversalCRT_IncludePath)
                };

                if (windowsTargetPlatformVersion <= Options.Vc.General.WindowsTargetPlatformVersion.v10_0_10240_0)
                {
                    //
                    // Version 10.0.10240.0 and below only contain the UCRT libraries
                    // and headers, not the usual Win32 stuff. So if we are using
                    // version 10240 or older, also include the Windows 8.1 paths so we
                    // have a complete Win32 support.
                    //

                    string kitsRoot81 = Util.EnsureTrailingSeparator(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81));
                    paths.AddRange(new[]
                        {
                            $@"{kitsRoot81}Include\um",
                            $@"{kitsRoot81}Include\shared"
                        });
                }

                return(string.Join(";", paths));
            }

            default:
                throw new NotImplementedException("No WindowsResourceCompiler associated with " + visualVersion);
            }
        }
        public static string GetWindowsResourceCompiler(this DevEnv visualVersion, Platform platform)
        {
            KitsRootEnum kitsRoot = KitsRootPaths.GetUseKitsRootForDevEnv(visualVersion);

            string targetPlatform = (platform == Platform.win64) ? "x64" : "x86";

            switch (kitsRoot)
            {
            case KitsRootEnum.KitsRoot:
                return(Path.Combine(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot), "bin", targetPlatform, "rc.exe"));

            case KitsRootEnum.KitsRoot81:
                return(Path.Combine(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81), "bin", targetPlatform, "rc.exe"));

            case KitsRootEnum.KitsRoot10:
            {
                Options.Vc.General.WindowsTargetPlatformVersion windowsTargetPlatformVersion = KitsRootPaths.GetWindowsTargetPlatformVersionForDevEnv(visualVersion);
                if (windowsTargetPlatformVersion <= Options.Vc.General.WindowsTargetPlatformVersion.v10_0_10240_0)
                {
                    string kitsRoot81Path = KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81);
                    return(Path.Combine(kitsRoot81Path, "bin", targetPlatform, "rc.exe"));
                }

                string kitsRoot10Path  = KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot10);
                string platformVersion = windowsTargetPlatformVersion.ToVersionString();

                // First, try WindowsSdkVerBinPath
                string candidateWindowsSdkVerBinPath = Path.Combine(kitsRoot10Path, "bin", platformVersion, targetPlatform, "rc.exe");
                if (File.Exists(candidateWindowsSdkVerBinPath))
                {
                    return(candidateWindowsSdkVerBinPath);
                }

                // If it didn't contain rc.exe, fallback to WindowsSdkBinPath
                return(Path.Combine(kitsRoot10Path, "bin", targetPlatform, "rc.exe"));
            }

            default:
                throw new NotImplementedException("No WindowsResourceCompiler associated with " + kitsRoot);
            }
        }
Beispiel #5
0
            public CompilerSettings GetMasterCompilerSettings(
                IDictionary <string, CompilerSettings> masterCompilerSettings,
                string compilerName,
                DevEnv devEnv,
                string projectRootPath,
                Options.Vc.General.PlatformToolset platformToolset,
                bool useCCompiler
                )
            {
                CompilerSettings compilerSettings;

                if (masterCompilerSettings.ContainsKey(compilerName))
                {
                    compilerSettings = masterCompilerSettings[compilerName];
                }
                else
                {
                    DevEnv?compilerDevEnv      = null;
                    string platformToolSetPath = null;
                    string pathToCompiler      = null;
                    string compilerExeName     = null;
                    var    compilerFamily      = Sharpmake.CompilerFamily.Auto;
                    var    fastBuildSettings   = PlatformRegistry.Get <IFastBuildCompilerSettings>(Platform.win64);

                    switch (platformToolset)
                    {
                    case Options.Vc.General.PlatformToolset.Default:
                        compilerDevEnv = devEnv;
                        break;

                    case Options.Vc.General.PlatformToolset.v100:
                        compilerDevEnv = DevEnv.vs2010;
                        break;

                    case Options.Vc.General.PlatformToolset.v110:
                    case Options.Vc.General.PlatformToolset.v110_xp:
                        compilerDevEnv = DevEnv.vs2012;
                        break;

                    case Options.Vc.General.PlatformToolset.v120:
                    case Options.Vc.General.PlatformToolset.v120_xp:
                        compilerDevEnv = DevEnv.vs2013;
                        break;

                    case Options.Vc.General.PlatformToolset.v140:
                    case Options.Vc.General.PlatformToolset.v140_xp:
                        compilerDevEnv = DevEnv.vs2015;
                        break;

                    case Options.Vc.General.PlatformToolset.v141:
                    case Options.Vc.General.PlatformToolset.v141_xp:
                        compilerDevEnv = DevEnv.vs2017;
                        break;

                    case Options.Vc.General.PlatformToolset.v142:
                        compilerDevEnv = DevEnv.vs2019;
                        break;

                    case Options.Vc.General.PlatformToolset.LLVM_vs2012:
                    case Options.Vc.General.PlatformToolset.LLVM_vs2014:
                    case Options.Vc.General.PlatformToolset.LLVM:

                        platformToolSetPath = ClangForWindows.Settings.LLVMInstallDir;
                        pathToCompiler      = Path.Combine(platformToolSetPath, "bin");
                        compilerExeName     = "clang-cl.exe";

                        var compilerFamilyKey = new FastBuildWindowsCompilerFamilyKey(devEnv, platformToolset);
                        if (!fastBuildSettings.CompilerFamily.TryGetValue(compilerFamilyKey, out compilerFamily))
                        {
                            compilerFamily = Sharpmake.CompilerFamily.ClangCl;
                        }

                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }

                    if (compilerDevEnv.HasValue)
                    {
                        platformToolSetPath = Path.Combine(compilerDevEnv.Value.GetVisualStudioDir(), "VC");
                        pathToCompiler      = compilerDevEnv.Value.GetVisualStudioBinPath(Platform.win64);
                        compilerExeName     = "cl.exe";

                        var compilerFamilyKey = new FastBuildWindowsCompilerFamilyKey(devEnv, platformToolset);
                        if (!fastBuildSettings.CompilerFamily.TryGetValue(compilerFamilyKey, out compilerFamily))
                        {
                            compilerFamily = Sharpmake.CompilerFamily.MSVC;
                        }
                    }

                    Strings extraFiles = new Strings();
                    {
                        Strings userExtraFiles;
                        if (fastBuildSettings.ExtraFiles.TryGetValue(devEnv, out userExtraFiles))
                        {
                            extraFiles.AddRange(userExtraFiles);
                        }
                    }

                    if (compilerDevEnv.HasValue)
                    {
                        extraFiles.Add(
                            @"$ExecutableRootPath$\c1.dll",
                            @"$ExecutableRootPath$\c1xx.dll",
                            @"$ExecutableRootPath$\c2.dll",
                            @"$ExecutableRootPath$\mspdbcore.dll",
                            @"$ExecutableRootPath$\mspdbsrv.exe",
                            @"$ExecutableRootPath$\1033\clui.dll"
                            );

                        switch (devEnv)
                        {
                        case DevEnv.vs2012:
                        {
                            extraFiles.Add(
                                @"$ExecutableRootPath$\c1ast.dll",
                                @"$ExecutableRootPath$\c1xxast.dll",
                                @"$ExecutableRootPath$\mspft110.dll",
                                @"$ExecutableRootPath$\msobj110.dll",
                                @"$ExecutableRootPath$\mspdb110.dll",
                                Path.Combine(platformToolSetPath, @"redist\x64\Microsoft.VC110.CRT\msvcp110.dll"),
                                Path.Combine(platformToolSetPath, @"redist\x64\Microsoft.VC110.CRT\msvcr110.dll"),
                                Path.Combine(platformToolSetPath, @"redist\x64\Microsoft.VC110.CRT\vccorlib110.dll")
                                );
                        }
                        break;

                        case DevEnv.vs2013:
                        {
                            extraFiles.Add(
                                @"$ExecutableRootPath$\c1ast.dll",
                                @"$ExecutableRootPath$\c1xxast.dll",
                                @"$ExecutableRootPath$\mspft120.dll",
                                @"$ExecutableRootPath$\msobj120.dll",
                                @"$ExecutableRootPath$\mspdb120.dll",
                                Path.Combine(platformToolSetPath, @"redist\x64\Microsoft.VC120.CRT\msvcp120.dll"),
                                Path.Combine(platformToolSetPath, @"redist\x64\Microsoft.VC120.CRT\msvcr120.dll"),
                                Path.Combine(platformToolSetPath, @"redist\x64\Microsoft.VC120.CRT\vccorlib120.dll")
                                );
                        }
                        break;

                        case DevEnv.vs2015:
                        case DevEnv.vs2017:
                        case DevEnv.vs2019:
                        {
                            string systemDllPath = FastBuildSettings.SystemDllRoot;
                            if (systemDllPath == null)
                            {
                                var    windowsTargetPlatformVersion = KitsRootPaths.GetWindowsTargetPlatformVersionForDevEnv(devEnv);
                                string redistDirectory;
                                if (windowsTargetPlatformVersion <= Options.Vc.General.WindowsTargetPlatformVersion.v10_0_17134_0)
                                {
                                    redistDirectory = @"Redist\ucrt\DLLs\x64\";
                                }
                                else
                                {
                                    redistDirectory = $@"Redist\{windowsTargetPlatformVersion.ToVersionString()}\ucrt\DLLs\x64\";
                                }

                                systemDllPath = Path.Combine(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot10), redistDirectory);
                            }

                            if (!Path.IsPathRooted(systemDllPath))
                            {
                                systemDllPath = Util.SimplifyPath(Path.Combine(projectRootPath, systemDllPath));
                            }

                            extraFiles.Add(
                                @"$ExecutableRootPath$\msobj140.dll",
                                @"$ExecutableRootPath$\mspft140.dll",
                                @"$ExecutableRootPath$\mspdb140.dll"
                                );

                            if (devEnv == DevEnv.vs2015)
                            {
                                extraFiles.Add(
                                    @"$ExecutableRootPath$\vcvars64.bat",
                                    Path.Combine(platformToolSetPath, @"redist\x64\Microsoft.VC140.CRT\concrt140.dll"),
                                    Path.Combine(platformToolSetPath, @"redist\x64\Microsoft.VC140.CRT\msvcp140.dll"),
                                    Path.Combine(platformToolSetPath, @"redist\x64\Microsoft.VC140.CRT\vccorlib140.dll"),
                                    Path.Combine(platformToolSetPath, @"redist\x64\Microsoft.VC140.CRT\vcruntime140.dll"),
                                    Path.Combine(systemDllPath, "ucrtbase.dll")
                                    );
                            }
                            else
                            {
                                extraFiles.Add(
                                    @"$ExecutableRootPath$\mspdbcore.dll",
                                    @"$ExecutableRootPath$\msvcdis140.dll",
                                    @"$ExecutableRootPath$\msvcp140.dll",
                                    @"$ExecutableRootPath$\pgodb140.dll",
                                    @"$ExecutableRootPath$\vcruntime140.dll",
                                    Path.Combine(platformToolSetPath, @"Auxiliary\Build\vcvars64.bat")
                                    );
                            }

                            if (devEnv == DevEnv.vs2019)
                            {
                                Version toolsVersion = devEnv.GetVisualStudioVCToolsVersion();

                                if (toolsVersion >= new Version("14.22.27905"))
                                {
                                    extraFiles.Add(@"$ExecutableRootPath$\tbbmalloc.dll");
                                }

                                if (toolsVersion >= new Version("14.25.28610"))
                                {
                                    extraFiles.Add(@"$ExecutableRootPath$\vcruntime140_1.dll");
                                }
                            }

                            try
                            {
                                foreach (string p in Util.DirectoryGetFiles(systemDllPath, "api-ms-win-*.dll"))
                                {
                                    extraFiles.Add(p);
                                }
                            }
                            catch { }
                        }
                        break;

                        default:
                            throw new NotImplementedException("This devEnv (" + devEnv + ") is not supported!");
                        }
                    }

                    string executable = Path.Combine("$ExecutableRootPath$", compilerExeName);

                    compilerSettings = new CompilerSettings(compilerName, compilerFamily, Platform.win64, extraFiles, executable, pathToCompiler, devEnv, new Dictionary <string, CompilerSettings.Configuration>());
                    masterCompilerSettings.Add(compilerName, compilerSettings);
                }

                return(compilerSettings);
            }
        public static string GetWindowsLibraryPath(this DevEnv visualVersion, Platform platform, DotNetFramework?dotNetFramework = null)
        {
            string visualStudioVCDir = Util.EnsureTrailingSeparator(visualVersion.GetVisualStudioVCRootPath());
            string subDir            = platform == Platform.win64 ? @"\amd64" : "";

            if ((visualVersion == DevEnv.vs2017) || (visualVersion == DevEnv.vs2019))
            {
                subDir = platform == Platform.win64 ? @"\x64" : @"\x86";
            }

            string visualStudioLib = string.Format(@"{0}lib{1};{0}atlmfc\lib{1};", visualStudioVCDir, subDir);

            if (visualVersion == DevEnv.vs2010)
            {
                return(visualStudioLib);
            }
            else
            {
                KitsRootEnum useKitsRoot    = KitsRootPaths.GetUseKitsRootForDevEnv(visualVersion);
                string       targetPlatform = platform == Platform.win64 ? "x64" : "x86";

                switch (useKitsRoot)
                {
                case KitsRootEnum.KitsRoot:
                {
                    string kitsRoot = Util.EnsureTrailingSeparator(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot));
                    return(string.Format(@"{0};{1}lib\win8\um\{2};{1}References\CommonConfiguration\Neutral;", visualStudioLib, kitsRoot, targetPlatform));
                }

                case KitsRootEnum.KitsRoot81:
                {
                    string kitsRoot = Util.EnsureTrailingSeparator(KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81));
                    return(string.Format(@"{0};{1}lib\winv6.3\um\{2};{1}References\CommonConfiguration\Neutral;", visualStudioLib, kitsRoot, targetPlatform));
                }

                case KitsRootEnum.KitsRoot10:
                {
                    string netFxPath = string.Empty;
                    if (dotNetFramework.HasValue && visualVersion >= DevEnv.vs2015)
                    {
                        string netFXKitsDir = Util.EnsureTrailingSeparator(KitsRootPaths.GetNETFXKitsDir(dotNetFramework.Value < DotNetFramework.v4_6 ? DotNetFramework.v4_6 : dotNetFramework.Value));
                        netFxPath = Path.Combine(netFXKitsDir, "Lib", "um", targetPlatform);
                    }

                    string kitsRoot10 = KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot10);
                    Options.Vc.General.WindowsTargetPlatformVersion windowsTargetPlatformVersion = KitsRootPaths.GetWindowsTargetPlatformVersionForDevEnv(visualVersion);
                    string platformVersion = windowsTargetPlatformVersion.ToVersionString();
                    var    paths           = new[]
                    {
                        visualStudioLib,
                        Path.Combine(kitsRoot10, "Lib", platformVersion, "ucrt", targetPlatform),           // $(UniversalCRT_LibraryPath_x86) or $(UniversalCRT_LibraryPath_x64)
                        Path.Combine(kitsRoot10, "Lib", platformVersion, "um", targetPlatform),             // $(WindowsSDK_LibraryPath_x86) or $(WindowsSDK_LibraryPath_x64)
                        netFxPath
                    }.ToList();

                    if (windowsTargetPlatformVersion <= Options.Vc.General.WindowsTargetPlatformVersion.v10_0_10240_0)
                    {
                        string kitsRoot81 = KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot81);
                        paths.AddRange(new[] {
                                Path.Combine(kitsRoot81, "lib", "winv6.3", "um", targetPlatform),
                                Path.Combine(kitsRoot81, "References", "CommonConfiguration", "Neutral")
                            });
                    }

                    return(string.Join(";", paths));
                }

                default:
                    throw new NotImplementedException("No WindowsResourceCompiler associated with " + visualVersion);
                }
            }
        }
Beispiel #7
0
        protected virtual void WriteWindowsKitsOverrides(IVcxprojGenerationContext context, IFileGenerator fileGenerator)
        {
            KitsRootEnum?kitsRootWritten = null;

            for (DevEnv devEnv = context.DevelopmentEnvironmentsRange.MinDevEnv; devEnv <= context.DevelopmentEnvironmentsRange.MaxDevEnv; devEnv = (DevEnv)((int)devEnv << 1))
            {
                // there's no need to write the properties with older versions of vs, as we override
                // completely the VC++ directories entries in the vcxproj
                if (devEnv < DevEnv.vs2015)
                {
                    continue;
                }

                KitsRootEnum kitsRootVersion = KitsRootPaths.GetUseKitsRootForDevEnv(devEnv);
                if (kitsRootWritten == null)
                {
                    kitsRootWritten = kitsRootVersion;
                }
                else if (kitsRootWritten != kitsRootVersion)
                {
                    throw new Error($"Different values of kitsRoot in the same vcxproj {context.ProjectFileName}");
                }
                else
                {
                    continue;
                }

                string windowsSdkDirKey   = FileGeneratorUtilities.RemoveLineTag;
                string windowsSdkDirValue = FileGeneratorUtilities.RemoveLineTag;

                string UniversalCRTSdkDir_10 = FileGeneratorUtilities.RemoveLineTag;
                string UCRTContentRoot       = FileGeneratorUtilities.RemoveLineTag;

                string targetPlatformVersionString = FileGeneratorUtilities.RemoveLineTag;
                if (kitsRootVersion != KitsRootEnum.KitsRoot81) // 8.1 is the default value for vs2015 and vs2017, so only specify a different platformVersion if we need to
                {
                    targetPlatformVersionString = KitsRootPaths.GetWindowsTargetPlatformVersionForDevEnv(devEnv).ToVersionString();
                }

                if (devEnv.OverridenWindowsPath())
                {
                    windowsSdkDirValue = Util.EnsureTrailingSeparator(KitsRootPaths.GetRoot(kitsRootVersion));
                    switch (kitsRootVersion)
                    {
                    case KitsRootEnum.KitsRoot:
                        windowsSdkDirKey = "WindowsSdkDir_80";
                        break;

                    case KitsRootEnum.KitsRoot81:
                        windowsSdkDirKey = "WindowsSdkDir_81";
                        break;

                    case KitsRootEnum.KitsRoot10:
                    {
                        windowsSdkDirKey      = "WindowsSdkDir_10";
                        UniversalCRTSdkDir_10 = windowsSdkDirValue;

                        // this variable is found in Windows Kits\10\DesignTime\CommonConfiguration\Neutral\uCRT.props
                        // it is always read from the registry unless overridden, so we need to explicitly set it
                        UCRTContentRoot = windowsSdkDirValue;
                    }
                    break;

                    default:
                        throw new NotImplementedException($"Unsupported kitsRoot '{kitsRootVersion}'");
                    }
                }

                using (fileGenerator.Declare("windowsSdkDirKey", windowsSdkDirKey))
                    using (fileGenerator.Declare("windowsSdkDirValue", windowsSdkDirValue))
                        using (fileGenerator.Declare("UniversalCRTSdkDir_10", UniversalCRTSdkDir_10))
                            using (fileGenerator.Declare("UCRTContentRoot", UCRTContentRoot))
                                using (fileGenerator.Declare("targetPlatformVersion", targetPlatformVersionString))
                                {
                                    fileGenerator.Write(_windowsSDKOverridesBegin);

                                    // vs2015 specific, we need to set the UniversalCRTSdkDir to $(UniversalCRTSdkDir_10) because it is not done in the .props
                                    if (devEnv == DevEnv.vs2015 && !string.Equals(UniversalCRTSdkDir_10, FileGeneratorUtilities.RemoveLineTag, StringComparison.Ordinal))
                                    {
                                        using (fileGenerator.Declare("custompropertyname", "UniversalCRTSdkDir"))
                                            using (fileGenerator.Declare("custompropertyvalue", "$(UniversalCRTSdkDir_10)"))
                                            {
                                                fileGenerator.Write(fileGenerator.Resolver.Resolve(Vcxproj.Template.Project.CustomProperty));
                                            }
                                    }
                                    fileGenerator.Write(_windowsSDKOverridesEnd);
                                }
            }
        }
Beispiel #8
0
            public CompilerSettings GetMasterCompilerSettings(
                IDictionary <string, CompilerSettings> masterCompilerSettings,
                string compilerName,
                DevEnv devEnv,
                string projectRootPath,
                Options.Vc.General.PlatformToolset platformToolset,
                bool useCCompiler
                )
            {
                CompilerSettings compilerSettings;

                if (masterCompilerSettings.ContainsKey(compilerName))
                {
                    compilerSettings = masterCompilerSettings[compilerName];
                }
                else
                {
                    DevEnv?compilerDevEnv      = null;
                    string platformToolSetPath = null;
                    string pathToCompiler      = null;
                    string compilerExeName     = null;

                    switch (platformToolset)
                    {
                    case Options.Vc.General.PlatformToolset.Default:
                        compilerDevEnv = devEnv;
                        break;

                    case Options.Vc.General.PlatformToolset.v100:
                        compilerDevEnv = DevEnv.vs2010;
                        break;

                    case Options.Vc.General.PlatformToolset.v110:
                    case Options.Vc.General.PlatformToolset.v110_xp:
                        compilerDevEnv = DevEnv.vs2012;
                        break;

                    case Options.Vc.General.PlatformToolset.v120:
                    case Options.Vc.General.PlatformToolset.v120_xp:
                        compilerDevEnv = DevEnv.vs2013;
                        break;

                    case Options.Vc.General.PlatformToolset.v140:
                    case Options.Vc.General.PlatformToolset.v140_xp:
                        compilerDevEnv = DevEnv.vs2015;
                        break;

                    case Options.Vc.General.PlatformToolset.v141:
                    case Options.Vc.General.PlatformToolset.v141_xp:
                        compilerDevEnv = DevEnv.vs2017;
                        break;

                    case Options.Vc.General.PlatformToolset.LLVM_vs2012:
                    case Options.Vc.General.PlatformToolset.LLVM_vs2014:
                    case Options.Vc.General.PlatformToolset.LLVM:

                        platformToolSetPath = ClangForWindows.Settings.LLVMInstallDir;
                        pathToCompiler      = Path.Combine(platformToolSetPath, "bin");
                        compilerExeName     = "clang-cl.exe";

                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }

                    if (compilerDevEnv.HasValue)
                    {
                        platformToolSetPath = Path.Combine(compilerDevEnv.Value.GetVisualStudioDir(), "VC");
                        pathToCompiler      = compilerDevEnv.Value.GetVisualStudioBinPath(Platform.win64);
                        compilerExeName     = "cl.exe";
                    }

                    Strings extraFiles = new Strings();
                    if (compilerDevEnv.HasValue)
                    {
                        extraFiles.Add(
                            @"$ExecutableRootPath$\c1.dll",
                            @"$ExecutableRootPath$\c1xx.dll",
                            @"$ExecutableRootPath$\c2.dll",
                            @"$ExecutableRootPath$\mspdbcore.dll",
                            @"$ExecutableRootPath$\mspdbsrv.exe",
                            @"$ExecutableRootPath$\1033\clui.dll"
                            );

                        switch (devEnv)
                        {
                        case DevEnv.vs2012:
                        {
                            extraFiles.Add(
                                @"$ExecutableRootPath$\c1ast.dll",
                                @"$ExecutableRootPath$\c1xxast.dll",
                                @"$ExecutableRootPath$\mspft110.dll",
                                @"$ExecutableRootPath$\msobj110.dll",
                                @"$ExecutableRootPath$\mspdb110.dll",
                                Path.Combine(platformToolSetPath, @"redist\x64\Microsoft.VC110.CRT\msvcp110.dll"),
                                Path.Combine(platformToolSetPath, @"redist\x64\Microsoft.VC110.CRT\msvcr110.dll"),
                                Path.Combine(platformToolSetPath, @"redist\x64\Microsoft.VC110.CRT\vccorlib110.dll")
                                );
                        }
                        break;

                        case DevEnv.vs2013:
                        {
                            extraFiles.Add(
                                @"$ExecutableRootPath$\c1ast.dll",
                                @"$ExecutableRootPath$\c1xxast.dll",
                                @"$ExecutableRootPath$\mspft120.dll",
                                @"$ExecutableRootPath$\msobj120.dll",
                                @"$ExecutableRootPath$\mspdb120.dll",
                                Path.Combine(platformToolSetPath, @"redist\x64\Microsoft.VC120.CRT\msvcp120.dll"),
                                Path.Combine(platformToolSetPath, @"redist\x64\Microsoft.VC120.CRT\msvcr120.dll"),
                                Path.Combine(platformToolSetPath, @"redist\x64\Microsoft.VC120.CRT\vccorlib120.dll")
                                );
                        }
                        break;

                        case DevEnv.vs2015:
                        case DevEnv.vs2017:
                        {
                            string systemDllPath = FastBuildSettings.SystemDllRoot;
                            if (systemDllPath == null)
                            {
                                systemDllPath = KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot10) + @"Redist\ucrt\DLLs\x64\";
                            }

                            if (!Path.IsPathRooted(systemDllPath))
                            {
                                systemDllPath = Util.SimplifyPath(Path.Combine(projectRootPath, systemDllPath));
                            }

                            extraFiles.Add(
                                @"$ExecutableRootPath$\msobj140.dll",
                                @"$ExecutableRootPath$\mspft140.dll",
                                @"$ExecutableRootPath$\mspdb140.dll"
                                );

                            if (devEnv == DevEnv.vs2015)
                            {
                                extraFiles.Add(
                                    @"$ExecutableRootPath$\vcvars64.bat",
                                    Path.Combine(platformToolSetPath, @"redist\x64\Microsoft.VC140.CRT\concrt140.dll"),
                                    Path.Combine(platformToolSetPath, @"redist\x64\Microsoft.VC140.CRT\msvcp140.dll"),
                                    Path.Combine(platformToolSetPath, @"redist\x64\Microsoft.VC140.CRT\vccorlib140.dll"),
                                    Path.Combine(platformToolSetPath, @"redist\x64\Microsoft.VC140.CRT\vcruntime140.dll"),
                                    Path.Combine(systemDllPath, "ucrtbase.dll")
                                    );
                            }
                            else
                            {
                                extraFiles.Add(
                                    @"$ExecutableRootPath$\mspdbcore.dll",
                                    @"$ExecutableRootPath$\msvcdis140.dll",
                                    @"$ExecutableRootPath$\msvcp140.dll",
                                    @"$ExecutableRootPath$\pgodb140.dll",
                                    @"$ExecutableRootPath$\vcruntime140.dll",
                                    Path.Combine(platformToolSetPath, @"Auxiliary\Build\vcvars64.bat")
                                    );
                            }

                            try
                            {
                                foreach (string p in Util.DirectoryGetFiles(systemDllPath, "api-ms-win-*.dll"))
                                {
                                    extraFiles.Add(p);
                                }
                            }
                            catch { }
                        }
                        break;

                        default:
                            throw new NotImplementedException("This devEnv (" + devEnv + ") is not supported!");
                        }
                    }

                    string executable = Path.Combine("$ExecutableRootPath$", compilerExeName);

                    compilerSettings = new CompilerSettings(compilerName, Platform.win64, extraFiles, executable, pathToCompiler, devEnv, new Dictionary <string, CompilerSettings.Configuration>());
                    masterCompilerSettings.Add(compilerName, compilerSettings);
                }

                return(compilerSettings);
            }
Beispiel #9
0
            public override CompilerSettings GetMasterCompilerSettings(
                IDictionary <string, CompilerSettings> masterCompilerSettings,
                string compilerName,
                string rootPath,
                DevEnv devEnv,
                string projectRootPath,
                bool useCCompiler
                )
            {
                CompilerSettings compilerSettings;

                if (masterCompilerSettings.ContainsKey(compilerName))
                {
                    compilerSettings = masterCompilerSettings[compilerName];
                }
                else
                {
                    string pathToCompiler = devEnv.GetVisualStudioBinPath(Platform.win64);
                    if (pathToCompiler.StartsWith(rootPath, StringComparison.OrdinalIgnoreCase))
                    {
                        string rootRelative = pathToCompiler.Substring(rootPath.Length).TrimStart(Util._pathSeparators);
                        pathToCompiler = Path.Combine("$RootPath$", rootRelative);
                    }

                    Strings extraFiles = new Strings();

                    extraFiles.Add(
                        Path.Combine(pathToCompiler, "c1.dll"),
                        Path.Combine(pathToCompiler, "c1xx.dll"),
                        Path.Combine(pathToCompiler, "c2.dll"),
                        Path.Combine(pathToCompiler, "mspdbcore.dll"),
                        Path.Combine(pathToCompiler, "mspdbsrv.exe"),
                        Path.Combine(pathToCompiler, @"1033\clui.dll")
                        );

                    switch (devEnv)
                    {
                    case DevEnv.vs2012:
                    {
                        extraFiles.Add(
                            Path.Combine(pathToCompiler, "c1ast.dll"),
                            Path.Combine(pathToCompiler, "c1xxast.dll"),
                            Path.Combine(pathToCompiler, "mspft110.dll"),
                            Path.Combine(pathToCompiler, "msobj110.dll"),
                            Path.Combine(pathToCompiler, "mspdb110.dll"),
                            @"$RootPath$\redist\x64\Microsoft.VC110.CRT\msvcp110.dll",
                            @"$RootPath$\redist\x64\Microsoft.VC110.CRT\msvcr110.dll",
                            @"$RootPath$\redist\x64\Microsoft.VC110.CRT\vccorlib110.dll"
                            );
                    }
                    break;

                    case DevEnv.vs2013:
                    {
                        extraFiles.Add(
                            Path.Combine(pathToCompiler, "c1ast.dll"),
                            Path.Combine(pathToCompiler, "c1xxast.dll"),
                            Path.Combine(pathToCompiler, "mspft120.dll"),
                            Path.Combine(pathToCompiler, "msobj120.dll"),
                            Path.Combine(pathToCompiler, "mspdb120.dll"),
                            @"$RootPath$\redist\x64\Microsoft.VC120.CRT\msvcp120.dll",
                            @"$RootPath$\redist\x64\Microsoft.VC120.CRT\msvcr120.dll",
                            @"$RootPath$\redist\x64\Microsoft.VC120.CRT\vccorlib120.dll"
                            );
                    }
                    break;

                    case DevEnv.vs2015:
                    case DevEnv.vs2017:
                    {
                        string systemDllPath = FastBuildSettings.SystemDllRoot;
                        if (systemDllPath == null)
                        {
                            systemDllPath = KitsRootPaths.GetRoot(KitsRootEnum.KitsRoot10) + @"Redist\ucrt\DLLs\x64\";
                        }

                        if (!Path.IsPathRooted(systemDllPath))
                        {
                            systemDllPath = Util.SimplifyPath(Path.Combine(projectRootPath, systemDllPath));
                        }

                        extraFiles.Add(
                            Path.Combine(pathToCompiler, "msobj140.dll"),
                            Path.Combine(pathToCompiler, "mspft140.dll"),
                            Path.Combine(pathToCompiler, "mspdb140.dll")
                            );

                        if (devEnv == DevEnv.vs2015)
                        {
                            extraFiles.Add(

                                Path.Combine(pathToCompiler, "vcvars64.bat"),
                                @"$RootPath$\redist\x64\Microsoft.VC140.CRT\concrt140.dll",
                                @"$RootPath$\redist\x64\Microsoft.VC140.CRT\msvcp140.dll",
                                @"$RootPath$\redist\x64\Microsoft.VC140.CRT\vccorlib140.dll",
                                @"$RootPath$\redist\x64\Microsoft.VC140.CRT\vcruntime140.dll",
                                Path.Combine(systemDllPath, "ucrtbase.dll")
                                );
                        }
                        else
                        {
                            extraFiles.Add(
                                Path.Combine(pathToCompiler, "mspdbcore.dll"),
                                Path.Combine(pathToCompiler, "msvcdis140.dll"),
                                Path.Combine(pathToCompiler, "msvcp140.dll"),
                                Path.Combine(pathToCompiler, "pgodb140.dll"),
                                Path.Combine(pathToCompiler, "vcruntime140.dll"),
                                @"$RootPath$\Auxiliary\Build\vcvars64.bat"
                                );
                        }

                        try
                        {
                            foreach (string p in Util.DirectoryGetFiles(systemDllPath, "api-ms-win-*.dll"))
                            {
                                extraFiles.Add(p);
                            }
                        }
                        catch { }
                    }
                    break;

                    default:
                        throw new NotImplementedException("This devEnv (" + devEnv + ") is not supported!");
                    }

                    string executable = Path.Combine(pathToCompiler, "cl.exe");

                    compilerSettings = new CompilerSettings(compilerName, Platform.win64, extraFiles, executable, rootPath, devEnv, new Dictionary <string, CompilerSettings.Configuration>());
                    masterCompilerSettings.Add(compilerName, compilerSettings);
                }

                return(compilerSettings);
            }