cl65: Remove temporary .o files
This commit is contained in:
committed by
Oliver Schmidt
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 LD65 = { 0, 0, 0, 0, 0, 0, 0 };
|
||||||
static CmdDesc GRC = { 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 */
|
/* Variables controlling the steps we're doing */
|
||||||
static int DoLink = 1;
|
static int DoLink = 1;
|
||||||
static int DoAssemble = 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)
|
static void Link (void)
|
||||||
/* Link the resulting executable */
|
/* Link the resulting executable */
|
||||||
{
|
{
|
||||||
@@ -534,6 +550,8 @@ static void AssembleFile (const char* File, unsigned ArgCount)
|
|||||||
*/
|
*/
|
||||||
char* ObjName = MakeFilename (File, ".o");
|
char* ObjName = MakeFilename (File, ".o");
|
||||||
CmdAddFile (&LD65, ObjName);
|
CmdAddFile (&LD65, ObjName);
|
||||||
|
/* This is just a temporary file, schedule it for removal */
|
||||||
|
CmdAddFile (&RM, ObjName);
|
||||||
xfree (ObjName);
|
xfree (ObjName);
|
||||||
} else {
|
} else {
|
||||||
/* This is the final step. If an output name is given, set it */
|
/* This is the final step. If an output name is given, set it */
|
||||||
@@ -1641,6 +1659,8 @@ int main (int argc, char* argv [])
|
|||||||
Link ();
|
Link ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RemoveTempFiles ();
|
||||||
|
|
||||||
/* Return an apropriate exit code */
|
/* Return an apropriate exit code */
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user