예제 #1
0
            protected override IEnumerable <IncludeWithPrefix> GetPlatformIncludePathsWithPrefixImpl(IGenerationContext context)
            {
                var    includes      = new List <IncludeWithPrefix>();
                string includePrefix = "/I";

                var    platformToolset = Options.GetObject <Options.Vc.General.PlatformToolset>(context.Configuration);
                DevEnv devEnv          = platformToolset.GetDefaultDevEnvForToolset() ?? context.DevelopmentEnvironment;

                if (platformToolset.IsLLVMToolchain() && Options.GetObject <Options.Vc.LLVM.UseClangCl>(context.Configuration) == Options.Vc.LLVM.UseClangCl.Enable)
                {
                    // when using clang-cl, mark MSVC includes, so they are properly recognized
                    includePrefix = "/clang:-isystem";

                    Options.Vc.General.PlatformToolset overridenPlatformToolset = Options.Vc.General.PlatformToolset.Default;
                    if (Options.WithArgOption <Options.Vc.General.PlatformToolset> .Get <Options.Clang.Compiler.LLVMVcPlatformToolset>(context.Configuration, ref overridenPlatformToolset))
                    {
                        platformToolset = overridenPlatformToolset;
                        devEnv          = platformToolset.GetDefaultDevEnvForToolset() ?? context.DevelopmentEnvironment;
                    }

                    string clangIncludePath = platformToolset == Options.Vc.General.PlatformToolset.ClangCL ? ClangForWindows.GetWindowsClangIncludePath(devEnv) : ClangForWindows.GetWindowsClangIncludePath();
                    includes.Add(new IncludeWithPrefix(includePrefix, clangIncludePath));
                }
                else
                {
                    // this option is mandatory when using /external:I with msvc, so if the user has selected it
                    // we consider that the vcxproj supports ExternalIncludePath
                    if (Options.HasOption <Options.Vc.General.ExternalWarningLevel>(context.Configuration))
                    {
                        includePrefix = "/external:I";
                    }
                }

                IEnumerable <string> msvcIncludePaths = EnumerateSemiColonSeparatedString(devEnv.GetWindowsIncludePath());

                includes.AddRange(msvcIncludePaths.Select(path => new IncludeWithPrefix(includePrefix, path)));

                // Additional system includes
                OrderableStrings SystemIncludes = new OrderableStrings(context.Configuration.DependenciesIncludeSystemPaths);

                SystemIncludes.AddRange(context.Configuration.IncludeSystemPaths);
                if (SystemIncludes.Count > 0)
                {
                    SystemIncludes.Sort();
                    includes.AddRange(SystemIncludes.Select(path => new IncludeWithPrefix(includePrefix, path)));
                }
                return(includes);
            }