private void processCompileResults(fileObj[] files, StandardCompileOutput <Project> output, outputEntry[] errors, outputEntry[] warnings) { for (int c = 0; c < errors.Length; c++) { ProjectFile file; int line; resolveFile(errors[c], files, out file, out line); output.addError( file, line, errors[c].column, errors[c].message); } for (int c = 0; c < warnings.Length; c++) { ProjectFile file; int line; resolveFile(warnings[c], files, out file, out line); output.addWarning( file, line, warnings[c].column, warnings[c].message); } }
public ICompilerOutput <Solution> Compile(Solution solution, StandardOutputCallback standardOutput) { /*This is only temporary code until we have an actual build config system*/ string finalOutput = solution.BuildDirectory + "\\disk.iso"; if (File.Exists(finalOutput)) { File.Delete(finalOutput); } string bootsect = ""; StandardCompileOutput <Solution> output = new StandardCompileOutput <Solution>(finalOutput, solution); foreach (Project p in solution.Projects) { ICompilerOutput <Project> projOut = CompileProject(p, standardOutput); foreach (ICompileOutputEntry e in projOut.Errors) { output.addError( e.File, e.Line, e.Column, e.Message); } foreach (ICompileOutputEntry w in projOut.Warnings) { output.addWarning( w.File, w.Line, w.Column, w.Message); } if (projOut.Errors.Length != 0) { continue; } bootsect = projOut.OutputFile; } if (File.Exists(bootsect)) { generateISO( "OS Test", bootsect, solution.BuildDirectory + "\\disk", finalOutput, standardOutput, new string[0]); } return(output); }
private void link(string[] files, string outputFile, StandardCompileOutput <Project> output, StandardOutputCallback stdOut) { //perform the link outputEntry[] errors = new outputEntry[0]; outputEntry[] warnings = new outputEntry[0]; link(ref errors, ref warnings, files, outputFile, stdOut); //add the errors and warnings to the output object for (int c = 0; c < errors.Length; c++) { output.addError(null, 0, 0, errors[c].message); } for (int c = 0; c < warnings.Length; c++) { output.addWarning(null, 0, 0, warnings[c].message); } }
private void compileAssembly(bool linkable, string outputFile, StandardCompileOutput <Project> output, fileObj[] files, StandardOutputCallback stdOut) { if (File.Exists(outputFile)) { File.Delete(outputFile); } //collapse all the files into one file to compile string collapsed = collapseFiles(files, ".asm"); //compile outputEntry[] errors = new outputEntry[0]; outputEntry[] warnings = new outputEntry[0]; compileAssembly(linkable, ref errors, ref warnings, collapsed, outputFile, stdOut); processCompileResults(files, output, errors, warnings); //clean up File.Delete(collapsed); }
public ICompilerOutput<Solution> Compile(Solution solution, StandardOutputCallback standardOutput) { /*This is only temporary code until we have an actual build config system*/ string finalOutput = solution.BuildDirectory + "\\disk.iso"; if (File.Exists(finalOutput)) { File.Delete(finalOutput); } string bootsect = ""; StandardCompileOutput<Solution> output = new StandardCompileOutput<Solution>(finalOutput, solution); foreach (Project p in solution.Projects) { ICompilerOutput<Project> projOut = CompileProject(p, standardOutput); foreach (ICompileOutputEntry e in projOut.Errors) { output.addError( e.File, e.Line, e.Column, e.Message); } foreach (ICompileOutputEntry w in projOut.Warnings) { output.addWarning( w.File, w.Line, w.Column, w.Message); } if (projOut.Errors.Length != 0) { continue; } bootsect = projOut.OutputFile; } if (File.Exists(bootsect)) { generateISO( "OS Test", bootsect, solution.BuildDirectory + "\\disk", finalOutput, standardOutput, new string[0]); } return output; }
private void compileC(string outputFile, StandardCompileOutput <Project> output, fileObj[] codeFiles, fileObj[] headerFiles, StandardOutputCallback stdOut) { if (File.Exists(outputFile)) { File.Delete(outputFile); } //collapse the code files and header files into one array but add the header files first. fileObj[] files = new fileObj[0]; Helpers.AddObject(ref files, headerFiles); Helpers.AddObject(ref files, codeFiles); //flatten the files down to a single file string collapsed = collapseFiles(files, ".c"); //perform the compile outputEntry[] errors = new outputEntry[0]; outputEntry[] warnings = new outputEntry[0]; compileC(ref errors, ref warnings, collapsed, outputFile, stdOut); processCompileResults(codeFiles, output, errors, warnings); //clean up File.Delete(collapsed); }
public ICompilerOutput<Project> CompileProject(Project project, StandardOutputCallback standardOutput) { #region split up every file in the project into a code file fileObj[] assemblyFiles = new fileObj[0]; fileObj[] cCodeFiles = new fileObj[0]; fileObj[] cHeaderFiles = new fileObj[0]; project.Root.Enumerate(true, delegate(ProjectEntity e) { if (!(e is ProjectFile)) { return true; } //add the filename into the appropriate code file list ProjectFile file = (ProjectFile)e; string ext = file.Extension.ToLower(); switch (ext) { case ".c": Helpers.AddObject(ref cCodeFiles, new fileObj(file)); break; case ".h": Helpers.AddObject(ref cHeaderFiles, new fileObj(file)); break; case ".asm": Helpers.AddObject(ref assemblyFiles, new fileObj(file)); break; } return true; }); #endregion //define the final output file string finalOutput = getOuputFilename(project, "build.bin"); StandardCompileOutput<Project> output = new StandardCompileOutput<Project>(finalOutput, project); string[] outputFiles = new string[0]; if (File.Exists(finalOutput)) { File.Delete(finalOutput); } //define whether or not the assembly code should //be linked (no point in linking if theres nothing //to link with) bool linkable = cCodeFiles.Length != 0 || cHeaderFiles.Length != 0; //compile the assembly if (assemblyFiles.Length != 0) { //make sure that the main entry point assembly file is at the top //of the list to be compiled first. int bootfileIndex = -1; for (int c = 0; c < assemblyFiles.Length; c++) { if (assemblyFiles[c].ProjectFile.Name.ToLower() == "boot.asm") { bootfileIndex = c; break; } } if (bootfileIndex != -1) { Helpers.SwapEntries(ref assemblyFiles, bootfileIndex, 0); } string asmOut = getOuputFilename(project, "asm.o"); compileAssembly(linkable, asmOut, output, assemblyFiles, standardOutput); Helpers.AddObject(ref outputFiles, asmOut); //if there are no C code/header files, then there is no point //compiling and linking them with the ASM code. if (!linkable) { if (File.Exists(asmOut)) { File.Move(asmOut, finalOutput); } return output; } } //compile all the C code string cOut = getOuputFilename(project, "c.o"); compileC(cOut, output, cCodeFiles, cHeaderFiles, standardOutput); Helpers.AddObject(ref outputFiles, cOut); //if there was no success, do not continue with linking. if (output.Errors.Length != 0) { return output; } //link the c and assembly code together. link( outputFiles, finalOutput, output, standardOutput); return output; }
private void processCompileResults(fileObj[] files, StandardCompileOutput<Project> output, outputEntry[] errors, outputEntry[] warnings) { for (int c = 0; c < errors.Length; c++) { ProjectFile file; int line; resolveFile(errors[c], files, out file, out line); output.addError( file, line, errors[c].column, errors[c].message); } for (int c = 0; c < warnings.Length; c++) { ProjectFile file; int line; resolveFile(warnings[c], files, out file, out line); output.addWarning( file, line, warnings[c].column, warnings[c].message); } }
private void link(string[] files, string outputFile, StandardCompileOutput<Project> output, StandardOutputCallback stdOut) { //perform the link outputEntry[] errors = new outputEntry[0]; outputEntry[] warnings = new outputEntry[0]; link(ref errors, ref warnings, files, outputFile, stdOut); //add the errors and warnings to the output object for (int c = 0; c < errors.Length; c++) { output.addError(null, 0, 0, errors[c].message); } for (int c = 0; c < warnings.Length; c++) { output.addWarning(null, 0, 0, warnings[c].message); } }
private void compileC(string outputFile, StandardCompileOutput<Project> output, fileObj[] codeFiles, fileObj[] headerFiles, StandardOutputCallback stdOut) { if (File.Exists(outputFile)) { File.Delete(outputFile); } //collapse the code files and header files into one array but add the header files first. fileObj[] files = new fileObj[0]; Helpers.AddObject(ref files, headerFiles); Helpers.AddObject(ref files, codeFiles); //flatten the files down to a single file string collapsed = collapseFiles(files, ".c"); //perform the compile outputEntry[] errors = new outputEntry[0]; outputEntry[] warnings = new outputEntry[0]; compileC(ref errors, ref warnings, collapsed, outputFile, stdOut); processCompileResults(codeFiles, output, errors, warnings); //clean up File.Delete(collapsed); }
private void compileAssembly(bool linkable, string outputFile, StandardCompileOutput<Project> output, fileObj[] files, StandardOutputCallback stdOut) { if (File.Exists(outputFile)) { File.Delete(outputFile); } //collapse all the files into one file to compile string collapsed = collapseFiles(files, ".asm"); //compile outputEntry[] errors = new outputEntry[0]; outputEntry[] warnings = new outputEntry[0]; compileAssembly(linkable, ref errors, ref warnings, collapsed, outputFile, stdOut); processCompileResults(files, output, errors, warnings); //clean up File.Delete(collapsed); }
public ICompilerOutput <Project> CompileProject(Project project, StandardOutputCallback standardOutput) { #region split up every file in the project into a code file fileObj[] assemblyFiles = new fileObj[0]; fileObj[] cCodeFiles = new fileObj[0]; fileObj[] cHeaderFiles = new fileObj[0]; project.Root.Enumerate(true, delegate(ProjectEntity e) { if (!(e is ProjectFile)) { return(true); } //add the filename into the appropriate code file list ProjectFile file = (ProjectFile)e; string ext = file.Extension.ToLower(); switch (ext) { case ".c": Helpers.AddObject(ref cCodeFiles, new fileObj(file)); break; case ".h": Helpers.AddObject(ref cHeaderFiles, new fileObj(file)); break; case ".asm": Helpers.AddObject(ref assemblyFiles, new fileObj(file)); break; } return(true); }); #endregion //define the final output file string finalOutput = getOuputFilename(project, "build.bin"); StandardCompileOutput <Project> output = new StandardCompileOutput <Project>(finalOutput, project); string[] outputFiles = new string[0]; if (File.Exists(finalOutput)) { File.Delete(finalOutput); } //define whether or not the assembly code should //be linked (no point in linking if theres nothing //to link with) bool linkable = cCodeFiles.Length != 0 || cHeaderFiles.Length != 0; //compile the assembly if (assemblyFiles.Length != 0) { //make sure that the main entry point assembly file is at the top //of the list to be compiled first. int bootfileIndex = -1; for (int c = 0; c < assemblyFiles.Length; c++) { if (assemblyFiles[c].ProjectFile.Name.ToLower() == "boot.asm") { bootfileIndex = c; break; } } if (bootfileIndex != -1) { Helpers.SwapEntries(ref assemblyFiles, bootfileIndex, 0); } string asmOut = getOuputFilename(project, "asm.o"); compileAssembly(linkable, asmOut, output, assemblyFiles, standardOutput); Helpers.AddObject(ref outputFiles, asmOut); //if there are no C code/header files, then there is no point //compiling and linking them with the ASM code. if (!linkable) { if (File.Exists(asmOut)) { File.Move(asmOut, finalOutput); } return(output); } } //compile all the C code string cOut = getOuputFilename(project, "c.o"); compileC(cOut, output, cCodeFiles, cHeaderFiles, standardOutput); Helpers.AddObject(ref outputFiles, cOut); //if there was no success, do not continue with linking. if (output.Errors.Length != 0) { return(output); } //link the c and assembly code together. link( outputFiles, finalOutput, output, standardOutput); return(output); }