From: cuz Date: Thu, 22 Jun 2000 21:22:39 +0000 (+0000) Subject: Added support for geos resource files X-Git-Tag: V2.12.0~3403 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4e647d2d6836f912b122a5d1e58f7e5144d15065;p=cc65 Added support for geos resource files git-svn-id: svn://svn.cc65.org/cc65/trunk@110 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/src/cl65/main.c b/src/cl65/main.c index 2a12c2179..a0cac2250 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -78,6 +78,7 @@ struct CmdDesc_ { static CmdDesc CC65 = { 0, 0, 0, 0, 0, 0, 0 }; static CmdDesc CA65 = { 0, 0, 0, 0, 0, 0, 0 }; static CmdDesc LD65 = { 0, 0, 0, 0, 0, 0, 0 }; +static CmdDesc GRC = { 0, 0, 0, 0, 0, 0, 0 }; /* File types */ enum { @@ -85,7 +86,8 @@ enum { FILETYPE_C, FILETYPE_ASM, FILETYPE_OBJ, - FILETYPE_LIB + FILETYPE_LIB, + FILETYPE_GR, /* GEOS resource file */ }; /* Default file type, used if type unknown */ @@ -161,11 +163,13 @@ static unsigned GetFileType (const char* File) } FileTypes [] = { { ".c", FILETYPE_C }, { ".s", FILETYPE_ASM }, + { ".ss", FILETYPE_ASM }, { ".asm", FILETYPE_ASM }, { ".o", FILETYPE_OBJ }, { ".obj", FILETYPE_OBJ }, { ".a", FILETYPE_LIB }, { ".lib", FILETYPE_LIB }, + { ".grc", FILETYPE_GR }, }; unsigned I; @@ -532,8 +536,50 @@ static void Compile (const char* File) +static void CompileRes (const char* File) +/* Compile the given geos resource file */ +{ + char* AsmName = 0; + + /* Remember the current assembler argument count */ + unsigned ArgCount = GRC.ArgCount; + + /* The assembler file name will be the name of the source file + * with .grc replaced by ".ss". + */ + AsmName = MakeFilename (File, ".ss"); + + /* Add the file as argument for the resource compiler */ + CmdAddArg (&GRC, File); + + /* Add a NULL pointer to terminate the argument list */ + CmdAddArg (&GRC, 0); + + /* Run the compiler */ + ExecProgram (&GRC); + + /* Remove the excess arguments */ + CmdDelArgs (&GRC, ArgCount); + + /* If this is not the final step, assemble the generated file, then + * remove it + */ + if (!DontAssemble) { + Assemble (AsmName); + if (remove (AsmName) < 0) { + Warning ("Cannot remove temporary file `%s': %s", + AsmName, strerror (errno)); + } + } + + /* Free the assembler file name which was allocated from the heap */ + xfree (AsmName); +} + + + /*****************************************************************************/ -/* Code */ +/* Code */ /*****************************************************************************/ @@ -696,6 +742,7 @@ int main (int argc, char* argv []) CmdInit (&CC65, "cc65"); CmdInit (&CA65, "ca65"); CmdInit (&LD65, "ld65"); + CmdInit (&GRC, "grc"); /* Check the parameters */ I = 1; @@ -854,6 +901,11 @@ int main (int argc, char* argv []) CmdAddFile (&LD65, Arg); break; + case FILETYPE_GR: + /* Add to the resource compiler files */ + CompileRes (Arg); + break; + default: Error ("Don't know what to do with `%s'", Arg);