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

                if (Options.GetObject <Options.Vc.General.PlatformToolset>(context.Configuration).IsLLVMToolchain() && Options.GetObject <Options.Vc.LLVM.UseClangCl>(context.Configuration) == Options.Vc.LLVM.UseClangCl.Enable)
                {
                    includePrefix = "/clang:-isystem";
                    string clangIncludePath = ClangForWindows.GetWindowsClangIncludePath();
                    includes.Add(new IncludeWithPrefix(includePrefix, clangIncludePath));
                }

                // when using clang-cl, mark MSVC includes, so they are properly recognized
                IEnumerable <string> msvcIncludePaths = EnumerateSemiColonSeparatedString(context.DevelopmentEnvironment.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);
            }
            public override void SetupSdkOptions(IGenerationContext context)
            {
                var conf   = context.Configuration;
                var devEnv = context.DevelopmentEnvironment;

                // We need to override the executable path for vs2015 because WindowsKit UAP.props does not
                // correctly set the WindowsSDK_ExecutablePath to the bin folder of its current version.
                if (devEnv == DevEnv.vs2015 && !KitsRootPaths.UsesDefaultKitRoot(devEnv))
                {
                    context.Options["ExecutablePath"] = devEnv.GetWindowsExecutablePath(conf.Platform);
                }

                var systemIncludes = new OrderableStrings(conf.DependenciesIncludeSystemPaths);

                systemIncludes.AddRange(conf.IncludeSystemPaths);
                if (systemIncludes.Count > 0)
                {
                    systemIncludes.Sort();
                    if (context.Options["IncludePath"] == FileGeneratorUtilities.RemoveLineTag)
                    {
                        context.Options["IncludePath"] = "$(VC_IncludePath);$(WindowsSDK_IncludePath);" + systemIncludes.JoinStrings(";");
                    }
                    else
                    {
                        context.Options["IncludePath"] += ";" + systemIncludes.JoinStrings(";");
                    }
                }
            }
Exemple #3
0
        public void AddRange(OrderableStrings collection, int outerOrderNumber = 0, OrderResolve resolveMethod = OrderResolve.None)
        {
            List <StringEntry> existingEntriesToAdd = null;

            foreach (var entry in collection._list)
            {
                var newEntry = new StringEntry(entry.StringValue, entry.OrderNumber + outerOrderNumber);

                if (_hashSet.Add(entry.StringValue))
                {
                    _list.Add(newEntry);
                }
                else if (newEntry.OrderNumber != 0)  // make sure to have orderNumber
                {
                    if (existingEntriesToAdd == null)
                    {
                        existingEntriesToAdd = new List <StringEntry>();
                    }
                    existingEntriesToAdd.Add(newEntry);
                }
            }
            if (existingEntriesToAdd != null)
            {
                Dictionary <string, int> dict = GetStringToOrderNumberDictionary(existingEntriesToAdd);
                for (int i = 0; i < _list.Count; ++i)
                {
                    int orderNumber;
                    if (dict.TryGetValue(_list[i].StringValue, out orderNumber))
                    {
                        if (_list[i].OrderNumber == 0)
                        {
                            _list[i] = new StringEntry(_list[i].StringValue, orderNumber);
                        }
                        else if (_list[i].OrderNumber != orderNumber)
                        {
                            if (resolveMethod == OrderResolve.Less)
                            {
                                if (orderNumber < _list[i].OrderNumber)
                                {
                                    _list[i] = new StringEntry(_list[i].StringValue, orderNumber);
                                }
                            }
                            else if (resolveMethod == OrderResolve.Greater)
                            {
                                if (orderNumber > _list[i].OrderNumber)
                                {
                                    _list[i] = new StringEntry(_list[i].StringValue, orderNumber);
                                }
                            }
                            else
                            {
                                throw new Error(
                                          "Cannot specify 2 different non-zero order number for \"" +
                                          _list[i].StringValue + "\": " + _list[i].OrderNumber + " and " + orderNumber);
                            }
                        }
                    }
                }
            }
        }
Exemple #4
0
 internal static void ResolvePathAndFixCase(string root, ref OrderableStrings paths)
 {
     for (int i = 0; i < paths.Count; ++i)
     {
         string fixedCase = ResolvePathAndFixCase(root, paths[i]);
         i = paths.SetOrRemoveAtIndex(i, fixedCase);
     }
     paths.Sort();
 }
