mirror of
https://github.com/cc65/cc65.git
synced 2025-01-12 02:30:44 +00:00
cl65: Remove temporary .o files
This commit is contained in:
parent
410e4502ee
commit
021362fb75
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user