示例#1
0
            public override void AddCompilerSettings(
                IDictionary <string, CompilerSettings> masterCompilerSettings,
                string compilerName,
                string rootPath,
                DevEnv devEnv,
                string projectRootPath
                )
            {
                var fastBuildCompilerSettings = PlatformRegistry.Get <IWindowsFastBuildCompilerSettings>(Platform.win64);

                if (!fastBuildCompilerSettings.BinPath.ContainsKey(devEnv))
                {
                    fastBuildCompilerSettings.BinPath.Add(devEnv, devEnv.GetVisualStudioBinPath(Platform.win64));
                }
                if (!fastBuildCompilerSettings.LinkerPath.ContainsKey(devEnv))
                {
                    fastBuildCompilerSettings.LinkerPath.Add(devEnv, fastBuildCompilerSettings.BinPath[devEnv]);
                }
                if (!fastBuildCompilerSettings.ResCompiler.ContainsKey(devEnv))
                {
                    fastBuildCompilerSettings.ResCompiler.Add(devEnv, devEnv.GetWindowsResourceCompiler(Platform.win64));
                }

                CompilerSettings compilerSettings = GetMasterCompilerSettings(masterCompilerSettings, compilerName, rootPath, devEnv, projectRootPath, false);

                compilerSettings.PlatformFlags |= Platform.win64;
                SetConfiguration(compilerSettings.Configurations, string.Empty, projectRootPath, devEnv, false);
            }
示例#2
0
            public override void AddCompilerSettings(
                IDictionary <string, CompilerSettings> masterCompilerSettings,
                string compilerName,
                string rootPath,
                DevEnv devEnv,
                string projectRootPath
                )
            {
                switch (devEnv)
                {
                case DevEnv.vs2012:
                {
                    CompilerSettings compilerSettings = GetMasterCompilerSettings(masterCompilerSettings, compilerName, rootPath, devEnv, projectRootPath, false);
                    compilerSettings.PlatformFlags |= Platform.durango;
                    SetConfiguration(compilerSettings.Configurations, string.Empty, projectRootPath, devEnv, false);
                }
                break;

                case DevEnv.vs2015:
                case DevEnv.vs2017:
                {
                    var win64PlatformSettings = PlatformRegistry.Get <IPlatformBff>(Platform.win64);

                    string           overrideName     = "Compiler-" + Sharpmake.Util.GetSimplePlatformString(Platform.win64) + "-" + devEnv;
                    CompilerSettings compilerSettings = win64PlatformSettings.GetMasterCompilerSettings(masterCompilerSettings, overrideName, rootPath, devEnv, projectRootPath, false);
                    compilerSettings.PlatformFlags |= Platform.durango;
                    SetConfiguration(compilerSettings.Configurations, string.Empty, projectRootPath, devEnv, false);
                }
                break;

                default:
                    throw new NotImplementedException("This devEnv (" + devEnv + ") is not supported!");
                }
            }