Exemple #5
0
 public static void ResolvePath(string root, ref OrderableStrings paths)
 {
     for (int i = 0; i < paths.Count; ++i)
     {
         string resolvedPath = ResolvePath(root, paths[i]);
         i = paths.SetOrRemoveAtIndex(i, resolvedPath);
     }
     paths.Sort();
 }
Exemple #6
0
        protected virtual IEnumerable<string> GetResourceIncludePathsImpl(IGenerationContext context)
        {
            var resourceIncludePaths = new OrderableStrings();
            resourceIncludePaths.AddRange(context.Configuration.ResourceIncludePrivatePaths);
            resourceIncludePaths.AddRange(context.Configuration.ResourceIncludePaths);
            resourceIncludePaths.AddRange(context.Configuration.DependenciesResourceIncludePaths);

            return resourceIncludePaths;
        }
            public override void SetupSdkOptions(IGenerationContext context)
            {
                var conf   = context.Configuration;
                var devEnv = context.DevelopmentEnvironment;

                // vs2012 and vs2013 do not support overriding windows kits using the underlying variables
                // so we need to change the VC++ directories path.
                // We need to override the executable path for vs2015 because WindowsKit UAP.props does not
                // correctly set the WindowsSDK_ExecutablePath to the bin folder of its current version.
                if ((devEnv == DevEnv.vs2012 || devEnv == DevEnv.vs2013 || devEnv == DevEnv.vs2015) && !KitsRootPaths.UsesDefaultKitRoot(devEnv))
                {
                    var options = context.Options;
                    options["ExecutablePath"] = devEnv.GetWindowsExecutablePath(conf.Platform);
                    if (devEnv != DevEnv.vs2015)
                    {
                        options["IncludePath"] = devEnv.GetWindowsIncludePath();
                        options["LibraryPath"] = devEnv.GetWindowsLibraryPath(conf.Platform, Util.IsDotNet(conf) ? conf.Target.GetFragment <DotNetFramework>() : default(DotNetFramework?));
                        options["ExcludePath"] = devEnv.GetWindowsIncludePath();
                    }
                }

                Options.Vc.General.PlatformToolset platformToolset = Options.GetObject <Options.Vc.General.PlatformToolset>(conf);
                if (platformToolset.IsLLVMToolchain())
                {
                    Options.Vc.General.PlatformToolset overridenPlatformToolset = Options.Vc.General.PlatformToolset.Default;
                    if (Options.WithArgOption <Options.Vc.General.PlatformToolset> .Get <Options.Clang.Compiler.LLVMVcPlatformToolset>(conf, ref overridenPlatformToolset))
                    {
                        platformToolset = overridenPlatformToolset;
                    }

                    devEnv = platformToolset.GetDefaultDevEnvForToolset() ?? devEnv;

                    context.Options["ExecutablePath"] = ClangForWindows.GetWindowsClangExecutablePath() + ";" + devEnv.GetWindowsExecutablePath(conf.Platform);
                    if (Options.GetObject <Options.Vc.LLVM.UseClangCl>(conf) == Options.Vc.LLVM.UseClangCl.Enable)
                    {
                        context.Options["IncludePath"] = ClangForWindows.GetWindowsClangIncludePath() + ";" + devEnv.GetWindowsIncludePath();
                        context.Options["LibraryPath"] = ClangForWindows.GetWindowsClangLibraryPath() + ";" + devEnv.GetWindowsLibraryPath(conf.Platform, Util.IsDotNet(conf) ? conf.Target.GetFragment <DotNetFramework>() : default(DotNetFramework?));
                    }
                }

                var systemIncludes = new OrderableStrings(conf.DependenciesIncludeSystemPaths);

                systemIncludes.AddRange(conf.IncludeSystemPaths);
                if (systemIncludes.Count > 0)
                {
                    systemIncludes.Sort();
                    if (context.Options["IncludePath"] == FileGeneratorUtilities.RemoveLineTag)
                    {
                        context.Options["IncludePath"] = "$(VC_IncludePath);$(WindowsSDK_IncludePath);" + systemIncludes.JoinStrings(";");
                    }
                    else
                    {
                        context.Options["IncludePath"] += ";" + systemIncludes.JoinStrings(";");
                    }
                }
            }
