1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 23:29:39 +00:00

cl65: Remove temporary .o files

This commit is contained in:
Jesse Rosenstock 2020-07-02 22:41:38 +02:00 committed by Oliver Schmidt
parent 410e4502ee
commit 021362fb75

View File

@ -112,6 +112,9 @@ static CmdDesc CO65 = { 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 };
/* Pseudo-command to track files we want to delete */
static CmdDesc RM = { 0, 0, 0, 0, 0, 0, 0 };
/* Variables controlling the steps we're doing */
static int DoLink = 1;
static int DoAssemble = 1;
@ -456,6 +459,19 @@ static void ExecProgram (CmdDesc* Cmd)
static void RemoveTempFiles (void)
{
unsigned I;
for (I = 0; I < RM.FileCount; ++I) {
if (remove (RM.Files[I]) < 0) {
Warning ("Cannot remove temporary file '%s': %s",
RM.Files[I], strerror (errno));
}
}
}
static void Link (void)
/* Link the resulting executable */
{
@ -534,6 +550,8 @@ static void AssembleFile (const char* File, unsigned ArgCount)
*/
char* ObjName = MakeFilename (File, ".o");
CmdAddFile (&LD65, ObjName);
/* This is just a temporary file, schedule it for removal */
CmdAddFile (&RM, ObjName);
xfree (ObjName);
} else {
/* This is the final step. If an output name is given, set it */
@ -1641,6 +1659,8 @@ int main (int argc, char* argv [])
Link ();
}
RemoveTempFiles ();
/* Return an apropriate exit code */
return EXIT_SUCCESS;
}