Exemple #1
0
        public static string CmdExceptionHandling(cppExceptionHandling handling)
        {
            switch (handling)
            {
            case cppExceptionHandling.cppExceptionHandlingNo:
                return("/EHc-s-");

            case cppExceptionHandling.cppExceptionHandlingYes:
                return("/EHcs");

            case cppExceptionHandling.cppExceptionHandlingYesWithSEH:
                return("/EHa");
            }
            return(null);
        }
Exemple #2
0
        /// <summary>
        /// Finds compiler vs flags
        /// </summary>
        private void parseCompilerSettings_CompilerFlags(VCConfiguration vcConfiguration, VCCLCompilerTool compilerTool, ProjectConfigurationInfo_CPP configurationInfo)
        {
            // Compile without link
            configurationInfo.addCompilerFlag("/c");

            // Support big object file
            configurationInfo.addCompilerFlag("/bigobj");

            #region General
            // - Resolve #using Reference (TODO)

            // - Debug Information format
            configurationInfo.addCompilerFlag("/Z7"); //< Make debug info always is /Z7

            // - Common Language RunTime Support (TODO)

            // - Suppress Startup Banner
            bool supressStartupBanner = Utils.call(() => (compilerTool.SuppressStartupBanner));
            if (supressStartupBanner)
            {
                configurationInfo.addCompilerFlag("/nologo");
            }

            // - Warning Level
            warningLevelOption warningLevel = Utils.call(() => (compilerTool.WarningLevel));
            switch (warningLevel)
            {
            case warningLevelOption.warningLevel_0:
                configurationInfo.addCompilerFlag("/W0");
                break;

            case warningLevelOption.warningLevel_1:
                configurationInfo.addCompilerFlag("/W1");
                break;

            case warningLevelOption.warningLevel_2:
                configurationInfo.addCompilerFlag("/W2");
                break;

            case warningLevelOption.warningLevel_3:
                configurationInfo.addCompilerFlag("/W3");
                break;

            case warningLevelOption.warningLevel_4:
                configurationInfo.addCompilerFlag("/W4");
                break;
            }

            // - Treat Warnings As Error
            bool warningsAsErrors = Utils.call(() => (compilerTool.WarnAsError));
            if (warningsAsErrors == true)
            {
                configurationInfo.addCompilerFlag("/WX");
            }

            // - Multi-processor Compilation (TODO)
            // - Use Unicode For Assembler Listing (TODO)

            #endregion

            #region Optimization:
            // - Optimization
            optimizeOption optimize = Utils.call(() => (compilerTool.Optimization));
            switch (optimize)
            {
            case optimizeOption.optimizeDisabled:
                configurationInfo.addCompilerFlag("/Od");
                break;

            case optimizeOption.optimizeFull:
                configurationInfo.addCompilerFlag("/Ox");
                break;

            case optimizeOption.optimizeMinSpace:
                configurationInfo.addCompilerFlag("/O1");
                break;

            case optimizeOption.optimizeMaxSpeed:
                configurationInfo.addCompilerFlag("/O2");
                break;
            }

            // - Inline Function Expansion
            inlineExpansionOption inlineExpansion = Utils.call(() => (compilerTool.InlineFunctionExpansion));
            switch (inlineExpansion)
            {
            case inlineExpansionOption.expandAnySuitable:
                configurationInfo.addCompilerFlag("/Ob2");
                break;

            case inlineExpansionOption.expandOnlyInline:
                configurationInfo.addCompilerFlag("/Ob1");
                break;
            }

            // - Enable Intrinsic Functions
            bool enableIntrinsic = Utils.call(() => (compilerTool.EnableIntrinsicFunctions));
            if (enableIntrinsic)
            {
                configurationInfo.addCompilerFlag("/Oi");
            }

            // - Favor Size Or Speed
            favorSizeOrSpeedOption favorSizeOrSpeed = Utils.call(() => (compilerTool.FavorSizeOrSpeed));
            switch (favorSizeOrSpeed)
            {
            case favorSizeOrSpeedOption.favorSize:
                configurationInfo.addCompilerFlag("/Os");
                break;

            case favorSizeOrSpeedOption.favorSpeed:
                configurationInfo.addCompilerFlag("/Ot");
                break;
            }

            // - Omit Frame Pointers (TODO)

            // - Enable Fiber-Safe Optimizations
            bool enableFiberSafe = Utils.call(() => (compilerTool.EnableFiberSafeOptimizations));
            if (enableFiberSafe)
            {
                configurationInfo.addCompilerFlag("/GT");
            }

            // - Whole Program Optimization
            bool wholeProgramOptimization = Utils.call(() => (compilerTool.WholeProgramOptimization));
            if (wholeProgramOptimization)
            {
                configurationInfo.addCompilerFlag("/GL");
            }
            #endregion

            #region Code Generation:
            // - Enable String Pooling (TODO)

            // - Enable Minimal Rebuild
            bool enableMinimalRebuild = Utils.call(() => (compilerTool.MinimalRebuild));
            if (enableMinimalRebuild)
            {
                configurationInfo.addCompilerFlag("/Gm");
            }
            else
            {
                configurationInfo.addCompilerFlag("/Gm-");
            }

            // - Enable C++ Exceptions
            cppExceptionHandling cppException = Utils.call(() => (compilerTool.ExceptionHandling));
            switch (cppException)
            {
            case cppExceptionHandling.cppExceptionHandlingYes:
                configurationInfo.addCompilerFlag("/EHsc");
                break;

            case cppExceptionHandling.cppExceptionHandlingYesWithSEH:
                configurationInfo.addCompilerFlag("/EHa");
                break;
            }

            // - Smaller Type Check (TODO)

            // - Basic Runtime Checks
            basicRuntimeCheckOption basicRuntimeCheck = Utils.call(() => (compilerTool.BasicRuntimeChecks));
            switch (basicRuntimeCheck)
            {
            case basicRuntimeCheckOption.runtimeBasicCheckAll:
                configurationInfo.addCompilerFlag("/RTC1");
                break;

            case basicRuntimeCheckOption.runtimeCheckStackFrame:
                configurationInfo.addCompilerFlag("/RTCs");
                break;

            case basicRuntimeCheckOption.runtimeCheckUninitVariables:
                configurationInfo.addCompilerFlag("/RTCu");
                break;
            }

            // - Runtime Library
            runtimeLibraryOption runtimeLibrary = Utils.call(() => (compilerTool.RuntimeLibrary));
            switch (runtimeLibrary)
            {
            case runtimeLibraryOption.rtMultiThreaded:
                configurationInfo.addCompilerFlag("/MT");
                break;

            case runtimeLibraryOption.rtMultiThreadedDebug:
                configurationInfo.addCompilerFlag("/MTd");
                break;

            case runtimeLibraryOption.rtMultiThreadedDebugDLL:
                configurationInfo.addCompilerFlag("/MDd");
                break;

            case runtimeLibraryOption.rtMultiThreadedDLL:
                configurationInfo.addCompilerFlag("/MD");
                break;
            }

            // - Struct Member Alignment (TODO)

            // - Buffer Security Check
            bool bufferSecurityCheck = Utils.call(() => (compilerTool.BufferSecurityCheck));
            if (bufferSecurityCheck)
            {
                configurationInfo.addCompilerFlag("/GS");
            }

            // - Enable Function-Level Linking
            bool functionLevelLink = Utils.call(() => (compilerTool.EnableFunctionLevelLinking));
            if (functionLevelLink)
            {
                configurationInfo.addCompilerFlag("/Gy");
            }

            // - Enable Enhanced Instruction Set
            enhancedInstructionSetType enhancedInstruction = Utils.call(() => (compilerTool.EnableEnhancedInstructionSet));;
            switch (enhancedInstruction)
            {
            case enhancedInstructionSetType.enhancedInstructionSetTypeSIMD:
                configurationInfo.addCompilerFlag("/arch:SSE");
                break;

            case enhancedInstructionSetType.enhancedInstructionSetTypeSIMD2:
                configurationInfo.addCompilerFlag("/arch:SSE2");
                break;
            }

            // - Floating Point Model
            floatingPointModel floatingPoint = Utils.call(() => (compilerTool.floatingPointModel));
            switch (floatingPoint)
            {
            case floatingPointModel.FloatingPointFast:
                configurationInfo.addCompilerFlag("/fp:fast");
                break;

            case floatingPointModel.FloatingPointPrecise:
                configurationInfo.addCompilerFlag("/fp:precise");
                break;

            case floatingPointModel.FloatingPointStrict:
                configurationInfo.addCompilerFlag("/fp:strict");
                break;
            }

            // - Enable Floating Point Exceptions (TODO)

            // - Create Hotpatchable Image (TODO)

            #endregion

            #region Language
            // - Disable Language Extensions
            bool disableLanguageExtensions = Utils.call(() => (compilerTool.DisableLanguageExtensions));
            if (disableLanguageExtensions)
            {
                configurationInfo.addCompilerFlag("/Za");
            }

            // - Treat WChar_t As Built in Type
            bool treatWChar_tAsBuildInType = Utils.call(() => (compilerTool.TreatWChar_tAsBuiltInType));
            if (treatWChar_tAsBuildInType)
            {
                configurationInfo.addCompilerFlag("/Zc:wchar_t");
            }
            else
            {
                configurationInfo.addCompilerFlag("/Zc:wchar_t-");
            }

            // - Force Conformance in For Loop Scope
            bool forceConformance = Utils.call(() => (compilerTool.ForceConformanceInForLoopScope));
            if (forceConformance)
            {
                configurationInfo.addCompilerFlag("/Zc:forScope");
            }
            else
            {
                configurationInfo.addCompilerFlag("/Zc:forScope-");
            }

            // - Enable Run-Time Type Information (TODO)

            // - Open MP Support
            bool openMpSupport = Utils.call(() => (compilerTool.OpenMP));
            if (openMpSupport)
            {
                configurationInfo.addCompilerFlag("/openmp");
            }
            #endregion


            #region Advance
            // - Calling Convention
            callingConventionOption callingConvention = Utils.call(() => (compilerTool.CallingConvention));
            switch (callingConvention)
            {
            case callingConventionOption.callConventionCDecl:
                configurationInfo.addCompilerFlag("/Gd");
                break;

            case callingConventionOption.callConventionFastCall:
                configurationInfo.addCompilerFlag("/Gr");
                break;

            case callingConventionOption.callConventionStdCall:
                configurationInfo.addCompilerFlag("/Gz");
                break;
            }

            // - Compile As (TODO)

            // - Disable Specific Warnings
            string disableSpecificWarnings = Utils.call(() => (compilerTool.DisableSpecificWarnings));
            if (!string.IsNullOrEmpty(disableSpecificWarnings))
            {
                List <string> disableSpecificWarningsList = Utils.split(disableSpecificWarnings, ';');
                foreach (string warning in disableSpecificWarningsList)
                {
                    int number;
                    if (Int32.TryParse(warning, out number))
                    {
                        configurationInfo.addCompilerFlag("/wd" + warning);
                    }
                }
            }

            // - Forced Include File (TODO)
            // - Forced #using File
            // - Show Includes
            // - Use Full Paths
            // - Omit Default Library Name

            // - Internal Compiler Error Reporting
            compilerErrorReportingType compilerErrorReporting = Utils.call(() => (compilerTool.ErrorReporting));
            switch (compilerErrorReporting)
            {
            case compilerErrorReportingType.compilerErrorReportingPrompt:
                configurationInfo.addCompilerFlag("/errorReport:prompt");
                break;

            case compilerErrorReportingType.compilerErrorReportingQueue:
                configurationInfo.addCompilerFlag("/errorReport:queue");
                break;
            }

            // - Treat Specific Warnings As Errors (TODO)
            #endregion
        }