Exemple #8
0
        public static OrderableStrings PathGetRelative(string sourceFullPath, IEnumerable <string> destFullPaths, bool ignoreCase = false)
        {
            OrderableStrings result = new OrderableStrings(destFullPaths);

            for (int i = 0; i < result.Count; ++i)
            {
                result[i] = PathGetRelative(sourceFullPath, result[i], ignoreCase);
            }
            return(result);
        }
Exemple #9
0
        public static OrderableStrings PathGetCapitalized(OrderableStrings fullPaths)
        {
            OrderableStrings result = new OrderableStrings(fullPaths);

            for (int i = 0; i < result.Count; ++i)
            {
                result[i] = GetCapitalizedPath(result[i]);
            }
            return(result);
        }
Exemple #10
0
        protected virtual IEnumerable<string> GetIncludePathsImpl(IGenerationContext context)
        {
            var includePaths = new OrderableStrings();
            includePaths.AddRange(context.Configuration.IncludePrivatePaths);
            includePaths.AddRange(context.Configuration.IncludePaths);
            includePaths.AddRange(context.Configuration.DependenciesIncludePaths);

            includePaths.Sort();
            return includePaths;
        }
Exemple #11
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);
            }
Exemple #12
0
            protected override IEnumerable <string> GetIncludePathsImpl(IGenerationContext context)
            {
                var includePaths1 = new OrderableStrings();

                var includePaths2 = new OrderableStrings();

                includePaths2.AddRange(context.Configuration.IncludePrivatePaths);
                includePaths2.AddRange(context.Configuration.IncludePaths);
                includePaths2.AddRange(context.Configuration.DependenciesIncludePaths);

                Options.Vc.RemoteBuild.RelativeDirectory relativeDirectoryOption = Options.GetObject <Options.Vc.RemoteBuild.RelativeDirectory>(context.Configuration);
                if (relativeDirectoryOption != null)
                {
                    string basePath = relativeDirectoryOption.Value.TrimEnd(Util.WindowsSeparator);

                    Options.Vc.RemoteBuild.ProjectDirectory projectDirectoryOption = Options.GetObject <Options.Vc.RemoteBuild.ProjectDirectory>(context.Configuration);
                    if (projectDirectoryOption != null)
                    {
                        basePath += Util.WindowsSeparator + projectDirectoryOption.Value.TrimEnd(Util.WindowsSeparator);
                    }

                    for (int i = 0; i < includePaths2.Count; ++i)
                    {
                        string includePath = includePaths2[i];

                        foreach (var variable in Options.GetObjects <Options.Vc.RemoteBuild.Variable>(context.Configuration))
                        {
                            includePath = includePath.Replace(@"$(" + variable.Key + @")", variable.Value);
                        }

                        string remotePath = Util.PathGetRelative(basePath, includePath.TrimEnd(Util.WindowsSeparator));

                        if (remotePath != includePath)
                        {
                            includePaths1.Add(remotePath);
                        }
                    }
                }

                includePaths1.AddRange(includePaths2);

                return(includePaths1);
            }
            public override void SetupSdkOptions(IGenerationContext context)
            {
                var conf   = context.Configuration;
                var devEnv = context.DevelopmentEnvironment;

                // vs2012 and vs2013 do not support overriding windows kits using the underlying variables
                // so we need to change the VC++ directories path.
                // We need to override the executable path for vs2015 because WindowsKit UAP.props does not
                // correctly set the WindowsSDK_ExecutablePath to the bin folder of its current version.
                if ((devEnv == DevEnv.vs2012 || devEnv == DevEnv.vs2013 || devEnv == DevEnv.vs2015) && !KitsRootPaths.UsesDefaultKitRoot(devEnv))
                {
                    var options = context.Options;
                    options["ExecutablePath"] = devEnv.GetWindowsExecutablePath(conf.Platform);
                    if (devEnv != DevEnv.vs2015)
                    {
                        options["IncludePath"] = devEnv.GetWindowsIncludePath();
                        options["LibraryPath"] = devEnv.GetWindowsLibraryPath(conf.Platform, Util.IsDotNet(conf) ? conf.Target.GetFragment <DotNetFramework>() : default(DotNetFramework?));
                        options["ExcludePath"] = devEnv.GetWindowsIncludePath();
                    }
                }

                var systemIncludes = new OrderableStrings(conf.DependenciesIncludeSystemPaths);

                systemIncludes.AddRange(conf.IncludeSystemPaths);
                if (systemIncludes.Count > 0)
                {
                    systemIncludes.Sort();
                    if (context.Options["IncludePath"] == FileGeneratorUtilities.RemoveLineTag)
                    {
                        context.Options["IncludePath"] = "$(VC_IncludePath);$(WindowsSDK_IncludePath);" + systemIncludes.JoinStrings(";");
                    }
                    else
                    {
                        context.Options["IncludePath"] += ";" + systemIncludes.JoinStrings(";");
                    }
                }
            }
