コード例 #1
0
ファイル: common.qr.cs プロジェクト: fifoforlifo/QRBuild
 /// Derived project classes can override this to set project-level
 /// defaults on linker params.
 protected virtual void LinkerOverride(MsvcLinkerParams lp)
 {
 }
コード例 #2
0
ファイル: common.qr.cs プロジェクト: fifoforlifo/QRBuild
        protected MsvcLinkerParams CreateLinkerParams(
            string outputName,
            Action<MsvcLinkerParams> overrideParams)
        {
            var lp = new MsvcLinkerParams();
            lp.VcBinDir = Config.VcBinDir;
            lp.ToolChain = ToolChain;
            lp.CompileDir = ProjectDir;
            lp.BuildFileDir = OutDir;
            lp.Inputs.Add(Config.PlatformSdkDir + @"\lib\kernel32.lib");
            lp.Inputs.Add(Config.PlatformSdkDir + @"\lib\user32.lib");
            foreach (MsvcCompile cc in m_compiles) {
                lp.Inputs.Add(cc.Params.ObjectPath);
            }
            lp.OutputFilePath = Path.Combine(OutDir, outputName);
            lp.Incremental = true;

            LinkerOverride(lp);

            if (overrideParams != null) {
                overrideParams(lp);
            }

            return lp;
        }
コード例 #3
0
ファイル: MsvcLink.cs プロジェクト: fifoforlifo/QRBuild
 public MsvcLink(BuildGraph buildGraph, MsvcLinkerParams p)
     : base(buildGraph)
 {
     m_params = p.Canonicalize();
 }
コード例 #4
0
 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;
 }
コード例 #5
0
        public static MsvcLinkerParams Canonicalize(this MsvcLinkerParams p)
        {
            MsvcLinkerParams o = new MsvcLinkerParams();
            //-- 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, p.CompileDir);
            o.ToolChain = p.ToolChain;
            o.AdditionalOptions = p.AdditionalOptions;

            //-- Input
            if (p.Inputs.Count == 0) {
                throw new InvalidOperationException("No Inputs specified");
            }
            foreach (string path in p.Inputs) {
                string absPath = QRPath.GetAbsolutePath(path, o.CompileDir);
                o.Inputs.Add(absPath);
            }
            foreach (string path in p.InputModules) {
                string absPath = QRPath.GetAbsolutePath(path, o.CompileDir);
                o.InputModules.Add(absPath);
            }
            if (!String.IsNullOrEmpty(p.DefFilePath)) {
                o.DefFilePath = QRPath.GetAbsolutePath(p.DefFilePath, o.CompileDir);
            }
            foreach (string path in p.DefaultLib) {
                o.DefaultLib.Add(path);
            }
            foreach (string path in p.NoDefaultLib) {
                o.NoDefaultLib.Add(path);
            }

            //-- Output
            o.Debug = p.Debug;
            o.Dll = p.Dll;
            o.SubSystem = p.SubSystem;
            if (!String.IsNullOrEmpty(p.OutputFilePath)) {
                o.OutputFilePath = QRPath.GetAbsolutePath(p.OutputFilePath, o.CompileDir);
            }
            else {
                string firstObj = QRPath.FindFileWithExt(o.Inputs, ".obj");
                string newExtension = p.Dll ? ".dll" : ".exe";
                o.OutputFilePath = QRPath.ChangeExtension(firstObj, newExtension);
            }
            if (!String.IsNullOrEmpty(p.PdbFilePath)) {
                o.PdbFilePath = QRPath.GetAbsolutePath(p.PdbFilePath, o.CompileDir);
            }
            else {
                if (p.Debug) {
                    string firstObj = QRPath.FindFileWithExt(o.Inputs, ".obj");
                    o.OutputFilePath = QRPath.ChangeExtension(firstObj, ".pdb");
                }
            }
            if (!String.IsNullOrEmpty(p.ImpLibPath)) {
                o.ImpLibPath = QRPath.GetAbsolutePath(p.ImpLibPath, o.CompileDir);
            }
            else {
                if (p.Dll) {
                    string firstObj = QRPath.FindFileWithExt(o.Inputs, ".obj");
                    o.OutputFilePath = QRPath.ChangeExtension(firstObj, ".lib");
                }
            }
            if (!String.IsNullOrEmpty(p.MapFilePath)) {
                o.MapFilePath = QRPath.GetAbsolutePath(p.MapFilePath, o.CompileDir);
            }

            //-- Options
            foreach (string path in p.DelayLoad) {
                o.DelayLoad.Add(path);
            }
            o.Entry = p.Entry;
            foreach (string symbol in p.Export) {
                o.Export.Add(symbol);
            }
            o.Force = p.Force;
            foreach (string symbol in p.Include) {
                o.Include.Add(symbol);
            }
            o.Incremental = p.Incremental;
            o.NoAssembly = p.NoAssembly;
            o.NoLogo = p.NoLogo;
            o.NxCompat = p.NxCompat;
            o.OptRef = p.OptRef;
            o.Stack = p.Stack;
            o.Verbose = p.Verbose;
            o.Version = p.Version;
            o.WarningsAsErrors = p.WarningsAsErrors;

            return o;
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: fifoforlifo/QRBuild
            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);
                }
            }