bugfixes
This commit is contained in:
@@ -526,12 +526,15 @@ static void Link (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void AssembleFile (const char* File, unsigned ArgCount)
|
static void AssembleFile (const char* File, const char* TmpFile, unsigned ArgCount)
|
||||||
/* Common routine to assemble a file. Will be called by Assemble() and
|
/* Common routine to assemble a file. Will be called by Assemble() and
|
||||||
** AssembleIntermediate(). Adds options common for both routines and
|
** AssembleIntermediate(). Adds options common for both routines and
|
||||||
** assembles the file. Will remove excess arguments after assembly.
|
** assembles the file. Will remove excess arguments after assembly.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
/* ObjName may be used for temporary or real filename */
|
||||||
|
char *ObjName;
|
||||||
|
|
||||||
/* Set the target system */
|
/* Set the target system */
|
||||||
CmdSetTarget (&CA65, Target);
|
CmdSetTarget (&CA65, Target);
|
||||||
|
|
||||||
@@ -541,7 +544,8 @@ static void AssembleFile (const char* File, unsigned ArgCount)
|
|||||||
** to the file list of the linker. The name of the output
|
** to the file list of the linker. The name of the output
|
||||||
** file is that of the input file with ".s" replaced by ".o".
|
** file is that of the input file with ".s" replaced by ".o".
|
||||||
*/
|
*/
|
||||||
char* ObjName = MakeFilename (File, ".o");
|
ObjName = MakeFilename (TmpFile ? TmpFile : File, ".o");
|
||||||
|
CmdSetOutput (&CA65, ObjName);
|
||||||
CmdAddFile (&LD65, ObjName);
|
CmdAddFile (&LD65, ObjName);
|
||||||
/* This is just a temporary file, schedule it for removal */
|
/* This is just a temporary file, schedule it for removal */
|
||||||
CmdAddFile (&RM, ObjName);
|
CmdAddFile (&RM, ObjName);
|
||||||
@@ -551,10 +555,15 @@ static void AssembleFile (const char* File, unsigned ArgCount)
|
|||||||
if (OutputName) {
|
if (OutputName) {
|
||||||
CmdSetOutput (&CA65, OutputName);
|
CmdSetOutput (&CA65, OutputName);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
ObjName = MakeFilename (File, ".o");
|
||||||
|
CmdSetOutput (&CA65, ObjName);
|
||||||
|
xfree (ObjName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add the file as argument for the assembler */
|
/* Add the file as argument for the assembler */
|
||||||
CmdAddArg (&CA65, File);
|
CmdAddArg (&CA65, TmpFile ? TmpFile : File);
|
||||||
|
|
||||||
/* Add a NULL pointer to terminate the argument list */
|
/* Add a NULL pointer to terminate the argument list */
|
||||||
CmdAddArg (&CA65, 0);
|
CmdAddArg (&CA65, 0);
|
||||||
@@ -568,7 +577,7 @@ static void AssembleFile (const char* File, unsigned ArgCount)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void AssembleIntermediate (const char* SourceFile)
|
static void AssembleIntermediate (const char* SourceFile, const char* TmpFile)
|
||||||
/* Assemble an intermediate file which was generated by a previous processing
|
/* Assemble an intermediate file which was generated by a previous processing
|
||||||
** step with SourceFile as input. The -dep options won't be added and
|
** step with SourceFile as input. The -dep options won't be added and
|
||||||
** the intermediate assembler file is removed after assembly.
|
** the intermediate assembler file is removed after assembly.
|
||||||
@@ -578,18 +587,20 @@ static void AssembleIntermediate (const char* SourceFile)
|
|||||||
** name. It's the same name with the extension replaced by ".s"
|
** name. It's the same name with the extension replaced by ".s"
|
||||||
*/
|
*/
|
||||||
char* AsmName = MakeFilename (SourceFile, ".s");
|
char* AsmName = MakeFilename (SourceFile, ".s");
|
||||||
|
char* AsmTmpName = TmpFile ? MakeFilename(TmpFile, ".s") : NULL;
|
||||||
|
|
||||||
/* Assemble the intermediate assembler file */
|
/* Assemble the intermediate assembler file */
|
||||||
AssembleFile (AsmName, CA65.ArgCount);
|
AssembleFile (AsmName, AsmTmpName, CA65.ArgCount);
|
||||||
|
|
||||||
/* Remove the input file */
|
/* Remove the input file */
|
||||||
if (remove (AsmName) < 0) {
|
if (remove (AsmTmpName ? AsmTmpName : AsmName) < 0) {
|
||||||
Warning ("Cannot remove temporary file '%s': %s",
|
Warning ("Cannot remove temporary file '%s': %s",
|
||||||
AsmName, strerror (errno));
|
AsmTmpName ? AsmTmpName : AsmName, strerror (errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the assembler file name which was allocated from the heap */
|
/* Free the assembler file name which was allocated from the heap */
|
||||||
xfree (AsmName);
|
xfree (AsmName);
|
||||||
|
xfree (AsmTmpName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -612,7 +623,7 @@ static void Assemble (const char* File)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Use the common routine */
|
/* Use the common routine */
|
||||||
AssembleFile (File, ArgCount);
|
AssembleFile (File, NULL, ArgCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -660,7 +671,7 @@ static void Compile (const char* File)
|
|||||||
/* Add the file as argument for the compiler */
|
/* Add the file as argument for the compiler */
|
||||||
CmdAddArg (&CC65, File);
|
CmdAddArg (&CC65, File);
|
||||||
|
|
||||||
if (DoAssemble && DoLink) {
|
if (DoAssemble) {
|
||||||
/* set a temporary output file name */
|
/* set a temporary output file name */
|
||||||
TmpFile = MakeTmpFilename(File, ".s");
|
TmpFile = MakeTmpFilename(File, ".s");
|
||||||
CmdSetOutput (&CC65, TmpFile);
|
CmdSetOutput (&CC65, TmpFile);
|
||||||
@@ -680,7 +691,7 @@ static void Compile (const char* File)
|
|||||||
*/
|
*/
|
||||||
if (DoAssemble) {
|
if (DoAssemble) {
|
||||||
/* Assemble the intermediate file and remove it */
|
/* Assemble the intermediate file and remove it */
|
||||||
AssembleIntermediate (TmpFile ? TmpFile : File);
|
AssembleIntermediate (File, TmpFile);
|
||||||
if (TmpFile) {
|
if (TmpFile) {
|
||||||
xfree(TmpFile);
|
xfree(TmpFile);
|
||||||
}
|
}
|
||||||
@@ -717,7 +728,7 @@ static void CompileRes (const char* File)
|
|||||||
*/
|
*/
|
||||||
if (DoAssemble) {
|
if (DoAssemble) {
|
||||||
/* Assemble the intermediate file and remove it */
|
/* Assemble the intermediate file and remove it */
|
||||||
AssembleIntermediate (File);
|
AssembleIntermediate (File, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -753,7 +764,7 @@ static void ConvertO65 (const char* File)
|
|||||||
*/
|
*/
|
||||||
if (DoAssemble) {
|
if (DoAssemble) {
|
||||||
/* Assemble the intermediate file and remove it */
|
/* Assemble the intermediate file and remove it */
|
||||||
AssembleIntermediate (File);
|
AssembleIntermediate (File, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user