/// <summary> /// Builds from supplied project file a list of string arguments to pass to 'cl65' /// </summary> /// <param name="project"></param> /// <returns>A List of strings representing the CL65 arguments</returns> private static List <string> BuildArgumentsList(Cc65Project project) { var result = new List <string> { // Add target args ... TARGET_OPTION, project.TargetPlatform }; // Add input files ... foreach (var inputFile in project.InputFiles) { result.Add(inputFile); } // Add optimise arg, if needed ... if (project.OptimiseCode) { result.Add(OPTIMISE_OPTION); } // Add output file args ... result.Add(OUTPUT_FILE_OPTION); result.Add(project.OutputFile); return(result); }
/// <summary> /// Compiles source file associated with project file into output file using 'cl65' /// </summary> /// <param name="project"></param> /// <returns></returns> public static async Task <CliWrap.Models.ExecutionResult> Compile(Cc65Project project) { CliWrap.Models.ExecutionResult result; // Take a copy of the current working directory ... var originalDir = Directory.GetCurrentDirectory(); try { // Switch to projects working directory ... Directory.SetCurrentDirectory(project.WorkingDirectory); // Build an arguments list from the project settings to pass to CL65 ... var argumentList = BuildArgumentsList(project); // Call CL65 with project settings ... result = await Cli.Wrap(CL65) .SetEnvironmentVariable(CC65_TARGET, project.TargetPlatform) .SetArguments(argumentList) .EnableExitCodeValidation(false) .ExecuteAsync(); } finally { // Always restore the original working directory ... Directory.SetCurrentDirectory(originalDir); } return(result); }