Example #1
0
 protected override void CompileOverride(MsvcCompileParams ccp)
 {
     ccp.IncludeDirs.Add(
         Path.Combine(Config.PlatformSdkDir, "Include")
     );
     ccp.IncludeDirs.Add(Path.Combine(ProjectDir, "inc"));
 }
        /// Returns a new canonicalized instance of compiler params.
        public static MsvcCompileParams Canonicalize(this MsvcCompileParams p)
        {
            MsvcCompileParams o = new MsvcCompileParams();
            //-- Meta
            if (String.IsNullOrEmpty(p.VcBinDir)) {
                throw new InvalidOperationException("VcBinDir not specified");
            }
            if (String.IsNullOrEmpty(p.CompileDir)) {
                throw new InvalidOperationException("CompileDir not specified");
            }
            o.CompileDir = QRPath.GetCanonical(p.CompileDir);
            o.BuildFileDir = String.IsNullOrEmpty(p.BuildFileDir)
                ? p.CompileDir
                : QRPath.GetCanonical(p.BuildFileDir);
            o.VcBinDir = QRPath.GetAbsolutePath(p.VcBinDir, o.CompileDir);
            o.ToolChain = p.ToolChain;
            o.CheckForImplicitIO = p.CheckForImplicitIO;

            //-- Input and Output Options
            if (String.IsNullOrEmpty(p.SourceFile)) {
                throw new InvalidOperationException("C/C++ SourceFile not specified");
            }
            o.SourceFile = QRPath.GetAbsolutePath(p.SourceFile, o.CompileDir);
            o.Compile = p.Compile;
            if (p.Compile) {
                o.ObjectPath = QRPath.ComputeDefaultFilePath(p.ObjectPath, p.SourceFile, ".obj", o.CompileDir);
                o.PdbPath = QRPath.ComputeDefaultFilePath(p.PdbPath, o.ObjectPath, ".pdb", o.CompileDir);
            }
            o.AsmOutputFormat = p.AsmOutputFormat;
            if (p.AsmOutputFormat != MsvcAsmOutputFormat.None) {
                o.AsmOutputPath = QRPath.ComputeDefaultFilePath(p.AsmOutputPath, p.SourceFile, ".asm", o.CompileDir);
            }
            o.ClrSupport = p.ClrSupport;
            o.NoLogo = p.NoLogo;
            o.ExtraArgs = p.ExtraArgs;

            //-- Optimization
            o.OptLevel = p.OptLevel;
            o.InlineExpansion = p.InlineExpansion;
            o.EnableIntrinsicFunctions = p.EnableIntrinsicFunctions;
            o.FavorSizeOrSpeed = p.FavorSizeOrSpeed;
            o.OmitFramePointers = p.OmitFramePointers;

            //-- Code Generation
            o.EnableMinimalRebuild = p.EnableMinimalRebuild;
            o.EnableStringPooling = p.EnableStringPooling;
            o.CppExceptions = p.CppExceptions;
            o.ExternCNoThrow = p.ExternCNoThrow;
            o.BasicRuntimeChecks = p.BasicRuntimeChecks;
            o.RuntimeLibrary = p.RuntimeLibrary;
            o.StructMemberAlignment = p.StructMemberAlignment;
            o.BufferSecurityCheck = p.BufferSecurityCheck;
            o.EnableFunctionLevelLinking = p.EnableFunctionLevelLinking;
            o.EnhancedIsa = p.EnhancedIsa;
            o.FloatingPointModel = p.FloatingPointModel;
            o.EnableFloatingPointExceptions = p.EnableFloatingPointExceptions;
            o.HotPatchable = p.HotPatchable;

            //-- PreProcessor
            o.Defines.AddRange(p.Defines);
            o.Undefines.AddRange(p.Undefines);
            o.UndefineAllPredefinedMacros = p.UndefineAllPredefinedMacros;
            o.IncludeDirs.AddRangeAsAbsolutePaths(p.IncludeDirs, o.CompileDir);
            o.AssemblySearchDirs.AddRangeAsAbsolutePaths(p.AssemblySearchDirs, o.CompileDir);
            o.ForcedIncludes.AddRangeAsAbsolutePaths(p.ForcedIncludes, o.CompileDir);
            o.ForcedUsings.AddRangeAsAbsolutePaths(p.ForcedUsings, o.CompileDir);
            o.IgnoreStandardPaths = p.IgnoreStandardPaths;

            //-- Language
            o.DebugInfoFormat = p.DebugInfoFormat;
            o.EnableExtensions = p.EnableExtensions;
            o.DefaultCharUnsigned = p.DefaultCharUnsigned;
            o.Wchar_tBuiltIn = p.Wchar_tBuiltIn;
            o.ConformantForLoopScope = p.ConformantForLoopScope;
            o.EnableRtti = p.EnableRtti;
            o.EnableOpenMPSupport = p.EnableOpenMPSupport;
            o.CompileAsC = p.CompileAsC;
            o.CompileAsCpp = p.CompileAsCpp;

            //-- Warnings
            o.DisableAllWarnings = p.DisableAllWarnings;
            o.EnableAllWarnings = p.EnableAllWarnings;
            o.WarnLevel = p.WarnLevel;
            o.TreatWarningsAsErrors = p.TreatWarningsAsErrors;
            o.SingleLineDiagnostics = p.SingleLineDiagnostics;

            if (p.CreatePch) {
                o.CreatePchFilePath = QRPath.ComputeDefaultFilePath(p.CreatePchFilePath, p.SourceFile, ".pch", o.CompileDir);
            }
            if (!String.IsNullOrEmpty(p.UsePchFilePath)) {
                o.UsePchFilePath = QRPath.GetAbsolutePath(p.UsePchFilePath, o.CompileDir);
            }

            return o;
        }
