示例#1
0
 //-- Protected interface
 /// Constructor to be called by derived classes.
 protected BuildTranslation(BuildGraph buildGraph)
 {
     if (buildGraph == null) {
         throw new ArgumentNullException("buildGraph");
     }
     ModuleName = "";
     BuildNode = new BuildNode(this);
     BuildGraph = buildGraph;
     BuildGraph.Add(this);
 }
        public static void DoTest2()
        {
            var buildGraph = new BuildGraph();
            Directory.CreateDirectory(buildFileDir);

            string windowsSdkDir = @"C:\Program Files\Microsoft SDKs\Windows\v6.0A";

            var cc_a    = PpAndCompileOne(buildGraph, "a.cpp");
            var cc_b    = PpAndCompileOne(buildGraph, "b.cpp");
            var cc_c    = PpAndCompileOne(buildGraph, "c.cpp");
            var cc_main = PpAndCompileOne(buildGraph, "main.cpp");

            string kernel32Lib = Path.Combine(windowsSdkDir, @"Lib\kernel32.lib");
            // NOTE: linker order matters; the linker translation respects that
            var link = LinkExecutable(
                buildGraph,
                "main.exe",
                cc_a.Params.ObjectPath,
                cc_b.Params.ObjectPath,
                cc_c.Params.ObjectPath,
                cc_main.Params.ObjectPath,
                kernel32Lib);

            var generateHeader = new GenerateHeader(
                buildGraph,
                "generated.h",
                compileDir,
                buildFileDir);

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

            string[] targets = { link.Params.OutputFilePath };

            BuildResults cleanBuildResults = buildGraph.Execute(BuildAction.Build, buildOptions, targets, true);
            TestHelpers.PrintBuildResults(buildOptions, cleanBuildResults);
            BuildResults incrementalBuildResults = buildGraph.Execute(BuildAction.Build, buildOptions, targets, true);
            TestHelpers.PrintBuildResults(buildOptions, incrementalBuildResults);

            bool doClean = true;
            if (doClean) {
                BuildResults cleanResults = buildGraph.Execute(BuildAction.Clean, buildOptions, targets, true);
                TestHelpers.PrintBuildResults(buildOptions, cleanResults);
            }
        }
示例#3
0
        ///-----------------------------------------------------------------
        /// Public interface
        public BuildProcess(
            BuildGraph buildGraph,
            BuildAction buildAction,
            BuildOptions buildOptions,
            BuildResults buildResults,
            IEnumerable<BuildNode> buildNodes,
            bool processDependencies)
        {
            m_buildGraph = buildGraph;
            m_buildAction = buildAction;
            m_buildOptions = buildOptions;
            m_buildResults = buildResults;

            bool initialized = InitializeBuildProcess(buildNodes, processDependencies);
            if (!initialized) {
                throw new InvalidOperationException("Failed to initialize BuildProcess.");
            }
        }
 public GenerateHeader(
     BuildGraph buildGraph, 
     string fileName, 
     string compileDir,
     string buildFileDir)
     : base(buildGraph)
 {
     m_fileName = QRPath.GetAbsolutePath(fileName, compileDir);
     m_buildFileDir = QRPath.GetCanonical(buildFileDir);
 }
        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;
        }
 static MsvcLink LinkExecutable(
     BuildGraph buildGraph,
     string outputName,
     params string[] objFiles)
 {
     var linkerParams = new MsvcLinkerParams();
     linkerParams.VcBinDir = vcBinDir;
     linkerParams.ToolChain = toolChain;
     linkerParams.CompileDir = compileDir;
     linkerParams.BuildFileDir = buildFileDir;
     foreach (string objFile in objFiles) {
         linkerParams.Inputs.Add(objFile);
     }
     linkerParams.OutputFilePath = outputName;
     var link = new MsvcLink(buildGraph, linkerParams);
     return link;
 }
