static void Main(string[] args) { Console.WriteLine("Generating ISO..."); Console.WriteLine("Args: " + string.Join(", ", args)); short BootLoadSize = short.Parse(args[0]); string IsoFileName = args[1]; string BootFileName = args[2]; bool BootInfoTable = bool.Parse(args[3]); string FilePath = args[4]; Options opts = new Options() { BootLoadSize = BootLoadSize, IsoFileName = IsoFileName, BootFileName = BootFileName, BootInfoTable = BootInfoTable }; opts.IncludeFiles.Add(FilePath); Iso9660Generator generator = new Iso9660Generator(opts); generator.Generate(); Console.WriteLine("ISO generated."); }
/// <summary> /// Constructor /// </summary> public Iso9660Generator(Options options) { this.isoRoot = new IsoFolder(); this.isoRoot.Name = "."; this.pedantic = options.Pedantic; this.isoFileName = options.IsoFileName; SetVolumeLabel(options.VolumeLabel); SetBootInfoTable(options.BootInfoTable); BootLoadSize(options.BootLoadSize); if (options.BootFileName != null) AddBootFile(options.BootFileName, new FileInfo(options.BootFileName)); foreach (string file in options.IncludeFiles) AddDirectoryTree(file, string.Empty); }
/// <summary> /// Mains the specified args. /// </summary> /// <param name="args">The args.</param> /// <returns></returns> private static int Main(string[] args) { Console.WriteLine("MakeIsoImage v0.9 [www.mosa-project.org]"); Console.WriteLine("Copyright 2010. New BSD License."); Console.WriteLine("Written by Royce Mitchell III ([email protected])"); Console.WriteLine(); // TODO FIXME - support remappings something like -map boot/boot.bin=c:/muos/build/debug/bin/iso9660_boot.bin try { Options options = new Options(); int i; for (i = 0; i < args.Length; i++) { if (args[i].Trim()[0] != '-') break; switch (args[i].Trim()) { case "-boot": // iso.AddBootFile(args[i], new System.IO.FileInfo(args[i])); options.BootFileName = args[++i]; break; case "-boot-load-size": short bootLoadSize; if (short.TryParse(args[++i], out bootLoadSize)) options.BootLoadSize = bootLoadSize; break; case "-boot-info-table": options.BootInfoTable = true; break; case "-label": options.VolumeLabel = args[++i]; break; default: break; } } // at this point, args[i] should be our iso image name if (i >= args.Length) { Console.Error.Write("Missing iso file name"); return -1; } options.IsoFileName = args[i++]; // now args[i] is root folder if (i >= args.Length) { Console.Error.Write("Missing root folder"); return -1; } while (i < args.Length) options.IncludeFiles.Add(args[i++]); Iso9660Generator iso = new Iso9660Generator(options); iso.Generate(); Console.WriteLine("Completed!"); } catch (Exception e) { Console.Error.WriteLine("Error: " + e.ToString()); return -1; } return 0; }
/// <summary> /// Finalises the compilation by turning the .BIn file into a usable .ISO file. /// </summary> /// <returns>True if finalisation completed successfully. Otherwise false.</returns> public bool Finalise() { //Convert the .BIN file to usable .ISO file Debug.Data.DebugDatabase.SubmitChanges(); bool OK = true; //Compile the .ASM file to .BIN file string outputFilePath = TheSettings[Settings.OutputFileKey]; string aIsoPathname = outputFilePath + ".iso"; string aObjPathname = outputFilePath + ".obj"; string aBinPathname = outputFilePath + ".bin"; string aMapPathname = outputFilePath + ".map"; string executionPath = TheSettings[Settings.ToolsPathKey]; string compilerExecutionPath = Path.Combine(executionPath, @"ISO"); string LdPath = Path.Combine(executionPath, @"cygwin\ld.exe"); string LinkScriptPath = Path.Combine(executionPath, @"cygwin\linker.ld"); string ObjDumpPath = Path.Combine(executionPath, @"cygwin\objdump.exe"); string workingDir = Path.GetDirectoryName(outputFilePath); //Delete an existing output file so we start from scratch if (File.Exists(aBinPathname)) { File.Delete(aBinPathname); } OK = ExecuteProcess(workingDir, LdPath, String.Format("-T '{2}' -e Kernel_Start -o '{0}' '{1}'", aBinPathname, aObjPathname, LinkScriptPath), "Ld"); if (OK) { if (File.Exists(aIsoPathname)) { File.Delete(aIsoPathname); } // We copy and rename in the process to FlingOS.bin becaue the .cfg is currently // hardcoded to FlingOS.bin. string finalOutputBin = Path.Combine(compilerExecutionPath, "FlingOS.bin"); File.Copy(aBinPathname, finalOutputBin, true); string isoLinuxPath = Path.Combine(compilerExecutionPath, "isolinux.bin"); File.SetAttributes(isoLinuxPath, FileAttributes.Normal); var xOptions = new Options() { BootLoadSize = 4, IsoFileName = aIsoPathname, BootFileName = isoLinuxPath, BootInfoTable = true }; // TODO - Use move or see if we can do this without copying first the FlingOS.bin as it will start to get larger xOptions.IncludeFiles.Add(compilerExecutionPath); var xISO = new Iso9660Generator(xOptions); xISO.Generate(); OK = true; } if (OK) { //Debug data - takes the bin file and dumps the address->label mappings if (File.Exists(aMapPathname)) { File.Delete(aMapPathname); } if (!ExecuteProcess(workingDir, ObjDumpPath, string.Format("--wide --syms \"{0}\"", aBinPathname), "ObjDump", false, aMapPathname)) { OutputError(new Exception("Failed to execute Obj Dump. Debug information will be missing.")); } } return OK; }