Exemple #14
0
 public OrderableStrings(OrderableStrings other)
 {
     _list.AddRange(other._list);
     _hashSet.UnionWith(other._hashSet);
 }
Exemple #15
0
            public override void SetupSdkOptions(IGenerationContext context)
            {
                var conf   = context.Configuration;
                var devEnv = context.DevelopmentEnvironment;

                // We need to override the executable path for vs2015 because WindowsKit UAP.props does not
                // correctly set the WindowsSDK_ExecutablePath to the bin folder of its current version.
                if (devEnv == DevEnv.vs2015 && !KitsRootPaths.UsesDefaultKitRoot(devEnv))
                {
                    context.Options["ExecutablePath"] = devEnv.GetWindowsExecutablePath(conf.Platform);
                }

                Options.Vc.General.PlatformToolset platformToolset = Options.GetObject <Options.Vc.General.PlatformToolset>(conf);
                if (Options.Vc.General.PlatformToolset.LLVM == platformToolset)
                {
                    Options.Vc.General.PlatformToolset overridenPlatformToolset = Options.Vc.General.PlatformToolset.Default;
                    if (Options.WithArgOption <Options.Vc.General.PlatformToolset> .Get <Options.Clang.Compiler.LLVMVcPlatformToolset>(conf, ref overridenPlatformToolset))
                    {
                        platformToolset = overridenPlatformToolset;
                    }

                    devEnv = platformToolset.GetDefaultDevEnvForToolset() ?? devEnv;

                    context.Options["ExecutablePath"] = ClangForWindows.GetWindowsClangExecutablePath() + ";" + devEnv.GetWindowsExecutablePath(conf.Platform);
                    if (Options.GetObject <Options.Vc.LLVM.UseClangCl>(conf) == Options.Vc.LLVM.UseClangCl.Enable)
                    {
                        context.Options["IncludePath"] = ClangForWindows.GetWindowsClangIncludePath() + ";" + devEnv.GetWindowsIncludePath();
                        context.Options["LibraryPath"] = ClangForWindows.GetWindowsClangLibraryPath() + ";" + devEnv.GetWindowsLibraryPath(conf.Platform, Util.IsDotNet(conf) ? conf.Target.GetFragment <DotNetFramework>() : default(DotNetFramework?));
                    }
                }

                var systemIncludes = new OrderableStrings(conf.DependenciesIncludeSystemPaths);

                systemIncludes.AddRange(conf.IncludeSystemPaths);
                if (systemIncludes.Count > 0)
                {
                    systemIncludes.Sort();
                    string systemIncludesString = Util.PathGetRelative(context.ProjectDirectory, systemIncludes).JoinStrings(";");

                    // 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>(conf))
                    {
                        if (context.Options["ExternalIncludePath"] == FileGeneratorUtilities.RemoveLineTag)
                        {
                            context.Options["ExternalIncludePath"] = systemIncludesString;
                        }
                        else
                        {
                            context.Options["ExternalIncludePath"] += ";" + systemIncludesString;
                        }
                    }
                    else
                    {
                        if (context.Options["IncludePath"] == FileGeneratorUtilities.RemoveLineTag)
                        {
                            context.Options["IncludePath"] = "$(VC_IncludePath);$(WindowsSDK_IncludePath);" + systemIncludesString;
                        }
                        else
                        {
                            context.Options["IncludePath"] += ";" + systemIncludesString;
                        }
                    }
                }
            }