示例#3
0
            private 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
                {
                    var     fastBuildCompilerSettings = PlatformRegistry.Get <IFastBuildCompilerSettings>(Platform.durango);
                    Strings extraFiles;
                    if (!fastBuildCompilerSettings.ExtraFiles.TryGetValue(devEnv, out extraFiles))
                    {
                        extraFiles = new Strings();
                    }
                    string executable;

                    switch (devEnv)
                    {
                    case DevEnv.vs2012:
                    {
                        extraFiles.Add(
                            @"$ExecutableRootPath$\c1.dll",
                            @"$ExecutableRootPath$\c1xx.dll",
                            @"$ExecutableRootPath$\c1xxast.dll",
                            @"$ExecutableRootPath$\c2.dll",
                            @"$ExecutableRootPath$\msobj110.dll",
                            @"$ExecutableRootPath$\mspdb110.dll",
                            @"$ExecutableRootPath$\mspdbcore.dll",
                            @"$ExecutableRootPath$\mspdbsrv.exe",
                            @"$ExecutableRootPath$\mspft110.dll",
                            @"$ExecutableRootPath$\1033\clui.dll",
                            @"$ExecutableRootPath$\msvcp110.dll",
                            @"$ExecutableRootPath$\msvcr110.dll",
                            @"$ExecutableRootPath$\vccorlib110.dll");

                        executable = @"$ExecutableRootPath$\cl.exe";
                        fastBuildCompilerSettings.BinPath.TryGetValue(devEnv, out rootPath);
                    }
                    break;

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

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

                return(compilerSettings);
            }
示例#4
0
            public override void SetConfiguration(IDictionary <string, CompilerSettings.Configuration> configurations, string compilerName, string projectRootPath, DevEnv devEnv, bool useCCompiler)
            {
                string configName = ".win64Config";

                if (!configurations.ContainsKey(configName))
                {
                    var    fastBuildCompilerSettings = PlatformRegistry.Get <IWindowsFastBuildCompilerSettings>(Platform.win64);
                    string binPath;
                    if (!fastBuildCompilerSettings.BinPath.TryGetValue(devEnv, out binPath))
                    {
                        binPath = devEnv.GetVisualStudioBinPath(Platform.win64);
                    }

                    string linkerPath;
                    if (!fastBuildCompilerSettings.LinkerPath.TryGetValue(devEnv, out linkerPath))
                    {
                        linkerPath = binPath;
                    }

                    string linkerExe;
                    if (!fastBuildCompilerSettings.LinkerExe.TryGetValue(devEnv, out linkerExe))
                    {
                        linkerExe = "link.exe";
                    }

                    string librarianExe;
                    if (!fastBuildCompilerSettings.LibrarianExe.TryGetValue(devEnv, out librarianExe))
                    {
                        librarianExe = "lib.exe";
                    }

                    string resCompiler;
                    if (!fastBuildCompilerSettings.ResCompiler.TryGetValue(devEnv, out resCompiler))
                    {
                        resCompiler = devEnv.GetWindowsResourceCompiler(Platform.win64);
                    }

                    configurations.Add(
                        configName,
                        new CompilerSettings.Configuration(
                            Platform.win64,
                            binPath: Util.GetCapitalizedPath(Util.PathGetAbsolute(projectRootPath, binPath)),
                            linkerPath: Util.GetCapitalizedPath(Util.PathGetAbsolute(projectRootPath, linkerPath)),
                            resourceCompiler: Util.GetCapitalizedPath(Util.PathGetAbsolute(projectRootPath, resCompiler)),
                            librarian: Path.Combine(@"$LinkerPath$", librarianExe),
                            linker: Path.Combine(@"$LinkerPath$", linkerExe)
                            )
                        );

                    configurations.Add(
                        ".win64ConfigMasm",
                        new CompilerSettings.Configuration(
                            Platform.win64,
                            compiler: @"$BinPath$\ml64.exe",
                            usingOtherConfiguration: @".win64Config"
                            )
                        );
                }
            }
示例#5
0
            public override void SetConfiguration(IDictionary <string, CompilerSettings.Configuration> configurations, string compilerName, string projectRootPath, DevEnv devEnv, bool useCCompiler)
            {
                string configName = ".durangoConfig";

                if (!configurations.ContainsKey(configName))
                {
                    var    fastBuildCompilerSettings = PlatformRegistry.Get <IFastBuildCompilerSettings>(Platform.durango);
                    string binPath;
                    if (!fastBuildCompilerSettings.BinPath.TryGetValue(devEnv, out binPath))
                    {
                        binPath = devEnv.GetDurangoBinPath();
                    }

                    string linkerPath;
                    if (!fastBuildCompilerSettings.LinkerPath.TryGetValue(devEnv, out linkerPath))
                    {
                        linkerPath = binPath;
                    }

                    string linkerExe;
                    if (!fastBuildCompilerSettings.LinkerExe.TryGetValue(devEnv, out linkerExe))
                    {
                        linkerExe = "link.exe";
                    }

                    string librarianExe;
                    if (!fastBuildCompilerSettings.LibrarianExe.TryGetValue(devEnv, out librarianExe))
                    {
                        librarianExe = "lib.exe";
                    }

                    configurations.Add(
                        configName,
                        new CompilerSettings.Configuration(
                            Platform.durango,
                            binPath: Sharpmake.Util.GetCapitalizedPath(Sharpmake.Util.PathGetAbsolute(projectRootPath, binPath)),
                            linkerPath: Sharpmake.Util.GetCapitalizedPath(Sharpmake.Util.PathGetAbsolute(projectRootPath, linkerPath)),
                            librarian: Path.Combine(@"$LinkerPath$", librarianExe),
                            linker: Path.Combine(@"$LinkerPath$", linkerExe)
                            )
                        );

                    configurations.Add(
                        ".durangoConfigMasm",
                        new CompilerSettings.Configuration(
                            Platform.durango,
                            compiler: @"$BinPath$\ml64.exe",
                            usingOtherConfiguration: configName
                            )
                        );
                }
            }
示例#6
0
        public virtual void SelectPreprocessorDefinitionsBff(IBffGenerationContext context)
        {
            var    platformDescriptor   = PlatformRegistry.Get <IPlatformDescriptor>(context.Configuration.Platform);
            string platformDefineSwitch = platformDescriptor.IsUsingClang ? "-D" : "/D";

            var defines = new Strings();

            defines.AddRange(context.Options.ExplicitDefines);
            defines.AddRange(context.Configuration.Defines);

            if (defines.Count > 0)
            {
                var fastBuildDefines = new List <string>();

                foreach (string define in defines.SortedValues)
                {
                    if (!string.IsNullOrWhiteSpace(define))
                    {
                        fastBuildDefines.Add(string.Format(@"{0}{1}{2}{1}", platformDefineSwitch, Util.DoubleQuotes, define.Replace(Util.DoubleQuotes, Util.EscapedDoubleQuotes)));
                    }
                }
                context.CommandLineOptions["PreprocessorDefinitions"] = string.Join($"'{Environment.NewLine}            + ' ", fastBuildDefines);
            }
            else
            {
                context.CommandLineOptions["PreprocessorDefinitions"] = FileGeneratorUtilities.RemoveLineTag;
            }

            Strings resourceDefines = Options.GetStrings <Options.Vc.ResourceCompiler.PreprocessorDefinitions>(context.Configuration);

            if (resourceDefines.Any())
            {
                var fastBuildDefines = new List <string>();

                foreach (string resourceDefine in resourceDefines.SortedValues)
                {
                    if (!string.IsNullOrWhiteSpace(resourceDefine))
                    {
                        fastBuildDefines.Add(string.Format(@"""{0}{1}""", platformDefineSwitch, resourceDefine.Replace(Util.DoubleQuotes, Util.EscapedDoubleQuotes)));
                    }
                }
                context.CommandLineOptions["ResourcePreprocessorDefinitions"] = string.Join($"'{Environment.NewLine}                                    + ' ", fastBuildDefines);
            }
            else
            {
                context.CommandLineOptions["ResourcePreprocessorDefinitions"] = FileGeneratorUtilities.RemoveLineTag;
            }
        }
示例#7
0
            public override void AddCompilerSettings(
                IDictionary <string, CompilerSettings> masterCompilerSettings,
                string compilerName,
                string rootPath,
                DevEnv devEnv,
                string projectRootPath
                )
            {
                var fastBuildCompilerSettings = PlatformRegistry.Get <IFastBuildCompilerSettings>(Platform.durango);

                if (!fastBuildCompilerSettings.BinPath.ContainsKey(devEnv))
                {
                    fastBuildCompilerSettings.BinPath.Add(devEnv, devEnv.GetDurangoBinPath());
                }

                if (!fastBuildCompilerSettings.LinkerPath.ContainsKey(devEnv))
                {
                    fastBuildCompilerSettings.LinkerPath.Add(devEnv, fastBuildCompilerSettings.BinPath[devEnv]);
                }

                switch (devEnv)
                {
                case DevEnv.vs2012:
                {
                    CompilerSettings compilerSettings = GetMasterCompilerSettings(masterCompilerSettings, compilerName, rootPath, devEnv, projectRootPath, false);
                    compilerSettings.PlatformFlags |= Platform.durango;
                    SetConfiguration(compilerSettings.Configurations, string.Empty, projectRootPath, devEnv, false);
                }
                break;

                case DevEnv.vs2015:
                case DevEnv.vs2017:
                {
                    var win64PlatformSettings = PlatformRegistry.Get <IPlatformBff>(Platform.win64);

                    string           overrideName     = devEnv == DevEnv.vs2015 ? "Compiler-x64-v140-vs2015" : "Compiler-x64-v141-vs2017";
                    CompilerSettings compilerSettings = win64PlatformSettings.GetMasterCompilerSettings(masterCompilerSettings, overrideName, rootPath, devEnv, projectRootPath, false);
                    compilerSettings.PlatformFlags |= Platform.durango;
                    SetConfiguration(compilerSettings.Configurations, string.Empty, projectRootPath, devEnv, false);
                }
                break;

                default:
                    throw new NotImplementedException("This devEnv (" + devEnv + ") is not supported!");
                }
            }
示例#8
0
            private CompilerSettings GetMasterCompilerSettings(IDictionary <string, CompilerSettings> masterCompilerSettings, string compilerName, DevEnv devEnv, string projectRootPath, bool useCCompiler)
            {
                CompilerSettings compilerSettings;

                if (masterCompilerSettings.ContainsKey(compilerName))
                {
                    compilerSettings = masterCompilerSettings[compilerName];
                }
                else
                {
                    var fastBuildSettings = PlatformRegistry.Get <IFastBuildCompilerSettings>(Platform.linux);

                    string binPath;
                    if (!fastBuildSettings.BinPath.TryGetValue(devEnv, out binPath))
                    {
                        binPath = ClangForWindows.GetWindowsClangExecutablePath();
                    }

                    string pathToCompiler = Util.GetCapitalizedPath(Util.PathGetAbsolute(projectRootPath, binPath));

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

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

                    string executable = useCCompiler ? @"$ExecutableRootPath$\clang.exe" : @"$ExecutableRootPath$\clang++.exe";

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

                return(compilerSettings);
            }
示例#9
0
            public override void SetConfiguration(IDictionary <string, CompilerSettings.Configuration> configurations, string compilerName, string projectRootPath, DevEnv devEnv, bool useCCompiler)
            {
                string configName = ".durangoConfig";

                if (!configurations.ContainsKey(configName))
                {
                    var fastBuildCompilerSettings = PlatformRegistry.Get <IFastBuildCompilerSettings>(Platform.durango);
                    configurations.Add(
                        configName,
                        new CompilerSettings.Configuration(
                            Platform.durango,
                            binPath: Sharpmake.Util.GetCapitalizedPath(Sharpmake.Util.PathGetAbsolute(projectRootPath, fastBuildCompilerSettings.BinPath[devEnv])),
                            linkerPath: Sharpmake.Util.GetCapitalizedPath(Sharpmake.Util.PathGetAbsolute(projectRootPath, fastBuildCompilerSettings.LinkerPath[devEnv])),
                            librarian: @"$LinkerPath$\lib.exe",
                            linker: @"$LinkerPath$\link.exe"
                            )
                        );
                    configurations.Add(".durangoConfigMasm", new CompilerSettings.Configuration(Platform.durango, compiler: @"$BinPath$\ml64.exe", usingOtherConfiguration: @".durangoConfig"));
                }
            }
示例#10
0
            private void SetConfiguration(CompilerSettings compilerSettings, string compilerName, string projectRootPath, DevEnv devEnv, bool useCCompiler)
            {
                string configName = useCCompiler ? ".linuxConfig" : ".linuxppConfig";

                IDictionary <string, CompilerSettings.Configuration> configurations = compilerSettings.Configurations;

                if (!configurations.ContainsKey(configName))
                {
                    var    fastBuildSettings = PlatformRegistry.Get <IFastBuildCompilerSettings>(Platform.linux);
                    string binPath           = compilerSettings.RootPath;
                    string linkerPath;
                    if (!fastBuildSettings.LinkerPath.TryGetValue(devEnv, out linkerPath))
                    {
                        linkerPath = binPath;
                    }

                    string linkerExe;
                    if (!fastBuildSettings.LinkerExe.TryGetValue(devEnv, out linkerExe))
                    {
                        linkerExe = "ld.lld.exe";
                    }

                    string librarianExe;
                    if (!fastBuildSettings.LibrarianExe.TryGetValue(devEnv, out librarianExe))
                    {
                        librarianExe = "llvm-ar.exe";
                    }

                    configurations.Add(configName,
                                       new CompilerSettings.Configuration(
                                           Platform.linux,
                                           compiler: compilerName,
                                           binPath: binPath,
                                           linkerPath: Util.GetCapitalizedPath(Util.PathGetAbsolute(projectRootPath, linkerPath)),
                                           librarian: @"$LinkerPath$\" + librarianExe,
                                           linker: @"$LinkerPath$\" + linkerExe,
                                           fastBuildLinkerType: CompilerSettings.LinkerType.GCC // Workaround: set GCC linker type since it will only enable response files
                                           )
                                       );
                }
            }
示例#11
0
            public override void AddCompilerSettings(IDictionary <string, CompilerSettings> masterCompilerSettings, Project.Configuration conf)
            {
                var devEnv            = conf.Target.GetFragment <DevEnv>();
                var fastBuildSettings = PlatformRegistry.Get <IFastBuildCompilerSettings>(Platform.linux);

                var    platform              = conf.Target.GetFragment <Platform>();
                string compilerName          = $"Compiler-{Util.GetSimplePlatformString(platform)}-{devEnv}";
                string CCompilerSettingsName = "C-" + compilerName + "-" + "Linux";
                string CompilerSettingsName  = compilerName + "-" + "Linux";

                var projectRootPath = conf.Project.RootPath;
                CompilerSettings compilerSettings = GetMasterCompilerSettings(masterCompilerSettings, CompilerSettingsName, devEnv, projectRootPath, false);

                compilerSettings.PlatformFlags |= Platform.linux;
                CompilerSettings CcompilerSettings = GetMasterCompilerSettings(masterCompilerSettings, CCompilerSettingsName, devEnv, projectRootPath, true);

                CcompilerSettings.PlatformFlags |= Platform.linux;

                SetConfiguration(compilerSettings, CompilerSettingsName, projectRootPath, devEnv, false);
                SetConfiguration(CcompilerSettings, CCompilerSettingsName, projectRootPath, devEnv, true);
            }
示例#12
0
            public override void AddCompilerSettings(
                IDictionary <string, CompilerSettings> masterCompilerSettings,
                Project.Configuration conf
                )
            {
                var    projectRootPath     = conf.Project.RootPath;
                var    devEnv              = conf.Target.GetFragment <DevEnv>();
                var    platform            = Platform.durango; // could also been retrieved from conf.Target.GetPlatform(), if we want
                string platformToolSetPath = Path.Combine(devEnv.GetVisualStudioDir(), "VC");
                string compilerName        = "Compiler-" + Sharpmake.Util.GetSimplePlatformString(platform) + "-" + devEnv;

                switch (devEnv)
                {
                case DevEnv.vs2012:
                {
                    CompilerSettings compilerSettings = GetMasterCompilerSettings(masterCompilerSettings, compilerName, platformToolSetPath, devEnv, projectRootPath, false);
                    compilerSettings.PlatformFlags |= Platform.durango;
                    SetConfiguration(conf, compilerSettings.Configurations, string.Empty, projectRootPath, devEnv, false);
                }
                break;

                case DevEnv.vs2015:
                case DevEnv.vs2017:
                {
                    var win64PlatformSettings = PlatformRegistry.Get <IPlatformBff>(Platform.win64) as Windows.Win64Platform;        // TODO: make cleaner

                    string           overrideName     = "Compiler-" + Sharpmake.Util.GetSimplePlatformString(Platform.win64) + "-" + devEnv;
                    CompilerSettings compilerSettings = win64PlatformSettings.GetMasterCompilerSettings(masterCompilerSettings, overrideName, devEnv, projectRootPath, Sharpmake.Options.Vc.General.PlatformToolset.Default, false);
                    compilerSettings.PlatformFlags |= Platform.durango;

                    SetConfiguration(conf, compilerSettings.Configurations, string.Empty, projectRootPath, devEnv, false);
                }
                break;

                default:
                    throw new NotImplementedException("This devEnv (" + devEnv + ") is not supported!");
                }
            }
示例#13
0
            public override void SetConfiguration(IDictionary <string, CompilerSettings.Configuration> configurations, string compilerName, string projectRootPath, DevEnv devEnv, bool useCCompiler)
            {
                string configName = ".win64Config";

                if (!configurations.ContainsKey(configName))
                {
                    var    fastBuildCompilerSettings = PlatformRegistry.Get <IWindowsFastBuildCompilerSettings>(Platform.win64);
                    string binPath     = fastBuildCompilerSettings.BinPath[devEnv];
                    string linkerPath  = fastBuildCompilerSettings.LinkerPath[devEnv];
                    string resCompiler = fastBuildCompilerSettings.ResCompiler[devEnv];
                    configurations.Add(configName,
                                       new CompilerSettings.Configuration(
                                           Platform.win64,
                                           binPath: Util.GetCapitalizedPath(Util.PathGetAbsolute(projectRootPath, binPath)),
                                           linkerPath: Util.GetCapitalizedPath(Util.PathGetAbsolute(projectRootPath, linkerPath)),
                                           resourceCompiler: Util.GetCapitalizedPath(Util.PathGetAbsolute(projectRootPath, resCompiler)),
                                           librarian: @"$LinkerPath$\lib.exe",
                                           linker: @"$LinkerPath$\link.exe"
                                           )
                                       );

                    configurations.Add(".win64ConfigMasm", new CompilerSettings.Configuration(Platform.win64, compiler: @"$BinPath$\ml64.exe", usingOtherConfiguration: @".win64Config"));
                }
            }
示例#14
0
            public override void AddCompilerSettings(
                IDictionary <string, CompilerSettings> masterCompilerSettings,
                Project.Configuration conf
                )
            {
                var    projectRootPath     = conf.Project.RootPath;
                var    devEnv              = conf.Target.GetFragment <DevEnv>();
                var    platform            = Platform.durango; // could also been retrieved from conf.Target.GetPlatform(), if we want
                string platformToolSetPath = Path.Combine(devEnv.GetVisualStudioDir(), "VC");
                string compilerName        = "Compiler-" + Sharpmake.Util.GetSimplePlatformString(platform) + "-" + devEnv;

                switch (devEnv)
                {
                case DevEnv.vs2012:
                {
                    CompilerSettings compilerSettings = GetMasterCompilerSettings(masterCompilerSettings, compilerName, platformToolSetPath, devEnv, projectRootPath, false);
                    compilerSettings.PlatformFlags |= Platform.durango;
                    SetConfiguration(conf, compilerSettings.Configurations, string.Empty, projectRootPath, devEnv, false);
                }
                break;

                case DevEnv.vs2015:
                case DevEnv.vs2017:
                {
                    var win64PlatformSettings = PlatformRegistry.Get <IPlatformBff>(Platform.win64) as Windows.Win64Platform;        // TODO: make cleaner

                    string overrideName = "Compiler-" + Sharpmake.Util.GetSimplePlatformString(Platform.win64);

                    var platformToolset = Sharpmake.Options.GetObject <Sharpmake.Options.Vc.General.PlatformToolset>(conf);
                    if (platformToolset == Sharpmake.Options.Vc.General.PlatformToolset.LLVM)
                    {
                        var useClangCl = Sharpmake.Options.GetObject <Sharpmake.Options.Vc.LLVM.UseClangCl>(conf);

                        // Use default platformToolset to get MS compiler instead of Clang, when ClanCl is disabled
                        if (useClangCl == Sharpmake.Options.Vc.LLVM.UseClangCl.Disable)
                        {
                            platformToolset = Sharpmake.Options.Vc.General.PlatformToolset.Default;
                        }
                    }

                    if (platformToolset != Sharpmake.Options.Vc.General.PlatformToolset.Default && !platformToolset.IsDefaultToolsetForDevEnv(devEnv))
                    {
                        overrideName += "-" + platformToolset;
                    }
                    else
                    {
                        overrideName += "-" + devEnv;
                    }


                    CompilerSettings compilerSettings = win64PlatformSettings.GetMasterCompilerSettings(masterCompilerSettings, overrideName, devEnv, projectRootPath, platformToolset, false);
                    compilerSettings.PlatformFlags |= Platform.durango;

                    SetConfiguration(conf, compilerSettings.Configurations, CppConfigName(conf), projectRootPath, devEnv, false);
                }
                break;

                default:
                    throw new NotImplementedException("This devEnv (" + devEnv + ") is not supported!");
                }
            }
示例#15
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);
            }
