mirror of
https://github.com/irmen/prog8.git
synced 2024-07-24 06:29:22 +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 binFile = outputDir.resolve("$name.bin")
|
||||||
private val viceMonListFile = outputDir.resolve("$name.$viceMonListPostfix")
|
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)
|
// 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",
|
val command = mutableListOf("64tass", "--ascii", "--case-sensitive", "--long-branch",
|
||||||
"-Wall", "-Wno-strict-bool", "-Wno-shadow", // "-Werror",
|
"-Wall", "-Wno-strict-bool", "-Wno-shadow", // "-Werror",
|
||||||
"--dump-labels", "--vice-labels", "-l", viceMonListFile.toString(), "--no-monitor")
|
"--dump-labels", "--vice-labels", "-l", viceMonListFile.toString(), "--no-monitor")
|
||||||
|
|
||||||
|
if(quiet)
|
||||||
|
command.add("--quiet")
|
||||||
|
|
||||||
val outFile = when (options.output) {
|
val outFile = when (options.output) {
|
||||||
OutputType.PRG -> {
|
OutputType.PRG -> {
|
||||||
command.add("--cbm-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 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 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 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 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 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)
|
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>()
|
val results = mutableListOf<CompilationResult>()
|
||||||
for(filepathRaw in moduleFiles) {
|
for(filepathRaw in moduleFiles) {
|
||||||
val filepath = pathFrom(filepathRaw).normalize()
|
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)
|
results.add(compilationResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +114,9 @@ private fun compileMain(args: Array<String>): Boolean {
|
|||||||
val filepath = pathFrom(filepathRaw).normalize()
|
val filepath = pathFrom(filepathRaw).normalize()
|
||||||
val compilationResult: CompilationResult
|
val compilationResult: CompilationResult
|
||||||
try {
|
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)
|
if(!compilationResult.success)
|
||||||
return false
|
return false
|
||||||
} catch (x: ParsingFailedError) {
|
} catch (x: ParsingFailedError) {
|
||||||
|
@ -34,6 +34,7 @@ fun compileProgram(filepath: Path,
|
|||||||
optimize: Boolean,
|
optimize: Boolean,
|
||||||
writeAssembly: Boolean,
|
writeAssembly: Boolean,
|
||||||
slowCodegenWarnings: Boolean,
|
slowCodegenWarnings: Boolean,
|
||||||
|
quietAssembler: Boolean,
|
||||||
compilationTarget: String,
|
compilationTarget: String,
|
||||||
sourceDirs: List<String>,
|
sourceDirs: List<String>,
|
||||||
outputDir: Path,
|
outputDir: Path,
|
||||||
@ -71,7 +72,7 @@ fun compileProgram(filepath: Path,
|
|||||||
// printAst(program)
|
// printAst(program)
|
||||||
|
|
||||||
if (writeAssembly) {
|
if (writeAssembly) {
|
||||||
val result = writeAssembly(program, errors, outputDir, compilationOptions)
|
val result = writeAssembly(program, errors, outputDir, quietAssembler, compilationOptions)
|
||||||
when (result) {
|
when (result) {
|
||||||
is WriteAssemblyResult.Ok -> programName = result.filename
|
is WriteAssemblyResult.Ok -> programName = result.filename
|
||||||
is WriteAssemblyResult.Fail -> {
|
is WriteAssemblyResult.Fail -> {
|
||||||
@ -308,6 +309,7 @@ private sealed class WriteAssemblyResult {
|
|||||||
private fun writeAssembly(program: Program,
|
private fun writeAssembly(program: Program,
|
||||||
errors: IErrorReporter,
|
errors: IErrorReporter,
|
||||||
outputDir: Path,
|
outputDir: Path,
|
||||||
|
quietAssembler: Boolean,
|
||||||
compilerOptions: CompilationOptions
|
compilerOptions: CompilationOptions
|
||||||
): WriteAssemblyResult {
|
): WriteAssemblyResult {
|
||||||
// asm generation directly from the Ast
|
// asm generation directly from the Ast
|
||||||
@ -325,7 +327,7 @@ private fun writeAssembly(program: Program,
|
|||||||
outputDir).compileToAssembly()
|
outputDir).compileToAssembly()
|
||||||
|
|
||||||
return if(assembly.valid && errors.noErrors()) {
|
return if(assembly.valid && errors.noErrors()) {
|
||||||
val assemblerReturnStatus = assembly.assemble(compilerOptions)
|
val assemblerReturnStatus = assembly.assemble(quietAssembler, compilerOptions)
|
||||||
if(assemblerReturnStatus!=0)
|
if(assemblerReturnStatus!=0)
|
||||||
WriteAssemblyResult.Fail("assembler step failed with return code $assemblerReturnStatus")
|
WriteAssemblyResult.Fail("assembler step failed with return code $assemblerReturnStatus")
|
||||||
else {
|
else {
|
||||||
|
@ -44,6 +44,7 @@ class TestCompilerOnExamples {
|
|||||||
optimize,
|
optimize,
|
||||||
writeAssembly = true,
|
writeAssembly = true,
|
||||||
slowCodegenWarnings = false,
|
slowCodegenWarnings = false,
|
||||||
|
quietAssembler = true,
|
||||||
compilationTarget = platform.name,
|
compilationTarget = platform.name,
|
||||||
sourceDirs = listOf(),
|
sourceDirs = listOf(),
|
||||||
outputDir
|
outputDir
|
||||||
|
@ -49,6 +49,7 @@ class TestCompilerOptionSourcedirs {
|
|||||||
optimize = false,
|
optimize = false,
|
||||||
writeAssembly = true,
|
writeAssembly = true,
|
||||||
slowCodegenWarnings = false,
|
slowCodegenWarnings = false,
|
||||||
|
quietAssembler = true,
|
||||||
compilationTarget = Cx16Target.name,
|
compilationTarget = Cx16Target.name,
|
||||||
sourceDirs,
|
sourceDirs,
|
||||||
outputDir
|
outputDir
|
||||||
|
@ -42,6 +42,7 @@ internal fun compileFile(
|
|||||||
optimize,
|
optimize,
|
||||||
writeAssembly = writeAssembly,
|
writeAssembly = writeAssembly,
|
||||||
slowCodegenWarnings = false,
|
slowCodegenWarnings = false,
|
||||||
|
quietAssembler = true,
|
||||||
platform.name,
|
platform.name,
|
||||||
sourceDirs = listOf(),
|
sourceDirs = listOf(),
|
||||||
outputDir,
|
outputDir,
|
||||||
|
@ -11,5 +11,5 @@ const val subroutineFloatEvalResultVar2 = "_prog8_float_eval_result2"
|
|||||||
interface IAssemblyProgram {
|
interface IAssemblyProgram {
|
||||||
val valid: Boolean
|
val valid: Boolean
|
||||||
val name: String
|
val name: String
|
||||||
fun assemble(options: CompilationOptions): Int
|
fun assemble(quiet: Boolean, options: CompilationOptions): Int
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,8 @@ class RequestParser : Take {
|
|||||||
slowCodegenWarnings = true,
|
slowCodegenWarnings = true,
|
||||||
compilationTarget = "c64",
|
compilationTarget = "c64",
|
||||||
sourceDirs = emptyList(),
|
sourceDirs = emptyList(),
|
||||||
outputDir = Path.of("")
|
outputDir = Path.of(""),
|
||||||
|
quietAssembler = false
|
||||||
)
|
)
|
||||||
return RsJson(Jsonding())
|
return RsJson(Jsonding())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user