From f335251c2b71295f5ff4cb849fc22d58ffe1e9fd Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sat, 1 Feb 2025 16:09:43 +0100 Subject: [PATCH] added ability to specify additional assembler options in custom target configurations --- .../src/prog8/code/core/ICompilationTarget.kt | 1 + codeCore/src/prog8/code/target/AtariTarget.kt | 1 + codeCore/src/prog8/code/target/C128Target.kt | 1 + codeCore/src/prog8/code/target/C64Target.kt | 1 + .../src/prog8/code/target/ConfigFileTarget.kt | 4 ++++ codeCore/src/prog8/code/target/Cx16Target.kt | 1 + .../src/prog8/code/target/Neo6502Target.kt | 1 + codeCore/src/prog8/code/target/PETTarget.kt | 1 + codeCore/src/prog8/code/target/VMTarget.kt | 1 + .../prog8/codegen/cpu6502/AssemblyProgram.kt | 21 +++++++------------ examples/customtarget/tinyc64.properties | 4 ++-- examples/customtarget/tinycx16.properties | 4 ++-- examples/customtarget/tinypet.properties | 4 ++-- 13 files changed, 26 insertions(+), 19 deletions(-) diff --git a/codeCore/src/prog8/code/core/ICompilationTarget.kt b/codeCore/src/prog8/code/core/ICompilationTarget.kt index 4f9fd40c2..e0b345778 100644 --- a/codeCore/src/prog8/code/core/ICompilationTarget.kt +++ b/codeCore/src/prog8/code/core/ICompilationTarget.kt @@ -35,6 +35,7 @@ interface ICompilationTarget: IStringEncoding, IMemSizer { var golden: GoldenRam val libraryPath: Path? val customLauncher: List + val additionalAssemblerOptions: String? fun initializeMemoryAreas(compilerOptions: CompilationOptions) fun getFloatAsmBytes(num: Number): String diff --git a/codeCore/src/prog8/code/target/AtariTarget.kt b/codeCore/src/prog8/code/target/AtariTarget.kt index 1eb17564b..5bc984738 100644 --- a/codeCore/src/prog8/code/target/AtariTarget.kt +++ b/codeCore/src/prog8/code/target/AtariTarget.kt @@ -12,6 +12,7 @@ class AtariTarget: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by override val defaultEncoding = Encoding.ATASCII override val libraryPath = null override val customLauncher: List = emptyList() + override val additionalAssemblerOptions = null companion object { const val NAME = "atari" diff --git a/codeCore/src/prog8/code/target/C128Target.kt b/codeCore/src/prog8/code/target/C128Target.kt index 3027e71d4..2d8ced598 100644 --- a/codeCore/src/prog8/code/target/C128Target.kt +++ b/codeCore/src/prog8/code/target/C128Target.kt @@ -19,6 +19,7 @@ class C128Target: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by N override val defaultEncoding = Encoding.PETSCII override val libraryPath = null override val customLauncher: List = emptyList() + override val additionalAssemblerOptions = null companion object { const val NAME = "c128" diff --git a/codeCore/src/prog8/code/target/C64Target.kt b/codeCore/src/prog8/code/target/C64Target.kt index b6ecba4a4..7a85de005 100644 --- a/codeCore/src/prog8/code/target/C64Target.kt +++ b/codeCore/src/prog8/code/target/C64Target.kt @@ -12,6 +12,7 @@ class C64Target: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by No override val defaultEncoding = Encoding.PETSCII override val libraryPath = null override val customLauncher: List = emptyList() + override val additionalAssemblerOptions = null companion object { const val NAME = "c64" diff --git a/codeCore/src/prog8/code/target/ConfigFileTarget.kt b/codeCore/src/prog8/code/target/ConfigFileTarget.kt index a7a01fb11..fff3c46d0 100644 --- a/codeCore/src/prog8/code/target/ConfigFileTarget.kt +++ b/codeCore/src/prog8/code/target/ConfigFileTarget.kt @@ -27,6 +27,7 @@ class ConfigFileTarget( override val BSSGOLDENRAM_END: UInt, override val libraryPath: Path, override val customLauncher: List, + override val additionalAssemblerOptions: String?, val ioAddresses: List, val zpScratchB1: UInt, val zpScratchReg: UInt, @@ -107,6 +108,8 @@ class ConfigFileTarget( if(customLauncherStr?.isNotBlank()==true) (customLauncherStr+"\n").lines().map { it.trimEnd() } else emptyList() + val assemblerOptionsStr = props.getProperty("assembler_options", "").trim() + val assemblerOptions = if(assemblerOptionsStr.isBlank()) null else assemblerOptionsStr return ConfigFileTarget( configfile.nameWithoutExtension, @@ -122,6 +125,7 @@ class ConfigFileTarget( props.getInteger("bss_goldenram_end"), libraryPath, customLauncher, + assemblerOptions, ioAddresses, props.getInteger("zp_scratch_b1"), props.getInteger("zp_scratch_reg"), diff --git a/codeCore/src/prog8/code/target/Cx16Target.kt b/codeCore/src/prog8/code/target/Cx16Target.kt index d9dfdd7da..4ea84cf43 100644 --- a/codeCore/src/prog8/code/target/Cx16Target.kt +++ b/codeCore/src/prog8/code/target/Cx16Target.kt @@ -19,6 +19,7 @@ class Cx16Target: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by N override val defaultEncoding = Encoding.PETSCII override val libraryPath = null override val customLauncher: List = emptyList() + override val additionalAssemblerOptions = null companion object { const val NAME = "cx16" diff --git a/codeCore/src/prog8/code/target/Neo6502Target.kt b/codeCore/src/prog8/code/target/Neo6502Target.kt index f88b48964..24c8bdaa5 100644 --- a/codeCore/src/prog8/code/target/Neo6502Target.kt +++ b/codeCore/src/prog8/code/target/Neo6502Target.kt @@ -11,6 +11,7 @@ class Neo6502Target: ICompilationTarget, IStringEncoding by Encoder, IMemSizer b override val defaultEncoding = Encoding.ISO override val libraryPath = null override val customLauncher: List = emptyList() + override val additionalAssemblerOptions = null companion object { const val NAME = "neo" diff --git a/codeCore/src/prog8/code/target/PETTarget.kt b/codeCore/src/prog8/code/target/PETTarget.kt index 5d402a094..4a080ad3a 100644 --- a/codeCore/src/prog8/code/target/PETTarget.kt +++ b/codeCore/src/prog8/code/target/PETTarget.kt @@ -19,6 +19,7 @@ class PETTarget: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by No override val defaultEncoding = Encoding.PETSCII override val libraryPath = null override val customLauncher: List = emptyList() + override val additionalAssemblerOptions = null companion object { const val NAME = "pet32" diff --git a/codeCore/src/prog8/code/target/VMTarget.kt b/codeCore/src/prog8/code/target/VMTarget.kt index 6deb883b1..a0d1c8ca4 100644 --- a/codeCore/src/prog8/code/target/VMTarget.kt +++ b/codeCore/src/prog8/code/target/VMTarget.kt @@ -12,6 +12,7 @@ class VMTarget: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by Nor override val defaultEncoding = Encoding.ISO override val libraryPath = null override val customLauncher: List = emptyList() + override val additionalAssemblerOptions = null companion object { const val NAME = "virtual" diff --git a/codeGenCpu6502/src/prog8/codegen/cpu6502/AssemblyProgram.kt b/codeGenCpu6502/src/prog8/codegen/cpu6502/AssemblyProgram.kt index 1fa06e7c1..4316ebdcd 100644 --- a/codeGenCpu6502/src/prog8/codegen/cpu6502/AssemblyProgram.kt +++ b/codeGenCpu6502/src/prog8/codegen/cpu6502/AssemblyProgram.kt @@ -29,11 +29,8 @@ internal class AssemblyProgram( ProgramType.CBMPRG -> { // CBM machines .prg generation. - // 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", "-Werror", - "--dump-labels", "--vice-labels", "--labels=$viceMonListFile" - ) + "-Wall", "--no-monitor", "--dump-labels", "--vice-labels", "--labels=$viceMonListFile") if(options.warnSymbolShadowing) command.add("-Wshadow") @@ -44,7 +41,7 @@ internal class AssemblyProgram( command.add("--quiet") if(options.asmListfile) { - command.addAll(listOf("--list=$listFile", "--no-monitor")) + command.add("--list=$listFile") } val outFile = when (options.output) { @@ -65,6 +62,7 @@ internal class AssemblyProgram( } else -> throw AssemblyError("invalid output type") } + command.addAll(listOf("--output", outFile.toString(), assemblyFile.toString())) assemblerCommand = command @@ -73,10 +71,7 @@ internal class AssemblyProgram( // Atari800XL .xex generation. // TODO are these options okay for atari? - val command = mutableListOf("64tass", "--ascii", "--case-sensitive", "--long-branch", - "-Wall", // "-Werror", "-Wno-strict-bool" - "--no-monitor" - ) + val command = mutableListOf("64tass", "--ascii", "--case-sensitive", "--long-branch", "-Wall", "--no-monitor") if(options.warnSymbolShadowing) command.add("-Wshadow") @@ -113,10 +108,7 @@ internal class AssemblyProgram( } // TODO are these options okay for neo? - val command = mutableListOf("64tass", "--case-sensitive", "--long-branch", - "-Wall", // "-Werror", "-Wno-strict-bool" - "--no-monitor" - ) + val command = mutableListOf("64tass", "--ascii", "--case-sensitive", "--long-branch", "-Wall", "--no-monitor") if(options.warnSymbolShadowing) command.add("-Wshadow") @@ -143,6 +135,9 @@ internal class AssemblyProgram( else -> throw AssemblyError("invalid program type") } + if(options.compTarget.additionalAssemblerOptions!=null) + assemblerCommand.add(options.compTarget.additionalAssemblerOptions!!) + val proc = ProcessBuilder(assemblerCommand).inheritIO().start() val result = proc.waitFor() if (result == 0 && compTarget.name !in targetWithoutBreakpointsForEmulator) { diff --git a/examples/customtarget/tinyc64.properties b/examples/customtarget/tinyc64.properties index eafeabada..f2279a7c5 100644 --- a/examples/customtarget/tinyc64.properties +++ b/examples/customtarget/tinyc64.properties @@ -36,5 +36,5 @@ library = ./libraries/tinyc64 # and instead outputs whatever is specified here. (You can use \n here for newline and \ for line continuantions) custom_launcher = -# TODO should the 64tass arguments be in here too perhaps? So that the "program" parameter that now selects 1 of a few fixed sets of arguments, can be removed? -# TODO should an emulator command line also be in here perhaps? So that -emu will work too. +# additional options passed to the assembler program +assembler_options = diff --git a/examples/customtarget/tinycx16.properties b/examples/customtarget/tinycx16.properties index 59d56219d..f1e14f9b8 100644 --- a/examples/customtarget/tinycx16.properties +++ b/examples/customtarget/tinycx16.properties @@ -36,5 +36,5 @@ library = ./libraries/tinycx16 # and instead outputs whatever is specified here. (You can use \n here for newline and \ for line continuantions) custom_launcher = -# TODO should the 64tass arguments be in here too perhaps? So that the "program" parameter that now selects 1 of a few fixed sets of arguments, can be removed? -# TODO should an emulator command line also be in here perhaps? So that -emu will work too. +# additional options passed to the assembler program +assembler_options = diff --git a/examples/customtarget/tinypet.properties b/examples/customtarget/tinypet.properties index edb8854f4..54b7fd0b4 100644 --- a/examples/customtarget/tinypet.properties +++ b/examples/customtarget/tinypet.properties @@ -36,5 +36,5 @@ library = ./libraries/tinypet # and instead outputs whatever is specified here. (You can use \n here for newline and \ for line continuantions) custom_launcher = -# TODO should the 64tass arguments be in here too perhaps? So that the "program" parameter that now selects 1 of a few fixed sets of arguments, can be removed? -# TODO should an emulator command line also be in here perhaps? So that -emu will work too. +# additional options passed to the assembler program +assembler_options =