示例#7
0
            public static void TestCppCompileLink()
            {
                var buildGraph = new BuildGraph();

                Directory.CreateDirectory(buildFileDir);

                var cc_test02 = CompileOne(buildGraph, "test02.cpp");
                var cc_foo = CompileOne(buildGraph, "foo.cpp");
                var cc_groo = CompileOne(buildGraph, "groo.cpp");
                var cc_qoo = CompileOne(buildGraph, "qoo.cpp");
                var cc_yoo = CompileOne(buildGraph, "yoo.cpp");
                var cc_aoo = CompileOne(buildGraph, "aoo.cpp");
                var cc_boo = CompileOne(buildGraph, "boo.cpp");
                var cc_coo = CompileOne(buildGraph, "coo.cpp");
                var cc_doo = CompileOne(buildGraph, "doo.cpp");

                var linkerParams = new MsvcLinkerParams();
                linkerParams.VcBinDir = vcBinDir;
                linkerParams.ToolChain = toolChain;
                linkerParams.CompileDir = compileDir;
                linkerParams.BuildFileDir = buildFileDir;
                linkerParams.Inputs.Add(cc_aoo.Params.ObjectPath);
                linkerParams.Inputs.Add(cc_boo.Params.ObjectPath);
                linkerParams.Inputs.Add(cc_coo.Params.ObjectPath);
                linkerParams.Inputs.Add(cc_doo.Params.ObjectPath);
                linkerParams.Inputs.Add(cc_foo.Params.ObjectPath);
                linkerParams.Inputs.Add(cc_groo.Params.ObjectPath);
                linkerParams.Inputs.Add(cc_qoo.Params.ObjectPath);
                linkerParams.Inputs.Add(cc_test02.Params.ObjectPath);
                linkerParams.Inputs.Add(cc_yoo.Params.ObjectPath);
                linkerParams.OutputFilePath = "result.exe";
                var link = new MsvcLink(buildGraph, linkerParams);

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

                string[] targets = { link.Params.OutputFilePath };

                BuildResults cleanBuildResults = buildGraph.Execute(BuildAction.Build, buildOptions, targets, true);
                TestHelpers.PrintBuildResults(buildOptions, cleanBuildResults);
                BuildResults incrementalBuildResults = buildGraph.Execute(BuildAction.Build, buildOptions, targets, true);
                TestHelpers.PrintBuildResults(buildOptions, incrementalBuildResults);

                bool doClean = true;
                if (doClean) {
                    BuildResults cleanResults = buildGraph.Execute(BuildAction.Clean, buildOptions, targets, true);
                    TestHelpers.PrintBuildResults(buildOptions, cleanResults);
                }
            }
示例#8
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);
        }
示例#9
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);
        }
示例#10
0
        static void TestDependencyChain()
        {
            var buildGraph = new BuildGraph();

            string testDir = @"K:\work\code\C#\QRBuild\Tests\A";
            string intDir = Path.Combine(testDir, "int");
            string a = Path.Combine(testDir, "a");
            string b = Path.Combine(testDir, "b");
            string c = Path.Combine(testDir, "c");
            string d = Path.Combine(testDir, "d");
            if (!File.Exists(a)) {
                File.WriteAllText(a, "a");
            }

            var fcB = new FileCopy(buildGraph, a, b, intDir);
            var fcC = new FileCopy(buildGraph, b, c, intDir);
            var fcD = new FileCopy(buildGraph, c, d, intDir);

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

            string[] targets = { d };
            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);

            //QRFile.Delete(a, b, c, d);
        }
示例#11
0
        static void TestCscCompile()
        {
            var cscp = new CSharpCompileParams();
            cscp.CompileDir = @"K:\work\code\C#\foo";
            string sourceFile = @"K:\work\code\C#\foo\Blah.cs";
            cscp.Sources.Add(sourceFile);
            cscp.OutputFilePath = QRPath.ChangeExtension(sourceFile, ".exe");
            cscp.FrameworkVersion = "v3.5";
            cscp.Platform = CSharpPlatforms.AnyCpu;
            cscp.Debug = true;

            var buildGraph = new BuildGraph();

            var csc = new CSharpCompile(buildGraph, cscp);
            csc.Execute();

            csc.UpdateExplicitIO();
            csc.UpdateImplicitInputs();

            string depsCache = DependencyCache.CreateDepsCacheString(csc, new FileSizeDateDecider());
            File.WriteAllText(csc.BuildFileBaseName + "__qr__.deps", depsCache);
        }