コード例 #1
0
        void FirmwareFromCS()
        {
            var csFiles        = Directory.EnumerateFiles(SourceFolder);
            var csFilesContent = csFiles
                                 .Select(path => new FSTextFile()
            {
                Name = path, Content = File.ReadAllText(path)
            })
                                 .ToList();

            if (csFilesContent.Any())
            {
                foreach (var cs in csFilesContent)
                {
                    Console.WriteLine($"Found CS source: {cs.Name}");
                }

                // translate source files
                var tx     = new CSharp2CPPTranslator();
                var source = new FSSnapshot();
                source.Files.AddRange(csFilesContent);
                tx.Run(source);
                var firmwareSource = tx.Result;

                // create soc resource records
                var socGenerator      = new SOCGenerator();
                var socRecordsBuilder = new SOCRecordsBuilder();
                var socRecords        = socRecordsBuilder.ToSOCRecords(0x800, tx.SOCResources);
                firmwareSource.Add(socGenerator.SOCImport(socRecords));

                FileTools.CreateDirectoryRecursive(FirmwareFolder);
                var m = new FSManager(FirmwareFolder);
                m.SaveSnapshot(firmwareSource);
            }

            ModifyMakefile();

            if (File.Exists(MakefileFile))
            {
                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    var context = RISCVIntegration
                                  .DefaultContext(FirmwareFolder)
                                  .WithMakeTarget("bin");

                    RISCVIntegrationClient.Make(context).Wait();
                }
                else
                {
                    using (new CurrentDirectory(FirmwareFolder))
                    {
                        Toolchain.Make("bin");
                    }
                }
            }
            else
            {
                Console.WriteLine($"Makefile was not found: {MakefileFile}");
            }
        }
コード例 #2
0
        public async Task <ActionResult> Make(string target)
        {
            try
            {
                var result = await Toolchain.Make(Request.Body, target);

                return(File(result, "application/zip"));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);

                return(BadRequest(ex.ToString()));
            }
        }