Exemple #16
0
            public override void SelectPlatformAdditionalDependenciesOptions(IGenerationContext context)
            {
                context.Options["AdditionalLibraryDirectories"] = FileGeneratorUtilities.RemoveLineTag;
                context.Options["AdditionalDependencies"]       = FileGeneratorUtilities.RemoveLineTag;
                context.Options["LibraryDependencies"]          = FileGeneratorUtilities.RemoveLineTag;

                context.CommandLineOptions["AdditionalDependencies"]       = FileGeneratorUtilities.RemoveLineTag;
                context.CommandLineOptions["AdditionalLibraryDirectories"] = FileGeneratorUtilities.RemoveLineTag;
                context.CommandLineOptions["LibraryDependencies"]          = FileGeneratorUtilities.RemoveLineTag;

                var dependencies = new List <Project.Configuration>();

                dependencies.AddRange(context.Configuration.ResolvedPublicDependencies);

                // Sort by the number of dependencies to get a good starting point
                dependencies.Sort((Project.Configuration d0, Project.Configuration d1) =>
                {
                    return(d1.ProjectGuidDependencies.Count.CompareTo(d0.ProjectGuidDependencies.Count));
                });

                var libPaths = new OrderableStrings();
                var libFiles = new OrderableStrings();

                foreach (var dependency in dependencies)
                {
                    string outputFileName = dependency.TargetFileName;

                    string outputPrefix = GetOutputFileNamePrefix(context, dependency.Output);
                    if (!string.IsNullOrEmpty(outputPrefix))
                    {
                        outputFileName = outputPrefix + outputFileName;
                    }

                    string outputExtension = GetDefaultOutputExtension(dependency.Output);
                    if (!string.IsNullOrEmpty(outputExtension))
                    {
                        outputFileName = outputFileName + "." + outputExtension;
                    }

                    string libPath = dependency.IntermediatePath + Util.WindowsSeparator + outputFileName;

                    foreach (var variable in Options.GetObjects <Options.Vc.RemoteBuild.Variable>(context.Configuration))
                    {
                        libPath = libPath.Replace(@"$(" + variable.Key + @")", variable.Value);
                    }

                    string remotePath = Util.PathGetRelative(dependency.ProjectPath.TrimEnd(Util.WindowsSeparator), libPath.TrimEnd(Util.WindowsSeparator));

                    Options.Vc.RemoteBuild.ProjectDirectory projectDirectoryOption = Options.GetObject <Options.Vc.RemoteBuild.ProjectDirectory>(dependency);
                    if (projectDirectoryOption != null)
                    {
                        remotePath = projectDirectoryOption.Value.TrimEnd(Util.WindowsSeparator) + Util.WindowsSeparator + remotePath;

                        // Unlike the include paths, this needs the RemoteRootDir variable and unix separators
                        remotePath = @"$(RemoteRootDir)" + Util.UnixSeparator + remotePath.Replace(Util.WindowsSeparator, Util.UnixSeparator);

                        libPaths.Add(remotePath);
                    }
                }

                foreach (var file in context.Configuration.LibraryFiles)
                {
                    if (file.Contains(Util.WindowsSeparator.ToString()))
                    {
                        string libPath = file;

                        Options.Vc.RemoteBuild.RelativeDirectory relativeDirectoryOption = Options.GetObject <Options.Vc.RemoteBuild.RelativeDirectory>(context.Configuration);
                        if (relativeDirectoryOption != null)
                        {
                            string basePath = relativeDirectoryOption.Value.TrimEnd(Util.WindowsSeparator);

                            foreach (var variable in Options.GetObjects <Options.Vc.RemoteBuild.Variable>(context.Configuration))
                            {
                                libPath = libPath.Replace(@"$(" + variable.Key + @")", variable.Value);
                            }

                            string remotePath = Util.PathGetRelative(basePath, libPath.TrimEnd(Util.WindowsSeparator));

                            remotePath = @"$(RemoteRootDir)" + Util.UnixSeparator + remotePath.Replace(Util.WindowsSeparator, Util.UnixSeparator);

                            libPaths.Add(remotePath);
                        }
                    }
                    else
                    {
                        libFiles.Add(file);
                    }
                }

                context.Options["AdditionalDependencies"] = string.Join(";", libPaths);
                context.Options["LibraryDependencies"]    = string.Join(";", libFiles);
            }