Пример #1
0
        private static void SetupMacOptions(ParserOptions options)
        {
            options.MicrosoftMode     = false;
            options.NoBuiltinIncludes = true;

            if (Platform.IsMacOS)
            {
                var headersPaths = new List <string> {
                    Path.Combine(GetSourceDirectory("deps"), "llvm/tools/clang/lib/Headers"),
                    Path.Combine(GetSourceDirectory("deps"), "libcxx", "include"),
                    "/usr/include",
                };

                foreach (var header in headersPaths)
                {
                    Console.WriteLine(header);
                }

                foreach (var header in headersPaths)
                {
                    options.AddSystemIncludeDirs(header);
                }
            }

            var headersPath = Path.Combine(GetSourceDirectory("build"), "headers",
                                           "osx");

            options.AddSystemIncludeDirs(Path.Combine(headersPath, "include"));
            options.AddSystemIncludeDirs(Path.Combine(headersPath, "clang", "4.2", "include"));
            options.AddSystemIncludeDirs(Path.Combine(headersPath, "libcxx", "include"));
            options.AddArguments("-stdlib=libc++");
        }
Пример #2
0
        private static void SetupMacOptions(ParserOptions options)
        {
            options.MicrosoftMode     = false;
            options.NoBuiltinIncludes = true;

            var headersPath = Path.Combine(GetSourceDirectory("build"), "headers",
                                           "osx");

            options.AddSystemIncludeDirs(Path.Combine(headersPath, "libcxx", "include"));
            options.AddSystemIncludeDirs(options.BuiltinsDir);
            options.AddSystemIncludeDirs(Path.Combine(headersPath, "include"));
            options.AddArguments("-stdlib=libc++");
        }
Пример #3
0
        private void SetupLinuxOptions(ParserOptions parserOptions)
        {
            parserOptions.MicrosoftMode     = false;
            parserOptions.NoBuiltinIncludes = true;

            var headersPath = string.Empty;

            // Search for the available GCC versions on the provided headers.
            var versions = Directory.EnumerateDirectories(Path.Combine(headersPath, "usr/include/c++"));

            if (versions.Count() == 0)
            {
                throw new Exception("No valid GCC version found on system include paths");
            }

            string gccVersionPath = versions.First();
            string gccVersion     = gccVersionPath.Substring(gccVersionPath.LastIndexOf(Path.DirectorySeparatorChar) + 1);

            string[] systemIncludeDirs =
            {
                Path.Combine("usr", "include", "c++",               gccVersion),
                Path.Combine("usr", "include", "x86_64-linux-gnu",  "c++",             gccVersion),
                Path.Combine("usr", "include", "c++",               gccVersion,        "backward"),
                Path.Combine("usr", "lib",     "gcc",               "x86_64-linux-gnu",gccVersion,  "include"),
                Path.Combine("usr", "include", "x86_64-linux-gnu"),
                Path.Combine("usr", "include")
            };

            foreach (var dir in systemIncludeDirs)
            {
                parserOptions.AddSystemIncludeDirs(Path.Combine(headersPath, dir));
            }

            parserOptions.AddDefines("_GLIBCXX_USE_CXX11_ABI=" + (options.Cpp11ABI ? "1" : "0"));
        }
Пример #4
0
        private static void SetupMacOptions(ParserOptions options)
        {
            options.MicrosoftMode = false;
            options.NoBuiltinIncludes = true;

            if (Platform.IsMacOS)
            {
                var headersPaths = new List<string> {
                    "/usr/include"
                };

                foreach (var header in headersPaths)
                    options.AddSystemIncludeDirs(header);
            }

            options.AddArguments("-stdlib=libc++");
        }
Пример #5
0
        public ParserOptions BuildParserOptions(SourceFile file = null)
        {
            var options = new ParserOptions
            {
                Abi                = ParserOptions.Abi,
                ToolSetToUse       = ParserOptions.ToolSetToUse,
                TargetTriple       = ParserOptions.TargetTriple,
                NoStandardIncludes = ParserOptions.NoStandardIncludes,
                NoBuiltinIncludes  = ParserOptions.NoBuiltinIncludes,
                MicrosoftMode      = ParserOptions.MicrosoftMode,
                Verbose            = ParserOptions.Verbose,
                LanguageVersion    = ParserOptions.LanguageVersion
            };

            // This eventually gets passed to Clang's MSCompatibilityVersion, which
            // is in turn used to derive the value of the built-in define _MSC_VER.
            // It used to receive a 4-digit based identifier but now expects a full
            // version MSVC digit, so check if we still have the old version and
            // convert to the right format.

            if (ParserOptions.ToolSetToUse.ToString(CultureInfo.InvariantCulture).Length == 4)
            {
                ParserOptions.ToolSetToUse *= 100000;
            }

            for (uint i = 0; i < ParserOptions.ArgumentsCount; ++i)
            {
                var arg = ParserOptions.GetArguments(i);
                options.AddArguments(arg);
            }

            for (uint i = 0; i < ParserOptions.IncludeDirsCount; ++i)
            {
                var include = ParserOptions.GetIncludeDirs(i);
                options.AddIncludeDirs(include);
            }

            for (uint i = 0; i < ParserOptions.SystemIncludeDirsCount; ++i)
            {
                var include = ParserOptions.GetSystemIncludeDirs(i);
                options.AddSystemIncludeDirs(include);
            }

            for (uint i = 0; i < ParserOptions.DefinesCount; ++i)
            {
                var define = ParserOptions.GetDefines(i);
                options.AddDefines(define);
            }

            for (uint i = 0; i < ParserOptions.UndefinesCount; ++i)
            {
                var define = ParserOptions.GetUndefines(i);
                options.AddUndefines(define);
            }

            for (uint i = 0; i < ParserOptions.LibraryDirsCount; ++i)
            {
                var lib = ParserOptions.GetLibraryDirs(i);
                options.AddLibraryDirs(lib);
            }

            foreach (var module in Options.Modules.Where(
                         m => file == null || m.Headers.Contains(file.Path)))
            {
                foreach (var include in module.IncludeDirs)
                {
                    options.AddIncludeDirs(include);
                }

                foreach (var define in module.Defines)
                {
                    options.AddDefines(define);
                }

                foreach (var undefine in module.Undefines)
                {
                    options.AddUndefines(undefine);
                }

                foreach (var libraryDir in module.LibraryDirs)
                {
                    options.AddLibraryDirs(libraryDir);
                }
            }

            return(options);
        }