mirror of
https://github.com/irmen/prog8.git
synced 2025-01-26 19:30:59 +00:00
added option to suppress assembler output (and enabled this in unit tests)
This commit is contained in:
parent
9ccc65bf8f
commit
4b3f31c2ee
@ -27,12 +27,15 @@ class AssemblyProgram(
|
||||
private val binFile = outputDir.resolve("$name.bin")
|
||||
private val viceMonListFile = outputDir.resolve("$name.$viceMonListPostfix")
|
||||
|
||||
override fun assemble(options: CompilationOptions): Int {
|
||||
override fun assemble(quiet: Boolean, options: CompilationOptions): Int {
|
||||
// add "-Wlong-branch" to see warnings about conversion of branch instructions to jumps (default = do this silently)
|
||||
val command = mutableListOf("64tass", "--ascii", "--case-sensitive", "--long-branch",
|
||||
"-Wall", "-Wno-strict-bool", "-Wno-shadow", // "-Werror",
|
||||
"--dump-labels", "--vice-labels", "-l", viceMonListFile.toString(), "--no-monitor")
|
||||
|
||||
if(quiet)
|
||||
command.add("--quiet")
|
||||
|
||||
val outFile = when (options.output) {
|
||||
OutputType.PRG -> {
|
||||
command.add("--cbm-prg")
|
||||
|
@ -38,6 +38,7 @@ private fun compileMain(args: Array<String>): Boolean {
|
||||
val dontOptimize by cli.option(ArgType.Boolean, fullName = "noopt", description = "don't perform any optimizations")
|
||||
val watchMode by cli.option(ArgType.Boolean, fullName = "watch", description = "continuous compilation mode (watches for file changes), greatly increases compilation speed")
|
||||
val slowCodegenWarnings by cli.option(ArgType.Boolean, fullName = "slowwarn", description="show debug warnings about slow/problematic assembly code generation")
|
||||
val quietAssembler by cli.option(ArgType.Boolean, fullName = "quietasm", description = "don't print assembler output results")
|
||||
val compilationTarget by cli.option(ArgType.String, fullName = "target", description = "target output of the compiler, currently '${C64Target.name}' and '${Cx16Target.name}' available").default(C64Target.name)
|
||||
val sourceDirs by cli.option(ArgType.String, fullName="srcdirs", description = "list of extra paths, separated with ${File.pathSeparator}, to search in for imported modules").multiple().delimiter(File.pathSeparator)
|
||||
val moduleFiles by cli.argument(ArgType.String, fullName = "modules", description = "main module file(s) to compile").multiple(999)
|
||||
@ -74,7 +75,9 @@ private fun compileMain(args: Array<String>): Boolean {
|
||||
val results = mutableListOf<CompilationResult>()
|
||||
for(filepathRaw in moduleFiles) {
|
||||
val filepath = pathFrom(filepathRaw).normalize()
|
||||
val compilationResult = compileProgram(filepath, dontOptimize!=true, dontWriteAssembly!=true, slowCodegenWarnings==true, compilationTarget, srcdirs, outputPath)
|
||||
val compilationResult = compileProgram(filepath,
|
||||
dontOptimize!=true, dontWriteAssembly!=true, slowCodegenWarnings==true, quietAssembler==true,
|
||||
compilationTarget, srcdirs, outputPath)
|
||||
results.add(compilationResult)
|
||||
}
|
||||
|
||||
@ -111,7 +114,9 @@ private fun compileMain(args: Array<String>): Boolean {
|
||||
val filepath = pathFrom(filepathRaw).normalize()
|
||||
val compilationResult: CompilationResult
|
||||
try {
|
||||
compilationResult = compileProgram(filepath, dontOptimize!=true, dontWriteAssembly!=true, slowCodegenWarnings==true, compilationTarget, srcdirs, outputPath)
|
||||
compilationResult = compileProgram(filepath,
|
||||
dontOptimize!=true, dontWriteAssembly!=true, slowCodegenWarnings==true, quietAssembler==true,
|
||||
compilationTarget, srcdirs, outputPath)
|
||||
if(!compilationResult.success)
|
||||
return false
|
||||
} catch (x: ParsingFailedError) {
|
||||
|
@ -34,6 +34,7 @@ fun compileProgram(filepath: Path,
|
||||
optimize: Boolean,
|
||||
writeAssembly: Boolean,
|
||||
slowCodegenWarnings: Boolean,
|
||||
quietAssembler: Boolean,
|
||||
compilationTarget: String,
|
||||
sourceDirs: List<String>,
|
||||
outputDir: Path,
|
||||
@ -71,7 +72,7 @@ fun compileProgram(filepath: Path,
|
||||
// printAst(program)
|
||||
|
||||
if (writeAssembly) {
|
||||
val result = writeAssembly(program, errors, outputDir, compilationOptions)
|
||||
val result = writeAssembly(program, errors, outputDir, quietAssembler, compilationOptions)
|
||||
when (result) {
|
||||
is WriteAssemblyResult.Ok -> programName = result.filename
|
||||
is WriteAssemblyResult.Fail -> {
|
||||
@ -308,6 +309,7 @@ private sealed class WriteAssemblyResult {
|
||||
private fun writeAssembly(program: Program,
|
||||
errors: IErrorReporter,
|
||||
outputDir: Path,
|
||||
quietAssembler: Boolean,
|
||||
compilerOptions: CompilationOptions
|
||||
): WriteAssemblyResult {
|
||||
// asm generation directly from the Ast
|
||||
@ -325,7 +327,7 @@ private fun writeAssembly(program: Program,
|
||||
outputDir).compileToAssembly()
|
||||
|
||||
return if(assembly.valid && errors.noErrors()) {
|
||||
val assemblerReturnStatus = assembly.assemble(compilerOptions)
|
||||
val assemblerReturnStatus = assembly.assemble(quietAssembler, compilerOptions)
|
||||
if(assemblerReturnStatus!=0)
|
||||
WriteAssemblyResult.Fail("assembler step failed with return code $assemblerReturnStatus")
|
||||
else {
|
||||
|
@ -44,6 +44,7 @@ class TestCompilerOnExamples {
|
||||
optimize,
|
||||
writeAssembly = true,
|
||||
slowCodegenWarnings = false,
|
||||
quietAssembler = true,
|
||||
compilationTarget = platform.name,
|
||||
sourceDirs = listOf(),
|
||||
outputDir
|
||||
|
@ -49,6 +49,7 @@ class TestCompilerOptionSourcedirs {
|
||||
optimize = false,
|
||||
writeAssembly = true,
|
||||
slowCodegenWarnings = false,
|
||||
quietAssembler = true,
|
||||
compilationTarget = Cx16Target.name,
|
||||
sourceDirs,
|
||||
outputDir
|
||||
|
@ -42,6 +42,7 @@ internal fun compileFile(
|
||||
optimize,
|
||||
writeAssembly = writeAssembly,
|
||||
slowCodegenWarnings = false,
|
||||
quietAssembler = true,
|
||||
platform.name,
|
||||
sourceDirs = listOf(),
|
||||
outputDir,
|
||||
|
@ -11,5 +11,5 @@ const val subroutineFloatEvalResultVar2 = "_prog8_float_eval_result2"
|
||||
interface IAssemblyProgram {
|
||||
val valid: Boolean
|
||||
val name: String
|
||||
fun assemble(options: CompilationOptions): Int
|
||||
fun assemble(quiet: Boolean, options: CompilationOptions): Int
|
||||
}
|
||||
|
@ -35,7 +35,8 @@ class RequestParser : Take {
|
||||
slowCodegenWarnings = true,
|
||||
compilationTarget = "c64",
|
||||
sourceDirs = emptyList(),
|
||||
outputDir = Path.of("")
|
||||
outputDir = Path.of(""),
|
||||
quietAssembler = false
|
||||
)
|
||||
return RsJson(Jsonding())
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user