示例#16
0
            private void SetConfiguration(
                Project.Configuration conf,
                IDictionary <string, CompilerSettings.Configuration> configurations,
                string configName,
                string projectRootPath,
                DevEnv devEnv,
                bool useCCompiler)
            {
                if (configurations.ContainsKey(configName))
                {
                    return;
                }

                string linkerPathOverride   = null;
                string linkerExeOverride    = null;
                string librarianExeOverride = null;

                GetLinkerExecutableInfo(conf, out linkerPathOverride, out linkerExeOverride, out librarianExeOverride);

                var    fastBuildCompilerSettings = PlatformRegistry.Get <IWindowsFastBuildCompilerSettings>(Platform.win64);
                string binPath;

                if (!fastBuildCompilerSettings.BinPath.TryGetValue(devEnv, out binPath))
                {
                    binPath = devEnv.GetVisualStudioBinPath(Platform.win64);
                }

                string linkerPath;

                if (!string.IsNullOrEmpty(linkerPathOverride))
                {
                    linkerPath = linkerPathOverride;
                }
                else if (!fastBuildCompilerSettings.LinkerPath.TryGetValue(devEnv, out linkerPath))
                {
                    linkerPath = binPath;
                }

                string linkerExe;

                if (!string.IsNullOrEmpty(linkerExeOverride))
                {
                    linkerExe = linkerExeOverride;
                }
                else if (!fastBuildCompilerSettings.LinkerExe.TryGetValue(devEnv, out linkerExe))
                {
                    linkerExe = "link.exe";
                }

                string librarianExe;

                if (!string.IsNullOrEmpty(librarianExeOverride))
                {
                    librarianExe = librarianExeOverride;
                }
                else if (!fastBuildCompilerSettings.LibrarianExe.TryGetValue(devEnv, out librarianExe))
                {
                    librarianExe = "lib.exe";
                }

                string resCompiler;

                if (!fastBuildCompilerSettings.ResCompiler.TryGetValue(devEnv, out resCompiler))
                {
                    resCompiler = devEnv.GetWindowsResourceCompiler(Platform.win64);
                }

                string capitalizedBinPath = Util.GetCapitalizedPath(Util.PathGetAbsolute(projectRootPath, binPath));

                configurations.Add(
                    configName,
                    new CompilerSettings.Configuration(
                        Platform.win64,
                        binPath: capitalizedBinPath,
                        linkerPath: Util.GetCapitalizedPath(Util.PathGetAbsolute(projectRootPath, linkerPath)),
                        resourceCompiler: Util.GetCapitalizedPath(Util.PathGetAbsolute(projectRootPath, resCompiler)),
                        librarian: Path.Combine(@"$LinkerPath$", librarianExe),
                        linker: Path.Combine(@"$LinkerPath$", linkerExe)
                        )
                    );

                string masmConfigurationName = configName + "Masm";
                var    masmConfiguration     = new CompilerSettings.Configuration(
                    Platform.win64,
                    compiler: "ML" + masmConfigurationName,
                    usingOtherConfiguration: configName
                    );

                masmConfiguration.Masm = Path.Combine(capitalizedBinPath, "ml64.exe");

                configurations.Add(
                    masmConfigurationName,
                    masmConfiguration
                    );
            }
