From 074a3f513eb0ab1543f8c153d4106b9b21fab8b2 Mon Sep 17 00:00:00 2001 From: Kugel Fuhr <98353208+kugelfuhr@users.noreply.github.com> Date: Wed, 9 Jul 2025 15:31:13 +0200 Subject: [PATCH] Add the --color and --no-utf8 options to cl65 which will pass it to the tools that understand it. --- doc/cl65.sgml | 14 ++++++++------ src/cl65/main.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/doc/cl65.sgml b/doc/cl65.sgml index f48e1353c..8413db6c0 100644 --- a/doc/cl65.sgml +++ b/doc/cl65.sgml @@ -34,7 +34,7 @@ and other things. --------------------------------------------------------------------------- Usage: cl65 [options] file [...] Short options: - -c Compile and assemble but don't link + -c Compile and assemble, but don't link -d Debug mode -g Add debug info -h Help (this text) @@ -55,10 +55,10 @@ Short options: -L path Specify a library search path -Ln name Create a VICE label file -O Optimize code - -Oi Optimize code, inline more code + -Oi Optimize code, inline runtime functions -Or Optimize code, honour the register keyword - -Os Optimize code, inline standard functions - -S Compile but don't assemble and link + -Os Optimize code, inline known C functions + -S Compile, but don't assemble and link -T Include source as comment -V Print the version number -W name[,...] Suppress compiler warnings @@ -81,8 +81,9 @@ Long options: --code-label name Define and export a CODE segment label --code-name seg Set the name of the CODE segment --codesize x Accept larger code by factor x + --color [on|auto|off] Color diagnostics (default: auto) --config name Use linker config file - --cpu type Set cpu type + --cpu type Set CPU type --create-dep name Create a make dependency file --create-full-dep name Create a full make dependency file --data-label name Define and export a DATA segment label @@ -101,8 +102,9 @@ Long options: --mapfile name Create a map file --memory-model model Set the memory model --module Link as a module - --module-id id Specify a module id for the linker + --module-id id Specify a module ID for the linker --no-target-lib Don't link the target library + --no-utf8 Disable use of UTF-8 in diagnostics --o65-model model Override the o65 model --obj file Link this object file --obj-path path Specify an object file search path diff --git a/src/cl65/main.c b/src/cl65/main.c index 6f2fe03df..0298dd601 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -70,6 +70,7 @@ /* common */ #include "attrib.h" #include "cmdline.h" +#include "consprop.h" #include "filetype.h" #include "fname.h" #include "mmodel.h" @@ -858,6 +859,7 @@ static void Usage (void) " --code-label name\t\tDefine and export a CODE segment label\n" " --code-name seg\t\tSet the name of the CODE segment\n" " --codesize x\t\t\tAccept larger code by factor x\n" + " --color [on|auto|off]\t\tColor diagnostics (default: auto)\n" " --config name\t\t\tUse linker config file\n" " --cpu type\t\t\tSet CPU type\n" " --create-dep name\t\tCreate a make dependency file\n" @@ -880,6 +882,7 @@ static void Usage (void) " --module\t\t\tLink as a module\n" " --module-id id\t\tSpecify a module ID for the linker\n" " --no-target-lib\t\tDon't link the target library\n" + " --no-utf8\t\t\tDisable use of UTF-8 in diagnostics\n" " --o65-model model\t\tOverride the o65 model\n" " --obj file\t\t\tLink this object file\n" " --obj-path path\t\tSpecify an object file search path\n" @@ -1028,6 +1031,20 @@ static void OptConfig (const char* Opt attribute ((unused)), const char* Arg) +static void OptColor(const char* Opt, const char* Arg) +/* Handle the --color option */ +{ + ColorMode Mode = CP_Parse (Arg); + if (Mode == CM_INVALID) { + Error ("Invalid argument to %s: %s", Opt, Arg); + } else { + CmdAddArg2 (&CA65, "--color", Arg); + CmdAddArg2 (&LD65, "--color", Arg); + } +} + + + static void OptCPU (const char* Opt attribute ((unused)), const char* Arg) /* Handle the --cpu option */ { @@ -1236,6 +1253,16 @@ static void OptNoTargetLib (const char* Opt attribute ((unused)), +static void OptNoUtf8 (const char* Opt attribute ((unused)), + const char* Arg attribute ((unused))) +/* Handle the --no-utf8 option */ +{ + CmdAddArg (&CA65, "--no-utf8"); + CmdAddArg (&LD65, "--no-utf8"); +} + + + static void OptO65Model (const char* Opt attribute ((unused)), const char* Arg) /* Handle the --o65-model option */ { @@ -1428,6 +1455,7 @@ int main (int argc, char* argv []) { "--code-label", 1, OptCodeLabel }, { "--code-name", 1, OptCodeName }, { "--codesize", 1, OptCodeSize }, + { "--color", 1, OptColor }, { "--config", 1, OptConfig }, { "--cpu", 1, OptCPU }, { "--create-dep", 1, OptCreateDep }, @@ -1450,6 +1478,7 @@ int main (int argc, char* argv []) { "--module", 0, OptModule }, { "--module-id", 1, OptModuleId }, { "--no-target-lib", 0, OptNoTargetLib }, + { "--no-utf8", 0, OptNoUtf8 }, { "--o65-model", 1, OptO65Model }, { "--obj", 1, OptObj }, { "--obj-path", 1, OptObjPath },