예제 #1
0
파일: Driver.cs 프로젝트: embtest/CppSharp
        void ValidateOptions()
        {
            if (!Options.Compilation.Platform.HasValue)
            {
                Options.Compilation.Platform = Platform.Host;
            }

            foreach (var module in Options.Modules)
            {
                if (string.IsNullOrWhiteSpace(module.LibraryName))
                {
                    throw new InvalidOptionException("One of your modules has no library name.");
                }

                if (module.OutputNamespace == null)
                {
                    module.OutputNamespace = module.LibraryName;
                }

                for (int i = 0; i < module.IncludeDirs.Count; i++)
                {
                    var dir = new DirectoryInfo(module.IncludeDirs[i]);
                    module.IncludeDirs[i] = dir.FullName;
                }
            }

            if (Options.NoGenIncludeDirs != null)
            {
                foreach (var incDir in Options.NoGenIncludeDirs)
                {
                    ParserOptions.AddIncludeDirs(incDir);
                }
            }
        }
예제 #2
0
        void ValidateOptions()
        {
            foreach (var module in Options.Modules)
            {
                if (string.IsNullOrWhiteSpace(module.LibraryName))
                {
                    throw new InvalidOptionException("One of your modules has no library name.");
                }

                if (module.OutputNamespace == null)
                {
                    module.OutputNamespace = module.LibraryName;
                }
            }

            if (Options.NoGenIncludeDirs != null)
            {
                foreach (var incDir in Options.NoGenIncludeDirs)
                {
                    ParserOptions.AddIncludeDirs(incDir);
                }
            }
        }
예제 #3
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);
        }