示例#17
0
 public static bool IsUsingClang(this Platform platform)
 {
     return(PlatformRegistry.Get <IPlatformDescriptor>(platform).IsUsingClang);
 }
示例#18
0
 public static bool IsMicrosoft(this Platform platform)
 {
     return(PlatformRegistry.Get <IPlatformDescriptor>(platform).IsMicrosoftPlatform);
 }
示例#19
0
            private void SetConfiguration(
                Project.Configuration conf,
                IDictionary <string, CompilerSettings.Configuration> configurations,
                string configName,
                string projectRootPath,
                DevEnv devEnv,
                bool useCCompiler
                )
            {
                string linkerPathOverride   = null;
                string linkerExeOverride    = null;
                string librarianExeOverride = null;

                GetLinkerExecutableInfo(conf, out linkerPathOverride, out linkerExeOverride, out librarianExeOverride);

                if (!configurations.ContainsKey(configName))
                {
                    var    fastBuildCompilerSettings = PlatformRegistry.Get <IFastBuildCompilerSettings>(Platform.durango);
                    string binPath;
                    if (!fastBuildCompilerSettings.BinPath.TryGetValue(devEnv, out binPath))
                    {
                        binPath = devEnv.GetDurangoBinPath();
                    }

                    string linkerPath;
                    if (!string.IsNullOrEmpty(linkerPathOverride))
                    {
                        linkerPath = linkerPathOverride;
                    }
                    else if (!fastBuildCompilerSettings.LinkerPath.TryGetValue(devEnv, out linkerPath))
                    {
                        linkerPath = binPath;
                    }

                    string linkerExe;
                    if (!string.IsNullOrEmpty(linkerExeOverride))
                    {
                        linkerExe = linkerExeOverride;
                    }
                    else if (!fastBuildCompilerSettings.LinkerExe.TryGetValue(devEnv, out linkerExe))
                    {
                        linkerExe = "link.exe";
                    }

                    string librarianExe;
                    if (!string.IsNullOrEmpty(librarianExeOverride))
                    {
                        librarianExe = librarianExeOverride;
                    }
                    else if (!fastBuildCompilerSettings.LibrarianExe.TryGetValue(devEnv, out librarianExe))
                    {
                        librarianExe = "lib.exe";
                    }

                    configurations.Add(
                        configName,
                        new CompilerSettings.Configuration(
                            Platform.durango,
                            binPath: Sharpmake.Util.GetCapitalizedPath(Sharpmake.Util.PathGetAbsolute(projectRootPath, binPath)),
                            linkerPath: Sharpmake.Util.GetCapitalizedPath(Sharpmake.Util.PathGetAbsolute(projectRootPath, linkerPath)),
                            librarian: Path.Combine(@"$LinkerPath$", librarianExe),
                            linker: Path.Combine(@"$LinkerPath$", linkerExe)
                            )
                        );

                    configurations.Add(
                        configName + "Masm",
                        new CompilerSettings.Configuration(
                            Platform.durango,
                            compiler: @"$BinPath$\ml64.exe",
                            usingOtherConfiguration: configName
                            )
                        );
                }
            }
示例#20
0
 public override bool AddLibPrefix(Configuration conf)
 {
     return(PlatformRegistry.GetDefault <IPlatformBff>().AddLibPrefix(conf));
 }