Example #3
0
        protected MsvcCompileParams CreateCompileParams(
            string sourceFile,
            Action<MsvcCompileParams> overrideParams)
        {
            string srcDir = Path.GetDirectoryName(sourceFile);
            string objDir = Path.Combine(OutDir, srcDir);

            var ccp = new MsvcCompileParams();
            ccp.VcBinDir = Config.VcBinDir;
            ccp.CompileDir = Path.Combine(ProjectDir, srcDir);
            ccp.BuildFileDir = objDir;
            ccp.SourceFile = Path.GetFileName(sourceFile);
            ccp.ObjectPath = Path.Combine(
                objDir,
                ccp.SourceFile + ".obj");
            ccp.Compile = true;
            ccp.ToolChain = ToolChain;

            ccp.CppExceptions = MsvcCppExceptions.Enabled;
            ccp.DebugInfoFormat = MsvcDebugInfoFormat.Normal;
            ccp.EnableMinimalRebuild = true;

            if (MainVariant.Configuration == Configuration.debug) {
                ccp.OptLevel = MsvcOptLevel.Disabled;
            }
            else {
                ccp.OptLevel = MsvcOptLevel.GlobalOptimizations;
            }

            // Allow derived class to override settings in bulk.
            CompileOverride(ccp);

            // Allow caller to override settings for just this file.
            if (overrideParams != null) {
                overrideParams(ccp);
            }

            return ccp;
        }
Example #4
0
 protected virtual void CompileOverride(MsvcCompileParams ccp)
 {
 }
        static MsvcCompile PpAndCompileOne(BuildGraph buildGraph, string sourceFile)
        {
            string sourceFileName = Path.GetFileName(sourceFile);

            string iName = Path.Combine(buildFileDir, QRPath.ChangeExtension(sourceFileName, ".i"));
            var ppp = new MsvcPreProcessParams();
            ppp.VcBinDir = vcBinDir;
            ppp.ToolChain = toolChain;
            ppp.CompileDir = compileDir;
            ppp.BuildFileDir = buildFileDir;
            ppp.SourceFile = sourceFile;
            ppp.OutputPath = iName;
            ppp.IncludeDirs.Add(@"K:\work\code\lib\boost_1_43_0");
            var pp = new MsvcPreProcess(buildGraph, ppp);

            string objName = Path.Combine(buildFileDir, QRPath.ChangeExtension(sourceFileName, ".obj"));
            var ccp = new MsvcCompileParams();
            ccp.VcBinDir = vcBinDir;
            ccp.ToolChain = toolChain;
            ccp.CompileDir = compileDir;
            ccp.BuildFileDir = buildFileDir;
            ccp.CheckForImplicitIO = false;
            ccp.SourceFile = iName;
            ccp.ObjectPath = objName;
            ccp.Compile = true;
            ccp.DebugInfoFormat = MsvcDebugInfoFormat.Normal;
            ccp.CppExceptions = MsvcCppExceptions.Enabled;
            ccp.CompileAsCpp = true;
            var cc = new MsvcCompile(buildGraph, ccp);
            return cc;
        }
Example #6
0
 public MsvcCompile(BuildGraph buildGraph, MsvcCompileParams p)
     : base(buildGraph)
 {
     m_params = p.Canonicalize();
 }
Example #7
0
        static void TestSingleNodeGraph()
        {
            var buildGraph = new BuildGraph();

            var ccp = new MsvcCompileParams();
            ccp.VcBinDir = @"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin";
            ccp.ToolChain = MsvcToolChain.ToolsX86TargetX86;
            ccp.CompileDir = @"K:\work\code\cpp\0002_test";
            ccp.SourceFile = @"test02.cpp";
            ccp.Compile = true;
            ccp.DebugInfoFormat = MsvcDebugInfoFormat.Normal;

            var cc = new MsvcCompile(buildGraph, ccp);

            BuildOptions buildOptions = new BuildOptions();
            buildOptions.ContinueOnError = false;
            buildOptions.FileDecider = new FileSizeDateDecider();
            buildOptions.MaxConcurrency = 1;

            string[] targets = { @"K:\work\code\cpp\0002_test\test02.obj" };
            BuildResults buildResults = buildGraph.Execute(BuildAction.Build, buildOptions, targets, true);
            Console.WriteLine("BuildResults.Success          = {0}", buildResults.Success);
            Console.WriteLine("BuildResults.TranslationCount = {0}", buildResults.TranslationCount);
            Console.WriteLine("BuildResults.UpToDateCount    = {0}", buildResults.UpToDateCount);
        }
Example #8
0
        static void TestMsvcCompile(string vcBinDir)
        {
            var ccp = new MsvcCompileParams();
            ccp.VcBinDir = vcBinDir;
            ccp.ToolChain = MsvcToolChain.ToolsX86TargetX86;
            ccp.CompileDir = @"K:\work\code\cpp\0002_test";
            ccp.SourceFile = @"test02.cpp";
            ccp.Compile = true;
            ccp.DebugInfoFormat = MsvcDebugInfoFormat.Normal;

            var buildGraph = new BuildGraph();

            var cc = new MsvcCompile(buildGraph, ccp);
            cc.Execute();

            cc.UpdateExplicitIO();
            cc.UpdateImplicitInputs();

            string depsCache = DependencyCache.CreateDepsCacheString(cc, new FileSizeDateDecider());
            File.WriteAllText(cc.DepsCacheFilePath, depsCache);

            HashSet<string> implicitInputs = new HashSet<string>();
            DependencyCache.LoadDepsCacheImplicitIO(cc.DepsCacheFilePath, implicitInputs);
        }