public virtual uint[] FromAsmSource(string asmSource)
        {
            // making a API call to integration server.

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                // on Windows, integration server is required to run in Docker or WSL.
                // Installation steps are same for WSL and for docker.
                // https://github.com/EvgenyMuryshkin/Quokka.RISCV.Docker/blob/master/Dockerfile

                var instructions = RISCVIntegrationClient.Asm(new RISCVIntegrationEndpoint(), asmSource);
                return(instructions.Result);
            }
            else
            {
                // on Linux, just make local call to RISCV toolchain
                return(RISCVIntegrationClient.ToInstructions(Toolchain.Asm(asmSource)).ToArray());
            }
        }
Exemplo n.º 2
0
        public static IEnumerable <AssembledInstruction> AssembleSource(Toolchain.Configuration tcConfig, string source, AssembleSourceOptions options = null)
        {
            var assembled = GetChunksWithCommon(source)
                            .Select(x => new
            {
                x.Assembly,
                x.RomAddress,
                x.RamAddress,
                Out = Toolchain.Assemble(tcConfig, x.Assembly)
            })
                            .ToArray();

            var linkerParts   = assembled.Select(x => (x.Out.Path, x.RamAddress));
            var linkerDetails = Toolchain.GenerateLinkerScript(linkerParts);

            using (var elf = Toolchain.Link(tcConfig, new[] { "-q" }, linkerDetails.script))
            {
                try
                {
                    return(linkerDetails.chunkFilter
                           .Zip(assembled, (filter, asm) => new { filter, asm.RamAddress, asm.RomAddress })
                           .SelectMany(x =>
                                       Toolchain.ToBinary(tcConfig, elf.Path, x.filter.SelectMany(y => new[] { "-j", y }))
                                       .ToInstructions()
                                       .Select((y, i) => new AssembledInstruction(x.RomAddress + (uint)i * 4, x.RamAddress + (uint)i * 4, y))
                                       )
                           .ToArray());
                }
                finally
                {
                    foreach (var x in assembled)
                    {
                        x.Out.Dispose();
                    }

                    if (options?.PreserveElfAt != null)
                    {
                        File.Copy(elf.Path, options.PreserveElfAt, true);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void CustomToolchainsAreSupported()
        {
            var logger = new OutputLogger(Output);

            var generator   = new MyGenerator();
            var builder     = new MyBuilder();
            var executor    = new MyExecutor();
            var myToolchain = new Toolchain("My", generator, builder, executor);
            var job         = new Job(Job.Dry)
            {
                Infrastructure = { Toolchain = myToolchain }
            };
            var config = CreateSimpleConfig(logger).With(job);

            CanExecute <ToolchainBenchmark>(config, fullValidation: false);

            Assert.True(generator.Done);
            Assert.True(builder.Done);
            Assert.True(executor.Done);
        }
Exemplo n.º 4
0
        public ActionResult Invoke([FromBody] BaseRequest request)
        {
            try
            {
                switch (request)
                {
                case InvokeRequest invoke:
                    return(Ok(Toolchain.Invoke(invoke)));

                default:
                    return(BadRequest($"Unsupported request type: {request.GetType()}"));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);

                return(BadRequest(ex.ToString()));
            }
        }
        public void AllFilesTest()
        {
            var id = Guid.NewGuid();

            using (var tc = new Toolchain(id))
            {
                tc.SetupRules(new [] { new AllFilesRule() });
                File.WriteAllText(Path.Combine(tc.RootPath, "1.txt"), "content");
                File.WriteAllBytes(Path.Combine(tc.RootPath, "1.bin"), new byte[] { 128 });

                var classes = new ExtensionClasses().Text("txt").Binary("bin");

                var result = tc.LoadSnapshot(classes);

                Assert.AreEqual(2, result.Files.Count);

                Assert.AreEqual(1, result.Files.OfType <FSTextFile>().Count());
                Assert.AreEqual(1, result.Files.OfType <FSBinaryFile>().Count());
            }
        }
Exemplo n.º 6
0
        private static BenchmarkReport Run(Benchmark benchmark, ILogger logger, IConfig config, string rootArtifactsFolderPath)
        {
            var toolchain = Toolchain.GetToolchain(benchmark.Job);

            logger.WriteLineHeader("// **************************");
            logger.WriteLineHeader("// Benchmark: " + benchmark.ShortInfo);

            var generateResult = Generate(logger, toolchain, benchmark, rootArtifactsFolderPath, config);

            try
            {
                if (!generateResult.IsGenerateSuccess)
                {
                    return(new BenchmarkReport(benchmark, generateResult, null, null, null));
                }

                var buildResult = Build(logger, toolchain, generateResult, benchmark);
                if (!buildResult.IsBuildSuccess)
                {
                    return(new BenchmarkReport(benchmark, generateResult, buildResult, null, null));
                }

                List <ExecuteResult> executeResults = Execute(logger, benchmark, toolchain, buildResult, config);

                var runs = new List <Measurement>();
                for (int index = 0; index < executeResults.Count; index++)
                {
                    var executeResult = executeResults[index];
                    runs.AddRange(executeResult.Data.Select(line => Measurement.Parse(logger, line, index + 1)).Where(r => r != null));
                }

                return(new BenchmarkReport(benchmark, generateResult, buildResult, executeResults, runs));
            }
            finally
            {
                Cleanup(generateResult.DirectoryPath, config);
            }
        }
Exemplo n.º 7
0
        public void SaveSnapshot()
        {
            using (var tc = new Toolchain(Guid.NewGuid()))
            {
                var fs = new FSSnapshot();
                fs.Files.Add(new FSTextFile()
                {
                    Name    = "1.txt",
                    Content = "abc"
                });

                fs.Files.Add(new FSBinaryFile()
                {
                    Name    = "1.bin",
                    Content = new byte[] { 128 }
                });

                tc.SaveSnapshot(fs);

                Assert.AreEqual("abc", File.ReadAllText(Path.Combine(tc.RootPath, "1.txt")));
                Assert.AreEqual(128, File.ReadAllBytes(Path.Combine(tc.RootPath, "1.bin"))[0]);
            }
        }
Exemplo n.º 8
0
        public void ExecuteCommandTest_Success()
        {
            using (var tc = new Toolchain(Guid.NewGuid()))
            {
                var fs = new FSSnapshot();
                fs.Files.Add(new FSTextFile()
                {
                    Name    = "1.cmd",
                    Content = "copy 1.txt 2.txt"
                });

                fs.Files.Add(new FSTextFile()
                {
                    Name    = "1.txt",
                    Content = "content"
                });

                tc.SaveSnapshot(fs);
                tc.SetupRules(new[] { new ModifiedFilesRule() });

                tc.Invoke(new[]
                {
                    new CommandLineInfo()
                    {
                        FileName  = "cmd.exe",
                        Arguments = "/c 1.cmd"
                    }
                });

                var result = tc.LoadSnapshot(new ExtensionClasses().Text("txt"));
                Assert.AreEqual(1, result.Files.Count);

                var file = (FSTextFile)result.Files[0];
                Assert.AreEqual("2.txt", file.Name);
                Assert.AreEqual("content", file.Content);
            }
        }
Exemplo n.º 9
0
 private static Benchmark[] GetSupportedBenchmarks(IList <Benchmark> benchmarks, CompositeLogger logger)
 {
     return(benchmarks.Where(benchmark => Toolchain.GetToolchain(benchmark.Job).IsSupported(benchmark, logger)).ToArray());
 }
Exemplo n.º 10
0
 public void Benchmark()
 {
     Console.WriteLine($"{AvoidParsingException} {Toolchain.GetToolchain(Runtime.Host)}");
 }
Exemplo n.º 11
0
        /// <inheritdoc />
        void IVisualStudioProjectCustomizer.WriteVisualStudioBuildProperties(VisualStudioProject project, Platform platform, Toolchain toolchain, Project.ConfigurationData configuration, StringBuilder vcProjectFileContent, StringBuilder vcFiltersFileContent, StringBuilder vcUserFileContent)
        {
            // Override the debugger to use Editor if target doesn't output executable file
            var outputType = project.OutputType ?? configuration.Target.OutputType;

            if (outputType != TargetOutputType.Executable && configuration.Name.StartsWith("Editor."))
            {
                var editorFolder = configuration.Architecture == TargetArchitecture.x64 ? "Win64" : "Win32";
                vcUserFileContent.AppendLine(string.Format("  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='{0}'\">", configuration.Name));
                vcUserFileContent.AppendLine(string.Format("    <LocalDebuggerCommand>{0}\\FlaxEditor.exe</LocalDebuggerCommand>", Path.Combine(Globals.EngineRoot, "Binaries", "Editor", editorFolder, configuration.ConfigurationName)));
                vcUserFileContent.AppendLine("    <LocalDebuggerCommandArguments>-project \"$(SolutionDir)\" -skipCompile</LocalDebuggerCommandArguments>");
                vcUserFileContent.AppendLine("    <LocalDebuggerWorkingDirectory>$(SolutionDir)</LocalDebuggerWorkingDirectory>");
                vcUserFileContent.AppendLine("    <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>");
                vcUserFileContent.AppendLine("    </PropertyGroup>");
            }
        }
Exemplo n.º 12
0
        public bool Exec(CheckoutCommandOptions options)
        {
            Toolchain.RequireSubversion();

            bool ok;

            if (!options.Repository.On)
            {
                return(Prompt.PrintInvalidUsage("A URI do repositório Subversion não foi indicada."));
            }

            var revision = options.Revision.On ? options.Revision.Text : "HEAD";
            var user     = options.User.On ? options.User.Text : Svn.DefaultUser;
            var pass     = options.Pass.On ? options.Pass.Text : Svn.DefaultPass;

            var folder = options.Directory.On ? options.Directory.Text : ".";

            folder = Path.GetFullPath(folder);

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            Prompt.PrintInfo("Workcopy: \n" + folder);

            var workcopy = new SvnWorkcopy(folder, user, pass);
            var remote   = new SvnRemote(user, pass);

            var tag = GetTagName(options);

            if (tag == "latest")
            {
                var baseUri  = options.Repository.Text;
                var tagNames = remote.GetTagNames(baseUri, revision);

                var tagName = SemVer.GetMaxVersion(tagNames);
                if (tagName == null)
                {
                    var exists = remote.HasSpecialFolder(baseUri, revision, "trunk");
                    tagName = exists ? "trunk" : "self";
                }

                tag = tagName;
            }

            var uri = GetRepositoryUri(options, tag);

            var workcopyUri = workcopy.GetInfo(Properties.Url);

            if (options.ForceCheckout.On || uri != workcopyUri)
            {
                workcopy.PurgeWorkcopy();

                ok = workcopy.Checkout(uri, revision);
                if (!ok)
                {
                    return(Prompt.PrintCannotContinue());
                }

                ok = workcopy.Cleanup();
                if (!ok)
                {
                    return(Prompt.PrintCannotContinue());
                }
            }
            else
            {
                ok = workcopy.Cleanup();
                if (!ok)
                {
                    return(Prompt.PrintCannotContinue());
                }

                ok = workcopy.Revert();
                if (!ok)
                {
                    return(Prompt.PrintCannotContinue());
                }

                ok = workcopy.Cleanup();
                if (!ok)
                {
                    return(Prompt.PrintCannotContinue());
                }

                ok = workcopy.Update(revision);
                if (!ok)
                {
                    return(Prompt.PrintCannotContinue());
                }
            }

            workcopy.ShowInfo();
            Prompt.PrintInfo("Concluído com êxito.");
            return(true);
        }
Exemplo n.º 13
0
 public bool Exec(UpgradeToolchainCommandOptions options)
 {
     Toolchain.RequireAll(force: true);
     return(true);
 }
Exemplo n.º 14
0
 public void B()
 {
     Console.WriteLine($"{Toolchain.GetToolchain(Runtime.Host)}");
 }
Exemplo n.º 15
0
        public bool Exec(BuildCommandOptions options)
        {
            Toolchain.RequireDevenv();
            Toolchain.RequirePackDm();
            Toolchain.RequireSubversion();

            bool ok;

            string[] solutions;

            if (options.Solutions.On)
            {
                solutions = options.Solutions.Items.FindFiles();
            }
            else
            {
                solutions = "*.sln".FindFiles();
            }

            if (!solutions.Any())
            {
                return(Prompt.PrintNothingToBeDone("Nenhuma solução detectada."));
            }

            var pack = new Library.PackDm.PackDm();

            pack.PackConf = options.ConfFile.Text;
            pack.PackInfo = options.PackFile.Text;

            var svn = new Svn();

            ok = pack.Fill();
            if (!ok)
            {
                return(Prompt.PrintCannotContinue());
            }

            ok = svn.Fill();
            if (!ok)
            {
                return(Prompt.PrintCannotContinue());
            }

            // Imprimindo informação de revisao do pack.info e do subverison
            // no console e no arquivo REVISION.txt
            VersionInfo version;
            {
                var revisionFilepath = Path.GetFullPath("REVISION.txt");

                var loader = new ProjectLoader();
                loader.PackConf = options.ConfFile.Text;
                loader.PackInfo = options.PackFile.Text;
                var ret = loader.LoadProjectHeader();
                if (!ret.Ok)
                {
                    return(Prompt.PrintCannotContinue());
                }

                var project = ret.Value;
                version = project.Version;

                // imprimindo no console e no arquivo
                Prompt.PrintInfo(version);
                File.WriteAllText(revisionFilepath, version);
            }

            var configuration = options.Configuration.Text ?? "Release|Any CPU";

            foreach (var solution in solutions)
            {
                var solutionFilename = Path.GetFileName(solution);
                var solutionFolder   = Path.GetDirectoryName(solution);

                ok = $"devenv.com {solution.Quote()} /Rebuild {configuration.Quote()}".Run();
                if (!ok)
                {
                    return(Prompt.PrintCannotContinue());
                }
            }

            // O packDm usa a máscara para substituir partes da versao
            var versionMask = $"*.*.*{version.FormattedPreRelease}";

            ok = pack.Pack(versionMask);
            if (!ok)
            {
                return(Prompt.PrintCannotContinue());
            }

            // Constrói a página HTML com informações de setup.
            // Falhas podem ser ignoradas.
            var title = Path.GetFileName(solutions.First()).Replace(".sln", "");

            MakeSetupPage(title, version);

            return(true);
        }